mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 23:51:44 +00:00
fix: implement pagination for episode retrieval in NetflixMirror
This commit is contained in:
38
dist/netflixMirror/episodes.js
vendored
38
dist/netflixMirror/episodes.js
vendored
@@ -24,22 +24,32 @@ const getEpisodes = function (_a) {
|
|||||||
"&t=" +
|
"&t=" +
|
||||||
Math.round(new Date().getTime() / 1000);
|
Math.round(new Date().getTime() / 1000);
|
||||||
console.log("nfEpisodesUrl", url);
|
console.log("nfEpisodesUrl", url);
|
||||||
const res = yield axios.get(url, {
|
let page = 1;
|
||||||
headers: {
|
let hasMorePages = true;
|
||||||
"Content-Type": "application/json",
|
|
||||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36",
|
|
||||||
"Accept-Language": "en-US,en;q=0.9",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const data = res.data;
|
|
||||||
console.log("nfEpisodes", data);
|
|
||||||
const episodeList = [];
|
const episodeList = [];
|
||||||
(_b = data === null || data === void 0 ? void 0 : data.episodes) === null || _b === void 0 ? void 0 : _b.map((episode) => {
|
while (hasMorePages) {
|
||||||
episodeList.push({
|
const res = yield axios.get(url + `&page=${page}`, {
|
||||||
title: "Episode " + (episode === null || episode === void 0 ? void 0 : episode.ep.replace("E", "")),
|
headers: {
|
||||||
link: episode === null || episode === void 0 ? void 0 : episode.id,
|
"Content-Type": "application/json",
|
||||||
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36",
|
||||||
|
"Accept-Language": "en-US,en;q=0.9",
|
||||||
|
},
|
||||||
});
|
});
|
||||||
});
|
const data = res.data;
|
||||||
|
console.log("nfEpisodes", data);
|
||||||
|
(_b = data === null || data === void 0 ? void 0 : data.episodes) === null || _b === void 0 ? void 0 : _b.map((episode) => {
|
||||||
|
episodeList.push({
|
||||||
|
title: "Episode " + (episode === null || episode === void 0 ? void 0 : episode.ep.replace("E", "")),
|
||||||
|
link: episode === null || episode === void 0 ? void 0 : episode.id,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
if (data === null || data === void 0 ? void 0 : data.nextPageShow) {
|
||||||
|
page++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
hasMorePages = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
return episodeList;
|
return episodeList;
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|||||||
@@ -21,25 +21,33 @@ export const getEpisodes = async function ({
|
|||||||
"&t=" +
|
"&t=" +
|
||||||
Math.round(new Date().getTime() / 1000);
|
Math.round(new Date().getTime() / 1000);
|
||||||
console.log("nfEpisodesUrl", url);
|
console.log("nfEpisodesUrl", url);
|
||||||
const res = await axios.get(url, {
|
let page = 1;
|
||||||
headers: {
|
let hasMorePages = true;
|
||||||
"Content-Type": "application/json",
|
|
||||||
"User-Agent":
|
|
||||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36",
|
|
||||||
"Accept-Language": "en-US,en;q=0.9",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const data = res.data;
|
|
||||||
console.log("nfEpisodes", data);
|
|
||||||
|
|
||||||
const episodeList: EpisodeLink[] = [];
|
const episodeList: EpisodeLink[] = [];
|
||||||
|
while (hasMorePages) {
|
||||||
data?.episodes?.map((episode: any) => {
|
const res = await axios.get(url + `&page=${page}`, {
|
||||||
episodeList.push({
|
headers: {
|
||||||
title: "Episode " + episode?.ep.replace("E", ""),
|
"Content-Type": "application/json",
|
||||||
link: episode?.id,
|
"User-Agent":
|
||||||
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36",
|
||||||
|
"Accept-Language": "en-US,en;q=0.9",
|
||||||
|
},
|
||||||
});
|
});
|
||||||
});
|
const data = res.data;
|
||||||
|
console.log("nfEpisodes", data);
|
||||||
|
|
||||||
|
data?.episodes?.map((episode: any) => {
|
||||||
|
episodeList.push({
|
||||||
|
title: "Episode " + episode?.ep.replace("E", ""),
|
||||||
|
link: episode?.id,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
if (data?.nextPageShow) {
|
||||||
|
page++;
|
||||||
|
} else {
|
||||||
|
hasMorePages = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return episodeList;
|
return episodeList;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user