Feat: ImageRequestInit (#979)
* add ImageRequestInit & fix Hako * remove multisrc fetchFile * remove plugins fetchFile * update docs and template file
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { Parser } from 'htmlparser2';
|
||||
import { fetchFile } from '@libs/fetch';
|
||||
import { HTMLParser2Util, Plugin } from '@typings/plugin';
|
||||
import { NovelStatus } from '@libs/novelStatus';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
@@ -395,6 +394,8 @@ class HakoPlugin implements Plugin.PluginBase {
|
||||
novel.status = NovelStatus.Unknown;
|
||||
}
|
||||
novel.genres = novel.genres?.replace(/,*\s*$/, '');
|
||||
novel.name = novel.name.trim();
|
||||
novel.summary = novel.summary?.trim();
|
||||
return novel;
|
||||
});
|
||||
}
|
||||
@@ -416,12 +417,11 @@ class HakoPlugin implements Plugin.PluginBase {
|
||||
this.site + '/tim-kiem?keywords=' + searchTerm + '&page=' + pageNo;
|
||||
return this.parseNovels(url);
|
||||
}
|
||||
fetchImage(url: string): Promise<string | undefined> {
|
||||
const headers = {
|
||||
imageRequestInit: Plugin.ImageRequestInit = {
|
||||
headers: {
|
||||
Referer: 'https://ln.hako.vn',
|
||||
};
|
||||
return fetchFile(url, { headers: headers });
|
||||
}
|
||||
},
|
||||
};
|
||||
filters = {
|
||||
alphabet: {
|
||||
type: FilterTypes.Picker,
|
||||
|
||||
@@ -247,9 +247,7 @@ class TruyenConect implements Plugin.PagePlugin {
|
||||
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return fetchFile(url);
|
||||
}
|
||||
|
||||
filters = {
|
||||
category: {
|
||||
label: 'Lọc theo',
|
||||
|
||||
@@ -170,9 +170,6 @@ class LightNovelVN implements Plugin.PagePlugin {
|
||||
}) || [];
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return fetchFile(url);
|
||||
}
|
||||
}
|
||||
|
||||
export default new LightNovelVN();
|
||||
|
||||
@@ -119,8 +119,5 @@ class Nettruyen implements Plugin.PagePlugin {
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return fetchFile(url);
|
||||
}
|
||||
}
|
||||
export default new Nettruyen();
|
||||
|
||||
@@ -151,9 +151,6 @@ class TruyenFull implements Plugin.PagePlugin {
|
||||
const loadedCheerio = parseHTML(body);
|
||||
return this.parseNovels(loadedCheerio);
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return fetchFile(url);
|
||||
}
|
||||
}
|
||||
|
||||
export default new TruyenFull();
|
||||
|
||||
@@ -142,9 +142,6 @@ class TruyenFull implements Plugin.PagePlugin {
|
||||
const loadedCheerio = parseHTML(body);
|
||||
return this.parseNovels(loadedCheerio);
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return fetchFile(url);
|
||||
}
|
||||
}
|
||||
|
||||
export default new TruyenFull();
|
||||
|
||||
Reference in New Issue
Block a user