Update(plugin): Agitoon url (#974)

* Agitoon:
 - url update
 - getting url from this.site to check for url changed

* Agitoon: getting current url from the constructor
This commit is contained in:
Justin COLLON
2024-06-06 17:56:56 +02:00
committed by GitHub
parent b112e44998
commit 00575cb805
+13 -3
View File
@@ -1,5 +1,4 @@
import { fetchFile, fetchApi } from '@libs/fetch'; import { fetchFile, fetchApi } from '@libs/fetch';
import { Filters } from '@libs/filterInputs';
import { Plugin } from '@typings/plugin'; import { Plugin } from '@typings/plugin';
import { load as parseHTML } from 'cheerio'; import { load as parseHTML } from 'cheerio';
import qs from 'qs'; import qs from 'qs';
@@ -8,8 +7,14 @@ class Agitoon implements Plugin.PluginBase {
id = 'agit.xyz'; id = 'agit.xyz';
name = 'Agitoon'; name = 'Agitoon';
icon = 'src/kr/agitoon/icon.png'; icon = 'src/kr/agitoon/icon.png';
site = 'https://agit655.xyz'; site = 'https://agit657.xyz';
version = '2.0.1'; version = '3.0.0';
constructor() {
fetchApi(this.site).then(res => {
if (res.ok) this.site = res.url.replace(/\/$/, '');
});
}
async popularNovels( async popularNovels(
pageNo: number, pageNo: number,
@@ -34,6 +39,11 @@ class Agitoon implements Plugin.PluginBase {
is_query_first: pageNo == 1, is_query_first: pageNo == 1,
}), }),
}); });
if (!res.ok) {
throw new Error(
`Failed to get popular novels: (${res.status}: ${res.statusText}) (try to open in webview)`,
);
}
const resJson = (await res.json()) as response; const resJson = (await res.json()) as response;
const novels: Plugin.NovelItem[] = []; const novels: Plugin.NovelItem[] = [];