mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 23:51:44 +00:00
feat: add extractors bundled in file refactor stream handling in multiple providers
This commit is contained in:
@@ -14,6 +14,8 @@ export const getEpisodes = async function ({
|
||||
let $ = cheerio.load(html);
|
||||
|
||||
const episodeLinks: EpisodeLink[] = [];
|
||||
|
||||
// Try old format first (backward compatibility)
|
||||
$('a:contains("HubCloud")').map((i, element) => {
|
||||
const title = $(element).parent().prev().text();
|
||||
const link = $(element).attr("href");
|
||||
@@ -25,8 +27,58 @@ export const getEpisodes = async function ({
|
||||
}
|
||||
});
|
||||
|
||||
// If old format didn't work, try new format
|
||||
if (episodeLinks.length === 0) {
|
||||
// Find all anchor tags with href containing streaming services
|
||||
const streamingServices = ["hubcloud", "gdflix"];
|
||||
let currentTitle = "";
|
||||
|
||||
$('h5 span[style*="color"], h5').each((i, element) => {
|
||||
const text = $(element).text().trim();
|
||||
// Look for titles that contain quality indicators or episode info
|
||||
if (
|
||||
text &&
|
||||
(text.match(/\d{3,4}p/) ||
|
||||
text.includes("Ep") ||
|
||||
text.includes("Episode"))
|
||||
) {
|
||||
currentTitle = text;
|
||||
|
||||
// Find the next links after this title
|
||||
let nextElement = $(element).parent();
|
||||
for (let j = 0; j < 10; j++) {
|
||||
nextElement = nextElement.next();
|
||||
if (!nextElement.length) break;
|
||||
|
||||
const links = nextElement.find("a[href]");
|
||||
links.each((k, linkEl) => {
|
||||
const href = $(linkEl).attr("href");
|
||||
if (
|
||||
href &&
|
||||
streamingServices.some((service) => href.includes(service))
|
||||
) {
|
||||
// Determine server name from URL
|
||||
let serverName = "Play";
|
||||
if (href.includes("hubcloud")) serverName = "HubCloud";
|
||||
else if (href.includes("gdflix")) serverName = "GDFlix";
|
||||
else if (href.includes("pixeldrain")) serverName = "Pixeldrain";
|
||||
else if (href.includes("fastdl")) serverName = "FastDL";
|
||||
|
||||
const title = currentTitle
|
||||
? `${currentTitle} - ${serverName}`
|
||||
: serverName;
|
||||
episodeLinks.push({ title, link: href });
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// console.log(episodeLinks);
|
||||
return episodeLinks;
|
||||
return episodeLinks.length > 0
|
||||
? episodeLinks
|
||||
: [{ title: "Play", link: url }];
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user