Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Prince527GitHub committed Mar 2, 2024
1 parent 5212721 commit dd34052
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,15 @@ function checkAuth(req, res, next) {
}

next();
};
}

function createArray(array, size, offset) {
if (offset < 0 || offset >= array.length) return [];
if (size <= 0 || size > array.length - offset) return [];

const newArray = array.slice(offset, offset + size);
return newArray;
}

app.use(cors({ origin: "*" }));
app.use(require("./logs"));
Expand Down Expand Up @@ -299,10 +307,7 @@ app.get("/rest/getAlbumList2.view", async(req, res) => {

let albums = await (await fetch(`${config.music}/getall/albums?start=${offset || '0'}&limit=${size || '50'}&sortby=created_date&reverse=1`)).json();

if (type === "starred") {
albums.items = (await (await fetch(`${config.music}/albums/favorite?limit=0`)).json()).albums;
// albums = { items: albums.albums }
}
if (type === "starred") albums.items = createArray((await (await fetch(`${config.music}/albums/favorite?limit=0`)).json()).albums, size, offset);

let output = albums.items.map(item => ({
id: item.item?.albumhash || item.albumhash,
Expand Down

0 comments on commit dd34052

Please sign in to comment.