Skip to content

Commit

Permalink
fix rapidcloud
Browse files Browse the repository at this point in the history
  • Loading branch information
riimuru committed Oct 24, 2022
1 parent bd2aec8 commit 0b28835
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 44 deletions.
11 changes: 8 additions & 3 deletions dist/providers/anime/zoro.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/zoro.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/providers/meta/anilist.js.map

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions dist/utils/extractors/rapidcloud.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/rapidcloud.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.2.1",
"version": "1.2.2",
"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
24 changes: 16 additions & 8 deletions src/providers/anime/zoro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,15 @@ class Zoro extends AnimeParser {
info.type = $('span.item').last().prev().prev().text().toUpperCase() as MediaFormat;
info.url = `${this.baseUrl}/${id}`;

const subDub = $('div.film-stats span.item div.tick-dub').toArray().map((value) => $(value).text().toLowerCase())
const subDub = $('div.film-stats span.item div.tick-dub')
.toArray()
.map(value => $(value).text().toLowerCase());
if (subDub.length > 1) {
info.subOrDub = SubOrSub.BOTH
info.subOrDub = SubOrSub.BOTH;
} else if (subDub.length > 0) {
info.subOrDub = subDub[0] as SubOrSub
info.subOrDub = subDub[0] as SubOrSub;
} else {
info.subOrDub = SubOrSub.SUB
info.subOrDub = SubOrSub.SUB;
}

const episodesAjax = await axios.get(`${this.baseUrl}/ajax/v2/episode/list/${id.split('-').pop()}`, {
Expand All @@ -115,7 +117,11 @@ class Zoro extends AnimeParser {
info.totalEpisodes = $$('div.detail-infor-content > div > a').length;
info.episodes = [];
$$('div.detail-infor-content > div > a').each((i, el) => {
const episodeId = $$(el).attr('href')?.split('/')[2]?.replace('?ep=', '$episode$')?.concat(`$${info.subOrDub}`)!;
const episodeId = $$(el)
.attr('href')
?.split('/')[2]
?.replace('?ep=', '$episode$')
?.concat(`$${info.subOrDub}`)!;
const number = parseInt($$(el).attr('data-number')!);
const title = $$(el).attr('title');
const url = this.baseUrl + $$(el).attr('href');
Expand Down Expand Up @@ -175,9 +181,11 @@ class Zoro extends AnimeParser {
// Fallback to using sub if no info found in case of compatibility

// TODO: add both options later
let subOrDub:'sub' | 'dub' = episodeId.split('$')?.pop() === 'dub' ? 'dub' : 'sub';
let subOrDub: 'sub' | 'dub' = episodeId.split('$')?.pop() === 'dub' ? 'dub' : 'sub';

episodeId = `${this.baseUrl}/watch/${episodeId.replace('$episode$', '?ep=').replace(/\$auto|\$sub|\$dub/gi, '')}`;
episodeId = `${this.baseUrl}/watch/${episodeId
.replace('$episode$', '?ep=')
.replace(/\$auto|\$sub|\$dub/gi, '')}`;

try {
const { data } = await axios.get(
Expand Down Expand Up @@ -236,7 +244,7 @@ class Zoro extends AnimeParser {
.map((i: any, el: any) => ($(el).attr('data-server-id') == `${index}` ? $(el) : null))
.get()[0]
.attr('data-id')!;
}
};

/**
* @param page Page number
Expand Down
6 changes: 5 additions & 1 deletion src/providers/meta/anilist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import Gogoanime from '../../providers/anime/gogoanime';
import Enime from '../anime/enime';
import Zoro from '../anime/zoro';
import Mangasee123 from '../manga/mangasee123';
import Crunchyroll from '../anime/crunchyroll';

class Anilist extends AnimeParser {
override readonly name = 'Anilist';
Expand Down Expand Up @@ -643,7 +644,10 @@ class Anilist extends AnimeParser {
// Set the correct episode sub/dub request type
possibleAnime.episodes.forEach((_: any, index: number) => {
if (possibleAnime.subOrDub === SubOrSub.BOTH) {
possibleAnime.episodes[index].id = possibleAnime.episodes[index].id.replace(`$both`, dub ? '$dub' : '$sub');
possibleAnime.episodes[index].id = possibleAnime.episodes[index].id.replace(
`$both`,
dub ? '$dub' : '$sub'
);
}
});
}
Expand Down
30 changes: 15 additions & 15 deletions src/utils/extractors/rapidcloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ class RapidCloud extends VideoExtractor {

let res = null;

let { data: sId } = await axios({
method: 'GET',
url: `${this.consumetApi}/utils/rapid-cloud`,
validateStatus: status => true,
});

if (!sId) {
sId = await axios({
method: 'GET',
url: `${this.enimeApi}/tool/rapid-cloud/server-id`,
validateStatus: status => true,
});
}

res = await axios.get(`${this.host}/ajax/embed-6/getSources?id=${id}&sId=${sId}`, options);
// let { data: sId } = await axios({
// method: 'GET',
// url: `${this.consumetApi}/utils/rapid-cloud`,
// validateStatus: status => true,
// });

// if (!sId) {
// sId = await axios({
// method: 'GET',
// url: `${this.enimeApi}/tool/rapid-cloud/server-id`,
// validateStatus: status => true,
// });
// }

res = await axios.get(`${this.host}/ajax/embed-6/getSources?id=${id}`, options);

let {
data: { sources, tracks, intro, encrypted },
Expand Down

0 comments on commit 0b28835

Please sign in to comment.