Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(streamwish): Grab video sources extractor #529

Merged
merged 7 commits into from
May 16, 2024
Merged
18 changes: 12 additions & 6 deletions dist/extractors/streamwish.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/extractors/streamwish.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions dist/providers/anime/gogoanime.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/providers/anime/gogoanime.js.map

Large diffs are not rendered by default.

20 changes: 12 additions & 8 deletions src/extractors/streamwish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@
override extract = async (videoUrl: URL): Promise<IVideo[]> => {
try {
const { data } = await this.client.get(videoUrl.href);

const unPackagedData = eval(/(eval)(\(f.*?)(\n<\/script>)/s.exec(data)![2]);
const links = unPackagedData.match(/file:\s*"([^"]+)"/);

this.sources.push({
quality: 'auto',
url: links[1],
isM3U8: links[1].includes('.m3u8'),
const links = data.match(/file:\s*"([^"]+)"/);
let lastLink = null;
links.forEach((link: string) => {
if(link.includes('file:"')){
link = link.replace('file:"', '').replace('"', '');
Fixed Show fixed Hide fixed
}
this.sources.push({
quality: lastLink! ? 'backup' : 'default',
url: link,
isM3U8: link.includes('.m3u8'),
});
lastLink = link;
});

const m3u8Content = await this.client.get(links[1], {
Expand Down
27 changes: 20 additions & 7 deletions src/providers/anime/gogoanime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
ProxyConfig,
} from '../../models';
import { USER_AGENT } from '../../utils';
import { GogoCDN, StreamSB } from '../../extractors';
import { GogoCDN, StreamSB, StreamWish } from '../../extractors';

class Gogoanime extends AnimeParser {
override readonly name = 'Gogoanime';
Expand All @@ -26,7 +26,7 @@ class Gogoanime extends AnimeParser {
protected override classPath = 'ANIME.Gogoanime';
private readonly ajaxUrl = 'https://ajax.gogocdn.net/ajax';


constructor(
customBaseURL?: string,
proxy?: ProxyConfig,
Expand All @@ -37,11 +37,11 @@ class Gogoanime extends AnimeParser {
if (proxy) {
// Initialize proxyConfig if provided
this.setProxy(proxy);
}
if (adapter) {
}
if (adapter) {
// Initialize adapter if provided
this.setAxiosAdapter(adapter);
}
}
}

/**
Expand Down Expand Up @@ -209,6 +209,14 @@ class Gogoanime extends AnimeParser {
sources: await new StreamSB(this.proxyConfig, this.adapter).extract(serverUrl),
download: `https://${serverUrl.host}/download${serverUrl.search}`,
};
case StreamingServers.StreamWish:
return {
headers: {
Referer: serverUrl.href,
},
sources: await new StreamWish(this.proxyConfig, this.adapter).extract(serverUrl),
download: `https://${serverUrl.host}/download${serverUrl.search}`,
};
default:
return {
headers: { Referer: serverUrl.href },
Expand Down Expand Up @@ -239,6 +247,11 @@ class Gogoanime extends AnimeParser {
$('div.anime_video_body > div.anime_muti_link > ul > li.streamsb > a').attr('data-video')!
);
break;
case StreamingServers.StreamWish:
serverUrl = new URL(
$('div.anime_video_body > div.anime_muti_link > ul > li.streamwish > a').attr('data-video')!
);
break;
default:
serverUrl = new URL(`${$('#load_anime > div > div > iframe').attr('src')}`);
break;
Expand Down Expand Up @@ -502,7 +515,7 @@ class Gogoanime extends AnimeParser {
const animeID = idParam ? idParam[1] : null;
if (!captchaToken)
captchaToken = '03AFcWeA5zy7DBK82U_tctVKelJ6L2duTWac5at2zXjHLX8XqUm8tI6NKWMxGd2gjh1vi2hnEyRhVgbMhdb9WjexRsJkxTt-C-_iIIZ5yC3E5I19G5Q0buSTcIQIZS6tskrz-mDn-d37aWxAJtqbg0Yoo1XsdVc5Yf4sB-9iQxQK-W_9YLep_QaAz8uL17gMMlCz5WZM3dbBEEGmk_qPbJu_pZ8kk-lFPDzd6iBobcpyIDRZgTgD4bYUnby5WZc11i00mrRiRS3m-qSY0lprGaBqoyY1BbRkQZ25AGPp5al4kSwBZqpcVgLrs3bjdo8XVWAe73_XLa8HhqLWbz_m5Ebyl5F9awwL7w4qikGj-AK7v2G8pgjT22kDLIeenQ_ss4jYpmSzgnuTItur9pZVzpPkpqs4mzr6y274AmJjzppRTDH4VFtta_E02-R7Hc1rUD2kCYt9BqsD7kDjmetnvLtBm97q5XgBS8rQfeH4P-xqiTAsJwXlcrPybSjnwPEptqYCPX5St_BSj4NQfSuzZowXu_qKsP4hAaE9L2W36MvqePPlEm6LChBT3tnqUwcEYNe5k7lkAAbunxx8q_X5Q3iEdcFqt9_0GWHebRBd5abEbjbmoqqCoQeZt7AUvkXCRfBDne-bf25ypyTtwgyuvYMYXau3zGUjgPUO9WIotZwyKyrYmjsZJ7TiM';

let res = null;
try {
res = await this.client.get(`${baseUrl}?id=${animeID}&captcha_v3=${captchaToken}`);
Expand All @@ -513,7 +526,7 @@ class Gogoanime extends AnimeParser {
const $ = load(res.data);
$('.dowload').each((_index, element) => {
const link = $(element).find('a');
if(link.attr('target') != '_blank'){
if (link.attr('target') != '_blank') {
downloadLinks.push({ source: link.text(), link: link.attr('href') }!);
}
});
Expand Down