Skip to content

Commit

Permalink
fix gogo source crashing on mp4
Browse files Browse the repository at this point in the history
  • Loading branch information
riimuru committed Oct 15, 2022
1 parent f52756d commit a2ccabe
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 42 deletions.
5 changes: 5 additions & 0 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.

47 changes: 28 additions & 19 deletions dist/utils/extractors/gogocdn.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/utils/extractors/gogocdn.js.map

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@consumet/extensions",
"version": "1.1.7",
"version": "1.1.8",
"description": "Nodejs library that provides high-level APIs for obtaining information on various entertainment media such as books, movies, comic books, anime, manga, and so on.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
6 changes: 6 additions & 0 deletions src/providers/anime/gogoanime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,4 +320,10 @@ class Gogoanime extends AnimeParser {
};
}

// (async () => {
// const anime = new Gogoanime();
// const animeInfo = await anime.fetchEpisodeSources('juuni-taisen-dub-episode-6', StreamingServers.GogoCDN);
// console.log(animeInfo);
// })();

export default Gogoanime;
48 changes: 28 additions & 20 deletions src/utils/extractors/gogocdn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,33 +37,41 @@ class GogoCDN extends VideoExtractor {
const decryptedData = await this.decryptAjaxData(encryptedData.data.data);
if (!decryptedData.source) throw new Error('No source found. Try a different server.');

//console.log(decryptedData);

const resResult = await axios.get(decryptedData.source[0].file.toString());
const resolutions = resResult.data.match(/(RESOLUTION=)(.*)(\s*?)(\s*.*)/g);
resolutions.forEach((res: string) => {
var index = decryptedData.source[0].file.lastIndexOf('/');
var quality = res.split('\n')[0].split('x')[1].split(',')[0];
var url = decryptedData.source[0].file.slice(0, index);
this.sources.push({
url: url + '/' + res.split('\n')[1],
isM3U8: (url + res.split('\n')[1]).includes('.m3u8'),
quality: quality + 'p',
if (decryptedData.source[0].file.includes('.m3u8')) {
const resResult = await axios.get(decryptedData.source[0].file.toString());
const resolutions = resResult.data.match(/(RESOLUTION=)(.*)(\s*?)(\s*.*)/g);
resolutions.forEach((res: string) => {
var index = decryptedData.source[0].file.lastIndexOf('/');
var quality = res.split('\n')[0].split('x')[1].split(',')[0];
var url = decryptedData.source[0].file.slice(0, index);
this.sources.push({
url: url + '/' + res.split('\n')[1],
isM3U8: (url + res.split('\n')[1]).includes('.m3u8'),
quality: quality + 'p',
});
});
});

decryptedData.source.forEach((source: any) => {
this.sources.push({
url: source.file,
isM3U8: source.file.includes('.m3u8'),
quality: 'default'
decryptedData.source.forEach((source: any) => {
this.sources.push({
url: source.file,
isM3U8: source.file.includes('.m3u8'),
quality: 'default',
});
});
});
} else
decryptedData.source.forEach((source: any) => {
this.sources.push({
url: source.file,
isM3U8: source.file.includes('.m3u8'),
quality: source.label.split(' ')[0] + 'p',
});
});

decryptedData.source_bk.forEach((source: any) => {
this.sources.push({
url: source.file,
isM3U8: source.file.includes('.m3u8'),
quality: 'backup'
quality: 'backup',
});
});

Expand Down

0 comments on commit a2ccabe

Please sign in to comment.