forked from manga-download/hakuneko
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes manga-download#5058. 2 Connectors because website provide both mangas and animes.
- Loading branch information
Showing
2 changed files
with
210 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import Connector from '../engine/Connector.mjs'; | ||
import Manga from '../engine/Manga.mjs'; | ||
export default class Allanimesite extends Connector { | ||
constructor() { | ||
super(); | ||
super.id = 'allanimesite'; | ||
super.label = 'AllAnime.site (Mangas)'; | ||
this.tags = ['manga', 'webtoon', 'multilingual']; | ||
this.url = 'https://allanime.site'; | ||
this.path = '/allanimeapi'; | ||
this.varQueryMangas = '?variables={"search":{"isManga":true,"allowAdult":true,"allowUnknown":true},"limit":100,"page":%PAGE%,"countryOrigin":"ALL"}&extensions={"persistedQuery":{"version":1,"sha256Hash":"0cf12b2c7e4c571ef8aaae655276b646f485e5022900dd9d721d3bf902d7ef76"}}'; | ||
this.varQueryChapters ='?variables={"_id":"%MANGAID%"}&extensions={"persistedQuery":{"version":1,"sha256Hash":"fbf62e4a2030ecf8bfb9540e0a8a14a300a531cafd82ebb4331e5a3a4a3a4e4e"}}' | ||
this.queryMangaTitleFromURI = 'ol.breadcrumb li.breadcrumb-item span'; | ||
this.config = { | ||
throttle: { | ||
label: 'Manga list Throttle [ms]', | ||
description: 'Enter the timespan in [ms] to delay consecutive requests to the website api for manga list fetching', | ||
input: 'numeric', | ||
min: 100, | ||
max: 10000, | ||
value: 1000 | ||
} | ||
}; | ||
} | ||
canHandleURI(uri) { | ||
return /(www\.)?allanime\.site\/manga/.test(uri); | ||
} | ||
async _getMangaFromURI(uri) { | ||
const request = new Request(new URL(uri), this.requestOptions); | ||
const data = await this.fetchDOM(request, this.queryMangaTitleFromURI); | ||
const id = uri.pathname.replace(/$\//, ''); | ||
const title = data[0].textContent.trim(); | ||
return new Manga(this, id, title); | ||
} | ||
async _getMangas() { | ||
const mangaList = []; | ||
for(let page = 1, run = true; run; page++) { | ||
const mangas = await this._getMangasFromPage(page); | ||
await this.wait(this.config.throttle.value); | ||
mangas.length ? mangaList.push(...mangas) : run = false; | ||
} | ||
return mangaList; | ||
} | ||
async _getMangasFromPage(page) { | ||
const uri = new URL(this.path + this.varQueryMangas.replace('%PAGE%', page), this.url); | ||
const request = new Request(uri, this.requestOptions); | ||
const data = await this.fetchJSON(request); | ||
if (data.data == null) { | ||
return {}; | ||
} | ||
return data.data.mangas.edges.map(element => { | ||
return { | ||
id: '/manga/'+element._id, | ||
title: element.englishName ? element.englishName : element.name, | ||
}; | ||
}); | ||
} | ||
async _getChapters(manga) { | ||
let mangaid = manga.id.replace('/manga/', ''); | ||
let uri = new URL(this.path+ this.varQueryChapters.replace('%MANGAID%', mangaid) , this.url); | ||
let request = new Request(uri, this.requestOptions); | ||
const data = await this.fetchJSON(request); | ||
let chapterlist = []; | ||
let subchapters = data.data.manga.availableChaptersDetail.sub; | ||
subchapters.forEach(chapter => { | ||
chapterlist.push({ | ||
id : '/read/'+mangaid+'/chapter-'+chapter+'-sub', | ||
title : 'Chapter '+ chapter+' [SUB]', | ||
language : 'SUB', | ||
}); | ||
}); | ||
let rawchapters = data.data.manga.availableChaptersDetail.raw; | ||
rawchapters.forEach(chapter => { | ||
chapterlist.push({ | ||
id : '/read/'+mangaid+'/chapter-'+chapter+'-raw', | ||
title : 'Chapter '+ chapter +' [RAW]', | ||
language : 'RAW', | ||
}); | ||
}); | ||
return chapterlist; | ||
} | ||
async _getPages(chapter) { | ||
const request = new Request(new URL(chapter.id, this.url), this.requestOptions); | ||
let script = ` | ||
new Promise(resolve => { | ||
let pages = __NUXT__; | ||
resolve(pages); | ||
}); | ||
`; | ||
let data = await Engine.Request.fetchUI(request, script); | ||
let sourcename = data.fetch[0].selectedSourceName; | ||
let sourcesArray = data.fetch[0].chapters; | ||
let goodSource = null; | ||
sourcesArray.every(source => | ||
{ | ||
if (source.sourceName == sourcename) { | ||
goodSource = source; | ||
return false; | ||
} | ||
return true; | ||
}); | ||
let pageslist = goodSource.pictureUrls.map( element => { | ||
return new URL(element.url, goodSource.pictureUrlHead).href; | ||
}); | ||
return pageslist; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import Allanimesite from './Allanimesite.mjs'; | ||
export default class Allanimesite2 extends Allanimesite { | ||
constructor() { | ||
super(); | ||
super.id = 'allanimesit2'; | ||
super.label = 'AllAnime.site (Animes)'; | ||
this.tags = ['anime', 'multilingual']; | ||
this.url = 'https://allanime.site'; | ||
this.path = '/allanimeapi'; | ||
this.varQueryMangas = '?variables={"search":{"allowAdult":true,"allowUnknown":true},"limit":100,"page":%PAGE%,"countryOrigin":"ALL"}&extensions={"persistedQuery":{"version":1,"sha256Hash":"9c7a8bc1e095a34f2972699e8105f7aaf9082c6e1ccd56eab99c2f1a971152c6"}}'; | ||
} | ||
get icon() { | ||
return '/img/connectors/allanimesite'; | ||
} | ||
canHandleURI(uri) { | ||
return /(www\.)?allanime\.site\/anime/.test(uri); | ||
} | ||
async _getMangasFromPage(page) { | ||
const uri = new URL(this.path + this.varQueryMangas.replace('%PAGE%', page), this.url); | ||
const request = new Request(uri, this.requestOptions); | ||
const data = await this.fetchJSON(request); | ||
if (data.data == null) { | ||
return {}; | ||
} | ||
return data.data.shows.edges.map(element => { | ||
return { | ||
id: '/anime/'+element._id, | ||
title: element.englishName ? element.englishName : element.name, | ||
}; | ||
}); | ||
} | ||
async _getChapters(manga) { | ||
const request = new Request(new URL(manga.id, this.url), this.requestOptions); | ||
let script = ` | ||
new Promise(resolve => { | ||
let pages = __NUXT__; | ||
resolve(pages); | ||
}); | ||
`; | ||
let data = await Engine.Request.fetchUI(request, script); | ||
let chapterlist = []; | ||
const mangaid = data.fetch[0].show._id; | ||
let subchapters = data.fetch[0].show.availableEpisodesDetail.sub; | ||
subchapters.forEach(chapter => { | ||
chapterlist.push({ | ||
id : '/watch/'+mangaid+'/episode-'+chapter+'-sub', | ||
title : 'Episode '+ chapter+' [SUB]', | ||
language : 'SUB', | ||
}); | ||
}); | ||
let rawchapters = data.fetch[0].show.availableEpisodesDetail.raw; | ||
rawchapters.forEach(chapter => { | ||
chapterlist.push({ | ||
id : '/watch/'+mangaid+'/episode-'+chapter+'-raw', | ||
title : 'Episode '+ chapter+' [RAW]', | ||
language : 'RAW', | ||
}); | ||
}); | ||
let dubchapters = data.fetch[0].show.availableEpisodesDetail.dub; | ||
dubchapters.forEach(chapter => { | ||
chapterlist.push({ | ||
id : '/watch/'+mangaid+'/episode-'+chapter+'-dub', | ||
title : 'Episode '+ chapter+' [DUB]', | ||
language : 'DUB', | ||
}); | ||
}); | ||
return chapterlist; | ||
} | ||
async _getPages(chapter) { | ||
let request = new Request(new URL(chapter.id, this.url), this.requestOptions); | ||
let script = ` | ||
new Promise(resolve => { | ||
let pages = __NUXT__; | ||
resolve(pages); | ||
}); | ||
`; | ||
let data = await Engine.Request.fetchUI(request, script); | ||
let sourcesArray = data.fetch[0].episodeSelections; | ||
let goodSource = null; | ||
sourcesArray.every(source => | ||
{ | ||
if (source.sourceName.indexOf('Default') > -1) { | ||
goodSource = source; | ||
return false; | ||
} | ||
return true; | ||
}); | ||
if (goodSource == null) { | ||
throw error('No Default source found !'); | ||
} | ||
let uri = new URL(goodSource.sourceUrl.replace('clock', 'clock.json'), 'https://blog.allanime.pro'); | ||
request = new Request(uri, this.requestOptions); | ||
data = await this.fetchJSON(request); | ||
let stream = []; | ||
let link = data.links[0]; | ||
if (link.hls) { | ||
stream = { mirrors: [ link.link ], subtitles: [], referer : 'https://blog.allanime.pro'}; | ||
} else { | ||
stream = {video: [ link.link ], subtitles: []}; | ||
} | ||
return stream; | ||
} | ||
} |