mirror of
https://github.com/anidl/multi-downloader-nx.git
synced 2026-04-21 16:31:55 +00:00
[AO] Fix downloading
This commit is contained in:
parent
39fec7c35c
commit
c74e6fcb18
3 changed files with 34 additions and 12 deletions
14
ao.ts
14
ao.ts
|
|
@ -73,6 +73,12 @@ export default class AnimeOnegai implements ServiceClass {
|
||||||
'Doblaje en Portugués',
|
'Doblaje en Portugués',
|
||||||
'Dublagem em português'
|
'Dublagem em português'
|
||||||
];
|
];
|
||||||
|
private defaultOptions: RequestInit = {
|
||||||
|
'headers': {
|
||||||
|
'origin': 'https://www.animeonegai.com',
|
||||||
|
'referer': 'https://www.animeonegai.com/',
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
constructor(private debug = false) {
|
constructor(private debug = false) {
|
||||||
this.cfg = yamlCfg.loadCfg();
|
this.cfg = yamlCfg.loadCfg();
|
||||||
|
|
@ -124,7 +130,7 @@ export default class AnimeOnegai implements ServiceClass {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async doSearch(data: SearchData): Promise<SearchResponse> {
|
public async doSearch(data: SearchData): Promise<SearchResponse> {
|
||||||
const searchReq = await this.req.getData(`https://api.animeonegai.com/v1/search/algolia/${encodeURIComponent(data.search)}?lang=${this.locale}`);
|
const searchReq = await this.req.getData(`https://api.animeonegai.com/v1/search/algolia/${encodeURIComponent(data.search)}?lang=${this.locale}`, this.defaultOptions);
|
||||||
if (!searchReq.ok || !searchReq.res) {
|
if (!searchReq.ok || !searchReq.res) {
|
||||||
console.error('Search FAILED!');
|
console.error('Search FAILED!');
|
||||||
return { isOk: false, reason: new Error('Search failed. No more information provided') };
|
return { isOk: false, reason: new Error('Search failed. No more information provided') };
|
||||||
|
|
@ -163,14 +169,14 @@ export default class AnimeOnegai implements ServiceClass {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getShow(id: number) {
|
public async getShow(id: number) {
|
||||||
const getSeriesData = await this.req.getData(`https://api.animeonegai.com/v1/asset/${id}?lang=${this.locale}`);
|
const getSeriesData = await this.req.getData(`https://api.animeonegai.com/v1/asset/${id}?lang=${this.locale}`, this.defaultOptions);
|
||||||
if (!getSeriesData.ok || !getSeriesData.res) {
|
if (!getSeriesData.ok || !getSeriesData.res) {
|
||||||
console.error('Failed to get Show Data');
|
console.error('Failed to get Show Data');
|
||||||
return { isOk: false };
|
return { isOk: false };
|
||||||
}
|
}
|
||||||
const seriesData = await getSeriesData.res.json() as AnimeOnegaiSeries;
|
const seriesData = await getSeriesData.res.json() as AnimeOnegaiSeries;
|
||||||
|
|
||||||
const getSeasonData = await this.req.getData(`https://api.animeonegai.com/v1/asset/content/${id}?lang=${this.locale}`);
|
const getSeasonData = await this.req.getData(`https://api.animeonegai.com/v1/asset/content/${id}?lang=${this.locale}`, this.defaultOptions);
|
||||||
if (!getSeasonData.ok || !getSeasonData.res) {
|
if (!getSeasonData.ok || !getSeasonData.res) {
|
||||||
console.error('Failed to get Show Data');
|
console.error('Failed to get Show Data');
|
||||||
return { isOk: false };
|
return { isOk: false };
|
||||||
|
|
@ -777,7 +783,7 @@ export default class AnimeOnegai implements ServiceClass {
|
||||||
sxData.path = path.join(this.cfg.dir.content, sxData.file);
|
sxData.path = path.join(this.cfg.dir.content, sxData.file);
|
||||||
sxData.language = subLang;
|
sxData.language = subLang;
|
||||||
if((options.dlsubs.includes('all') || options.dlsubs.includes(subLang.locale)) && sub.url.includes('.ass')) {
|
if((options.dlsubs.includes('all') || options.dlsubs.includes(subLang.locale)) && sub.url.includes('.ass')) {
|
||||||
const getSubtitle = await this.req.getData(sub.url);
|
const getSubtitle = await this.req.getData(sub.url, AuthHeaders);
|
||||||
if (getSubtitle.ok && getSubtitle.res) {
|
if (getSubtitle.ok && getSubtitle.res) {
|
||||||
console.info(`Subtitle Downloaded: ${sub.url}`);
|
console.info(`Subtitle Downloaded: ${sub.url}`);
|
||||||
const sBody = await getSubtitle.res.text();
|
const sBody = await getSubtitle.res.text();
|
||||||
|
|
|
||||||
|
|
@ -421,6 +421,12 @@ const extFn = {
|
||||||
if ((options.url.hostname as string).match('hidive')) {
|
if ((options.url.hostname as string).match('hidive')) {
|
||||||
options.headers['referrer'] = 'https://www.hidive.com/';
|
options.headers['referrer'] = 'https://www.hidive.com/';
|
||||||
options.headers['origin'] = 'https://www.hidive.com';
|
options.headers['origin'] = 'https://www.hidive.com';
|
||||||
|
} else if ((options.url.hostname as string).includes('animecdn')) {
|
||||||
|
options.headers = {
|
||||||
|
origin: 'https://www.animeonegai.com',
|
||||||
|
referer: 'https://www.animeonegai.com/',
|
||||||
|
range: options.headers['range']
|
||||||
|
};
|
||||||
}
|
}
|
||||||
// console.log(' - Req:', options.url.pathname);
|
// console.log(' - Req:', options.url.pathname);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,10 +63,15 @@ export async function parse(manifest: string, language?: LanguageItem, url?: str
|
||||||
|
|
||||||
|
|
||||||
if (playlist.sidx && playlist.segments.length == 0) {
|
if (playlist.sidx && playlist.segments.length == 0) {
|
||||||
const item = await fetch(playlist.sidx.uri, {
|
const options: RequestInit = {
|
||||||
'method': 'head'
|
method: 'head'
|
||||||
});
|
};
|
||||||
if (!item.ok) console.warn(`Unable to fetch byteLength for audio stream ${Math.round(playlist.attributes.BANDWIDTH/1024)}KiB/s`);
|
if (playlist.sidx.uri.includes('animecdn')) options.headers = {
|
||||||
|
'origin': 'https://www.animeonegai.com',
|
||||||
|
'referer': 'https://www.animeonegai.com/',
|
||||||
|
};
|
||||||
|
const item = await fetch(playlist.sidx.uri, options);
|
||||||
|
if (!item.ok) console.warn(`${item.status}: ${item.statusText}, Unable to fetch byteLength for audio stream ${Math.round(playlist.attributes.BANDWIDTH/1024)}KiB/s`);
|
||||||
const byteLength = parseInt(item.headers.get('content-length') as string);
|
const byteLength = parseInt(item.headers.get('content-length') as string);
|
||||||
let currentByte = playlist.sidx.map.byterange.length;
|
let currentByte = playlist.sidx.map.byterange.length;
|
||||||
while (currentByte <= byteLength) {
|
while (currentByte <= byteLength) {
|
||||||
|
|
@ -133,10 +138,15 @@ export async function parse(manifest: string, language?: LanguageItem, url?: str
|
||||||
ret[host] = { audio: [], video: [] };
|
ret[host] = { audio: [], video: [] };
|
||||||
|
|
||||||
if (playlist.sidx && playlist.segments.length == 0) {
|
if (playlist.sidx && playlist.segments.length == 0) {
|
||||||
const item = await fetch(playlist.sidx.uri, {
|
const options: RequestInit = {
|
||||||
'method': 'head'
|
method: 'head'
|
||||||
});
|
};
|
||||||
if (!item.ok) console.warn(`Unable to fetch byteLength for video stream ${playlist.attributes.RESOLUTION?.height}x${playlist.attributes.RESOLUTION?.width}@${Math.round(playlist.attributes.BANDWIDTH/1024)}KiB/s`);
|
if (playlist.sidx.uri.includes('animecdn')) options.headers = {
|
||||||
|
'origin': 'https://www.animeonegai.com',
|
||||||
|
'referer': 'https://www.animeonegai.com/',
|
||||||
|
};
|
||||||
|
const item = await fetch(playlist.sidx.uri, options);
|
||||||
|
if (!item.ok) console.warn(`${item.status}: ${item.statusText}, Unable to fetch byteLength for video stream ${playlist.attributes.RESOLUTION?.height}x${playlist.attributes.RESOLUTION?.width}@${Math.round(playlist.attributes.BANDWIDTH/1024)}KiB/s`);
|
||||||
const byteLength = parseInt(item.headers.get('content-length') as string);
|
const byteLength = parseInt(item.headers.get('content-length') as string);
|
||||||
let currentByte = playlist.sidx.map.byterange.length;
|
let currentByte = playlist.sidx.map.byterange.length;
|
||||||
while (currentByte <= byteLength) {
|
while (currentByte <= byteLength) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue