From 00575cb80559dd195b33ac1d820a1224f3189903 Mon Sep 17 00:00:00 2001 From: Justin COLLON <48163201+error7404@users.noreply.github.com> Date: Thu, 6 Jun 2024 17:56:56 +0200 Subject: [PATCH] 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 --- plugins/korean/Agitoon.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/plugins/korean/Agitoon.ts b/plugins/korean/Agitoon.ts index 46c120d..21ef680 100644 --- a/plugins/korean/Agitoon.ts +++ b/plugins/korean/Agitoon.ts @@ -1,5 +1,4 @@ import { fetchFile, fetchApi } from '@libs/fetch'; -import { Filters } from '@libs/filterInputs'; import { Plugin } from '@typings/plugin'; import { load as parseHTML } from 'cheerio'; import qs from 'qs'; @@ -8,8 +7,14 @@ class Agitoon implements Plugin.PluginBase { id = 'agit.xyz'; name = 'Agitoon'; icon = 'src/kr/agitoon/icon.png'; - site = 'https://agit655.xyz'; - version = '2.0.1'; + site = 'https://agit657.xyz'; + version = '3.0.0'; + + constructor() { + fetchApi(this.site).then(res => { + if (res.ok) this.site = res.url.replace(/\/$/, ''); + }); + } async popularNovels( pageNo: number, @@ -34,6 +39,11 @@ class Agitoon implements Plugin.PluginBase { 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 novels: Plugin.NovelItem[] = [];