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

AnimeParadise : fix getting pages #7291

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 23 additions & 33 deletions src/web/mjs/connectors/AnimeParadise.mjs
Original file line number Diff line number Diff line change
@@ -1,41 +1,31 @@
import Connector from '../engine/Connector.mjs';
import Manga from '../engine/Manga.mjs';

export default class AnimeParadise extends Connector {

constructor() {
super();
super.id = 'animeparadise';
super.label = 'Anime Paradise';
this.tags = [ 'anime', 'subbed', 'multi-lingual' ];
this.url = 'https://www.animeparadise.moe';
this.api = 'https://api.animeparadise.moe';
this.config = {
resolution: {
label: 'Preferred Resolution',
description: 'Try to download video in the selected resolution.\nIf the resolution is not supported, depending on the mirror the download may fail, or a fallback resolution may be used!',
input: 'select',
options: [
{ value: '', name: 'Mirror\'s Default' },
{ value: '360p', name: '360p' },
{ value: '480p', name: '480p' },
{ value: '720p', name: '720p' },
{ value: '1080p', name: '1080p' }
],
value: ''
}
};
}

async _getMangaFromURI(uri) {
let request = new Request(uri, this.requestOptions);
let data = await this._getNextData(request);
let title = data.props.pageProps.data.title.trim();
let id = data.props.pageProps.data.link;
return new Manga(this, id, title);
}

async _getMangas() {
//api and search are limited to 35 results no matter what i do, and they are not the same. Better not using them :/
let msg = 'This website does not provide a manga list, please copy and paste the URL containing the chapters directly from your browser into HakuNeko.';
throw new Error(msg);
}

async _getChapters(manga) {
//first get anime id
let uri = new URL('/anime/'+manga.id, this.url);
Expand All @@ -56,32 +46,32 @@ export default class AnimeParadise extends Connector {
};
}).reverse();
}

async _getPages(chapter) {
let uri = new URL(chapter.id, this.url);
let request = new Request(uri, this.requestOptions);
let data = await this._getNextData(request);
const subtitles = data.props.pageProps.subtitles.map(sub =>{
let {props : {pageProps: {episode }}} = await this._getNextData(request);

const subtitles = episode.subData.map(sub =>{
let src = sub.src;
try {
src = new URL(src).href;
} catch (e) {
//compose url with website api
src = new URL(`/stream/file/${src}`, this.api).href;
}
return {
url : sub.src,
locale : sub.srclang
url : src,
locale : sub.label
};
});
const epnumber = data.props.pageProps.episode.number;
const drive = data.props.pageProps.animeData.drive;
const animename = data.props.pageProps.animeData.title;
//buid api request to get links
uri = new URL('/storage/'+animename+'/'+epnumber+'?&folderId='+ drive, this.api);
request = new Request(uri, this.requestOptions);
request.headers.set('x-origin', this.url);
request.headers.set('x-referer', this.url);
data = await this.fetchJSON(request);
let streams = data.directUrl;
let resolution = parseInt(this.config.resolution.value || 0);
let stream = streams.find(stream => stream.resolution >= resolution) || streams.shift();

return {
video: new URL(stream.src, this.api).href,
subtitles: subtitles
hash: 'id,language,resolution',
mirrors: [ episode.streamLink ],
subtitles
};

}
async _getNextData(request) {
const [data] = await this.fetchDOM(request, '#__NEXT_DATA__');
Expand Down
Loading