mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 23:51:44 +00:00
minify
This commit is contained in:
61
dist/mod/episodes.js
vendored
61
dist/mod/episodes.js
vendored
@@ -1,60 +1 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getEpisodes = void 0;
|
||||
const getEpisodes = function (_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ url, providerContext, }) {
|
||||
var _b;
|
||||
const { axios, cheerio } = providerContext;
|
||||
try {
|
||||
if (url.includes("url=")) {
|
||||
url = atob(url.split("url=")[1]);
|
||||
}
|
||||
const res = yield axios.get(url);
|
||||
const html = res.data;
|
||||
let $ = cheerio.load(html);
|
||||
if (url.includes("url=")) {
|
||||
const newUrl = (_b = $("meta[http-equiv='refresh']")
|
||||
.attr("content")) === null || _b === void 0 ? void 0 : _b.split("url=")[1];
|
||||
const res2 = yield axios.get(newUrl || url);
|
||||
const html2 = res2.data;
|
||||
$ = cheerio.load(html2);
|
||||
}
|
||||
const episodeLinks = [];
|
||||
$("h3,h4").map((i, element) => {
|
||||
const seriesTitle = $(element).text();
|
||||
const episodesLink = $(element).find("a").attr("href");
|
||||
if (episodesLink && episodesLink !== "#") {
|
||||
episodeLinks.push({
|
||||
title: seriesTitle.trim() || "No title found",
|
||||
link: episodesLink || "",
|
||||
});
|
||||
}
|
||||
});
|
||||
$("a.maxbutton").map((i, element) => {
|
||||
const seriesTitle = $(element).children("span").text();
|
||||
const episodesLink = $(element).attr("href");
|
||||
if (episodesLink && episodesLink !== "#") {
|
||||
episodeLinks.push({
|
||||
title: seriesTitle.trim() || "No title found",
|
||||
link: episodesLink || "",
|
||||
});
|
||||
}
|
||||
});
|
||||
return episodeLinks;
|
||||
}
|
||||
catch (err) {
|
||||
console.error(err);
|
||||
return [];
|
||||
}
|
||||
});
|
||||
};
|
||||
exports.getEpisodes = getEpisodes;
|
||||
"use strict";var __awaiter=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))(function(o,r){function a(t){try{u(i.next(t))}catch(t){r(t)}}function s(t){try{u(i.throw(t))}catch(t){r(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.getEpisodes=void 0;const getEpisodes=function(t){return __awaiter(this,arguments,void 0,function*({url:t,providerContext:e}){var n;const{axios:i,cheerio:o}=e;try{t.includes("url=")&&(t=atob(t.split("url=")[1]));const e=(yield i.get(t)).data;let r=o.load(e);if(t.includes("url=")){const e=null===(n=r("meta[http-equiv='refresh']").attr("content"))||void 0===n?void 0:n.split("url=")[1],a=(yield i.get(e||t)).data;r=o.load(a)}const a=[];return r("h3,h4").map((t,e)=>{const n=r(e).text(),i=r(e).find("a").attr("href");i&&"#"!==i&&a.push({title:n.trim()||"No title found",link:i||""})}),r("a.maxbutton").map((t,e)=>{const n=r(e).children("span").text(),i=r(e).attr("href");i&&"#"!==i&&a.push({title:n.trim()||"No title found",link:i||""})}),a}catch(t){return[]}})};exports.getEpisodes=getEpisodes;
|
||||
Reference in New Issue
Block a user