Refactor
This commit is contained in:
parent
01291a74fa
commit
40a5088513
|
@ -16,7 +16,7 @@ const run = async () => {
|
|||
}: JellyfinApiResponse = await fetchFromJellyfinApi();
|
||||
|
||||
const transformedItems = transformItems(items);
|
||||
const arrayOfExistingImdbIds = transformedItems.map(item => item.imdbId);
|
||||
const jellyfinExistingItems = transformedItems.map(item => item.imdbId);
|
||||
|
||||
// saveJfItemsToDisk({ totalItemCount, jellyfinItems: transformedItems });
|
||||
|
||||
|
@ -24,11 +24,11 @@ const run = async () => {
|
|||
// res.json(transformedItems)
|
||||
// });
|
||||
|
||||
// improve this endpoint to handle array of imdbId
|
||||
// improve this endpoint to handle array of imdbIds
|
||||
app.get("/check/:imdbId", async (req, res) => {
|
||||
const { imdbId } = req.params;
|
||||
const wishlistItems = await readWishlistFromDisk();
|
||||
if (arrayOfExistingImdbIds.includes(imdbId)) {
|
||||
if (jellyfinExistingItems.includes(imdbId)) {
|
||||
res.json({ imdbId, status: "ON_JF" });
|
||||
} else if (wishlistItems.includes(imdbId)) {
|
||||
res.json({ imdbId, status: "ON_WISHLIST" });
|
||||
|
@ -40,7 +40,7 @@ const run = async () => {
|
|||
app.post("/add", (req, res) => {
|
||||
const { imdbId: requestedImdbId } = req.body;
|
||||
|
||||
if (arrayOfExistingImdbIds.includes(requestedImdbId)) {
|
||||
if (jellyfinExistingItems.includes(requestedImdbId)) {
|
||||
res.send("DUP\n");
|
||||
} else {
|
||||
// to do: push to wishlist array
|
||||
|
|
Loading…
Reference in a new issue