mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 15:41:45 +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=" +
|
||||
Math.round(new Date().getTime() / 1000);
|
||||
console.log("nfEpisodesUrl", url);
|
||||
const res = yield axios.get(url, {
|
||||
headers: {
|
||||
"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);
|
||||
let page = 1;
|
||||
let hasMorePages = true;
|
||||
const episodeList = [];
|
||||
(_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,
|
||||
while (hasMorePages) {
|
||||
const res = yield axios.get(url + `&page=${page}`, {
|
||||
headers: {
|
||||
"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;
|
||||
}
|
||||
catch (err) {
|
||||
|
||||
@@ -21,25 +21,33 @@ export const getEpisodes = async function ({
|
||||
"&t=" +
|
||||
Math.round(new Date().getTime() / 1000);
|
||||
console.log("nfEpisodesUrl", url);
|
||||
const res = await axios.get(url, {
|
||||
headers: {
|
||||
"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);
|
||||
|
||||
let page = 1;
|
||||
let hasMorePages = true;
|
||||
const episodeList: EpisodeLink[] = [];
|
||||
|
||||
data?.episodes?.map((episode: any) => {
|
||||
episodeList.push({
|
||||
title: "Episode " + episode?.ep.replace("E", ""),
|
||||
link: episode?.id,
|
||||
while (hasMorePages) {
|
||||
const res = await axios.get(url + `&page=${page}`, {
|
||||
headers: {
|
||||
"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);
|
||||
|
||||
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;
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user