Feat: ImageRequestInit (#979)

* add ImageRequestInit & fix Hako

* remove multisrc fetchFile

* remove plugins fetchFile

* update docs and template file
This commit is contained in:
nyagami
2024-06-08 20:09:33 +07:00
committed by GitHub
parent 6062f51460
commit 60d95fb8d2
85 changed files with 441 additions and 692 deletions
+6 -6
View File
@@ -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,
+1 -3
View File
@@ -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',
-3
View File
@@ -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();
-3
View File
@@ -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();
-3
View File
@@ -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();
-3
View File
@@ -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();