refactor: Remove ignore generated multisrc .ts files when committing (#678)
* update clear multisrc script * ignore generated multisrc .ts files * Squashed commit of the following: commitb3ef1a83a9Author: Rajarshee Chatterjee <rajarshee.adm@gmail.com> Date: Sun Jan 7 16:56:12 2024 +0530 plugins: update json files for new plugins (#679) commitf36e93d0a6Author: Rider21 <58046032+Rider21@users.noreply.github.com> Date: Sun Jan 7 14:25:02 2024 +0300 fix: Update Plugins (#677) * typo * update * fix * fix * update * ifreedom * fix * fix ranobelib * ... commit8a267561cbAuthor: Rajarshee Chatterjee <rajarshee.adm@gmail.com> Date: Sun Jan 7 16:54:09 2024 +0530 plugins: update json files for new plugins (#673) * clear generated multisrc files * generate .js files
This commit is contained in:
@@ -0,0 +1,708 @@
|
||||
{
|
||||
"العربية": [
|
||||
{
|
||||
"id": "ar-mtl",
|
||||
"name": "ArMTL[madara]",
|
||||
"site": "https://ar-mtl.club/",
|
||||
"lang": "العربية",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/arabic/ArMTL[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/armtl.png"
|
||||
},
|
||||
{
|
||||
"id": "arnovel",
|
||||
"name": "ArNovel[madara]",
|
||||
"site": "https://arnovel.me/",
|
||||
"lang": "العربية",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/arabic/ArNovel[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/arnovel.png"
|
||||
},
|
||||
{
|
||||
"id": "hizomanga",
|
||||
"name": "HizoManga[madara]",
|
||||
"site": "https://hizomanga.com/",
|
||||
"lang": "العربية",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/arabic/HizoManga[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/hizomanga.png"
|
||||
},
|
||||
{
|
||||
"id": "kol-novel",
|
||||
"name": "Kol Novel[wpmangastream]",
|
||||
"site": "https://kolnovel.com/",
|
||||
"lang": "العربية",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/arabic/KolNovel[wpmangastream].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/wpmangastream/icons/kol-novel.png"
|
||||
},
|
||||
{
|
||||
"id": "kolnovel",
|
||||
"name": "KolNovel",
|
||||
"site": "https://kolnovel.lol/",
|
||||
"lang": "العربية",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/arabic/kolnovel.js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/wpmangastream/icons/kolnovel.png"
|
||||
},
|
||||
{
|
||||
"id": "novel4up",
|
||||
"name": "Novel4Up[madara]",
|
||||
"site": "https://novel4up.com/",
|
||||
"lang": "العربية",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/arabic/Novel4Up[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/novel4up.png"
|
||||
},
|
||||
{
|
||||
"id": "riwyat",
|
||||
"name": "Riwyat[madara]",
|
||||
"site": "https://riwyat.com/",
|
||||
"lang": "العربية",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/arabic/Riwyat[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/riwyat.png"
|
||||
},
|
||||
{
|
||||
"id": "teamxnovel",
|
||||
"name": "TeamXNovel[madara]",
|
||||
"site": "https://teamxnovel.com/",
|
||||
"lang": "العربية",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/arabic/TeamXNovel[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/teamxnovel.png"
|
||||
}
|
||||
],
|
||||
"中文, 汉语, 漢語": [
|
||||
{
|
||||
"id": "linovelib",
|
||||
"name": "Linovelib",
|
||||
"site": "https://w.linovelib.com",
|
||||
"lang": "中文, 汉语, 漢語",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/chinese/linovelib.js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/src/cn/linovelib/icon.png"
|
||||
}
|
||||
],
|
||||
"English": [
|
||||
{
|
||||
"id": "1stkissnovel",
|
||||
"name": "FirstKissNovel[madara]",
|
||||
"site": "https://1stkissnovel.org/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/FirstKissNovel[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/firstkissnovel.png"
|
||||
},
|
||||
{
|
||||
"id": "BLN.com",
|
||||
"name": "BestLightNovel",
|
||||
"site": "https://bestlightnovel.com/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/bestlightnovel.js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/src/en/bestlightnovel/icon.png"
|
||||
},
|
||||
{
|
||||
"id": "boxnovel",
|
||||
"name": "BoxNovel[madara]",
|
||||
"site": "https://boxnovel.com/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/BoxNovel[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/boxnovel.png"
|
||||
},
|
||||
{
|
||||
"id": "clicknovel",
|
||||
"name": "ClickNovel[madara]",
|
||||
"site": "https://clicknovel.net/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/ClickNovel[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/clicknovel.png"
|
||||
},
|
||||
{
|
||||
"id": "cratenovel",
|
||||
"name": "CrateNovel[madara]",
|
||||
"site": "https://cratenovel.com/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/CrateNovel[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/cratenovel.png"
|
||||
},
|
||||
{
|
||||
"id": "daonovel",
|
||||
"name": "DaoNovel[madara]",
|
||||
"site": "https://daonovel.com/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/DaoNovel[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/daonovel.png"
|
||||
},
|
||||
{
|
||||
"id": "fanTLS",
|
||||
"name": "Fans Translations[madara]",
|
||||
"site": "https://fanstranslations.com/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/FansTranslations[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/fanstranslations.png"
|
||||
},
|
||||
{
|
||||
"id": "freenovel.me",
|
||||
"name": "FreeNovelMe[madara]",
|
||||
"site": "https://freenovel.me/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/FreeNovelMe[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/freenovelme.png"
|
||||
},
|
||||
{
|
||||
"id": "ftest",
|
||||
"name": "Filter Test",
|
||||
"site": "https://noblemtl.com/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/filterTests.js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/src/en/noblemtl/icon.png"
|
||||
},
|
||||
{
|
||||
"id": "FWN.com",
|
||||
"name": "Web NOVEL",
|
||||
"site": "https://freewebnovel.com",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/freewebnovel.js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/src/en/freewebnovel/icon.png"
|
||||
},
|
||||
{
|
||||
"id": "guavaread",
|
||||
"name": "Guavaread[madara]",
|
||||
"site": "https://guavaread.com/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/Guavaread[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/guavaread.png"
|
||||
},
|
||||
{
|
||||
"id": "lnheaven",
|
||||
"name": "LightNovelHeaven[madara]",
|
||||
"site": "https://lightnovelheaven.com/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/LightNovelHeaven[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/lightnovelheaven.png"
|
||||
},
|
||||
{
|
||||
"id": "Ltnovel.com",
|
||||
"name": "Ltnovel[readwn]",
|
||||
"site": "https://www.ltnovel.com",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/Ltnovel[readwn].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/readwn/icons/ltnovel.png"
|
||||
},
|
||||
{
|
||||
"id": "lunarletters",
|
||||
"name": "LunarLetters[madara]",
|
||||
"site": "https://www.lunarletters.com/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/LunarLetters[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/lunarletters.png"
|
||||
},
|
||||
{
|
||||
"id": "mostnovel",
|
||||
"name": "MostNovel[madara]",
|
||||
"site": "https://mostnovel.com/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/MostNovel[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/mostnovel.png"
|
||||
},
|
||||
{
|
||||
"id": "mtl-novel",
|
||||
"name": "MTL-Novel[madara]",
|
||||
"site": "https://mtl-novel.com/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/MTLNovel[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/mtl-novel.png"
|
||||
},
|
||||
{
|
||||
"id": "mtlnovel.club",
|
||||
"name": "MTLNovel.Club[madara]",
|
||||
"site": "https://mtlnovel.club/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/MTLNovelClub[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/mtlnovel.club.png"
|
||||
},
|
||||
{
|
||||
"id": "mysticalmerries",
|
||||
"name": "MysticalSeries[madara]",
|
||||
"site": "https://mysticalmerries.com/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/MysticalSeries[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/mysticalseries.png"
|
||||
},
|
||||
{
|
||||
"id": "neosekaiTLS",
|
||||
"name": "NeoSekai Translations[madara]",
|
||||
"site": "https://www.neosekaitranslations.com/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/NeoSekaiTranslations[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/neosekaitranslations.png"
|
||||
},
|
||||
{
|
||||
"id": "noblemtl",
|
||||
"name": "NobleMTL",
|
||||
"site": "https://noblemtl.com/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/nobleMTL.js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/src/en/noblemtl/icon.png"
|
||||
},
|
||||
{
|
||||
"id": "nocturneTLS",
|
||||
"name": "Nocturne Translations[madara]",
|
||||
"site": "https://nocturnetls.net/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/NocturneTranslations[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/nocturnetranslations.png"
|
||||
},
|
||||
{
|
||||
"id": "noobchanTL",
|
||||
"name": "Noobchan Translation[madara]",
|
||||
"site": "https://noobchan.xyz/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/NoobchanTranslation[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/noobchantranslation.png"
|
||||
},
|
||||
{
|
||||
"id": "novelmultiverse",
|
||||
"name": "NovelMultiverse[madara]",
|
||||
"site": "https://www.novelmultiverse.com/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/NovelMultiverse[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/novelmultiverse.png"
|
||||
},
|
||||
{
|
||||
"id": "novelr18",
|
||||
"name": "NovelR18[madara]",
|
||||
"site": "https://novelr18.com/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/NovelR18[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/novelr18.png"
|
||||
},
|
||||
{
|
||||
"id": "novelroom",
|
||||
"name": "Novelroom.net[madara]",
|
||||
"site": "https://novelroom.net/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/Novelroomnet[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/novelroom.net.png"
|
||||
},
|
||||
{
|
||||
"id": "novelstic",
|
||||
"name": "Novelstic[madara]",
|
||||
"site": "https://novelstic.com/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/Novelstic[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/novelstic.png"
|
||||
},
|
||||
{
|
||||
"id": "novelTL",
|
||||
"name": "NovelTranslate[madara]",
|
||||
"site": "https://noveltranslate.com/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/NovelTranslate[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/noveltranslate.png"
|
||||
},
|
||||
{
|
||||
"id": "onlymtl",
|
||||
"name": "OnlyMTL[madara]",
|
||||
"site": "https://www.onlymtl.com/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/OnlyMTL[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/onlymtl.png"
|
||||
},
|
||||
{
|
||||
"id": "pandamtl",
|
||||
"name": "PandaMTL",
|
||||
"site": "https://pandamtl.com/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/pandaMTL.js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/src/en/wordpress/icon.png"
|
||||
},
|
||||
{
|
||||
"id": "readwebnovels",
|
||||
"name": "ReadWebNovels[madara]",
|
||||
"site": "https://readwebnovels.net/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/ReadWebNovels[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/readwebnovels.png"
|
||||
},
|
||||
{
|
||||
"id": "sleeptTLS",
|
||||
"name": "SleepyTranslations[madara]",
|
||||
"site": "https://sleepytranslations.com/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/SleepyTranslations[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/sleepytranslations.png"
|
||||
},
|
||||
{
|
||||
"id": "sonicmtl",
|
||||
"name": "SonicMTL[madara]",
|
||||
"site": "https://www.sonicmtl.com/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/SonicMTL[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/sonicmtl.png"
|
||||
},
|
||||
{
|
||||
"id": "sugarbbscan",
|
||||
"name": "Sugar Babies[madara]",
|
||||
"site": "https://sugarbbscan.com/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/SugarBabies[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/sugarbabies.png"
|
||||
},
|
||||
{
|
||||
"id": "sweetEscapeTL",
|
||||
"name": "Sweet Escape Translations[madara]",
|
||||
"site": "https://sweetescapetranslations.com/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/SweetEscapeTranslations[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/sweetescapetranslations.png"
|
||||
},
|
||||
{
|
||||
"id": "webnovelover",
|
||||
"name": "WebNovelLover[madara]",
|
||||
"site": "https://www.webnovelover.com/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/WebNovelLover[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/webnovellover.png"
|
||||
},
|
||||
{
|
||||
"id": "wuxiacity",
|
||||
"name": "Wuxiacity[readwn]",
|
||||
"site": "https://www.wuxiacity.com",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/Wuxiacity[readwn].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/readwn/icons/wuxiacity.png"
|
||||
},
|
||||
{
|
||||
"id": "wuxiap",
|
||||
"name": "Wuxiap[readwn]",
|
||||
"site": "https://www.wuxiap.com",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/Wuxiap[readwn].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/readwn/icons/wuxiap.png"
|
||||
},
|
||||
{
|
||||
"id": "wuxiaworld.site",
|
||||
"name": "WuxiaWorld.Site[madara]",
|
||||
"site": "https://wuxiaworld.site/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/WuxiaWorldSite[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/wuxiaworld.site.png"
|
||||
},
|
||||
{
|
||||
"id": "zetroTL",
|
||||
"name": "Zetro Translation[madara]",
|
||||
"site": "https://zetrotranslation.com/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/ZetroTranslation[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/zetrotranslation.png"
|
||||
},
|
||||
{
|
||||
"id": "zinnovel",
|
||||
"name": "ZinnNovel[madara]",
|
||||
"site": "https://zinnovel.com/",
|
||||
"lang": "English",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/english/ZinnNovel[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/zinnnovel.png"
|
||||
}
|
||||
],
|
||||
"français, française": [
|
||||
{
|
||||
"id": "chireads.com",
|
||||
"name": "Chireads",
|
||||
"site": "https://chireads.com",
|
||||
"lang": "français, française",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/french/chireads.js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/src/fr/chireads/icon.png"
|
||||
},
|
||||
{
|
||||
"id": "lightnovelfr",
|
||||
"name": "Ligh Novel FR[wpmangastream]",
|
||||
"site": "https://lightnovelfr.com/",
|
||||
"lang": "français, française",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/french/LighNovelFR[wpmangastream].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/wpmangastream/icons/lightnovelfr.png"
|
||||
},
|
||||
{
|
||||
"id": "NDG.com",
|
||||
"name": "NovelDeGlace",
|
||||
"site": "https://noveldeglace.com/",
|
||||
"lang": "français, française",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/french/noveldeglace.js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/src/fr/noveldeglace/icon.png"
|
||||
}
|
||||
],
|
||||
"Bahasa Indonesia": [
|
||||
{
|
||||
"id": "meionovel",
|
||||
"name": "MeioNovel[madara]",
|
||||
"site": "https://meionovel.id/",
|
||||
"lang": "Bahasa Indonesia",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/indonesian/MeioNovel[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/meionovel.png"
|
||||
},
|
||||
{
|
||||
"id": "morenovel",
|
||||
"name": "MoreNovel[madara]",
|
||||
"site": "https://morenovel.net/",
|
||||
"lang": "Bahasa Indonesia",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/indonesian/MoreNovel[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/morenovel.png"
|
||||
},
|
||||
{
|
||||
"id": "wbnovel",
|
||||
"name": "WBNovel[madara]",
|
||||
"site": "https://wbnovel.com/",
|
||||
"lang": "Bahasa Indonesia",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/indonesian/WBNovel[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/wbnovel.png"
|
||||
}
|
||||
],
|
||||
"Português": [
|
||||
{
|
||||
"id": "lightnovelbrasil",
|
||||
"name": "Light Novel Brasil",
|
||||
"site": "https://lightnovelbrasil.com/",
|
||||
"lang": "Português",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/portuguese/lightnovelbrasil.js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/wpmangastream/icons/lightnovelbrasil.png"
|
||||
}
|
||||
],
|
||||
"русский язык": [
|
||||
{
|
||||
"id": "AT",
|
||||
"name": "Автор Тудей",
|
||||
"site": "https://author.today",
|
||||
"lang": "русский язык",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/russian/authortoday.js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/src/ru/authortoday/icon.png"
|
||||
},
|
||||
{
|
||||
"id": "bookhamster",
|
||||
"name": "Bookhamster[ifreedom]",
|
||||
"site": "https://bookhamster.ru",
|
||||
"lang": "русский язык",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/russian/Bookhamster[ifreedom].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/ifreedom/icons/bookhamster.png"
|
||||
},
|
||||
{
|
||||
"id": "bookriver",
|
||||
"name": "Bookriver",
|
||||
"site": "https://bookriver.ru",
|
||||
"lang": "русский язык",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/russian/bookriver.js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/src/ru/bookriver/icon.png"
|
||||
},
|
||||
{
|
||||
"id": "erolate",
|
||||
"name": "Erolate[rulate]",
|
||||
"site": "https://erolate.com",
|
||||
"lang": "русский язык",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/russian/Erolate[rulate].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/rulate/icons/erolate.png"
|
||||
},
|
||||
{
|
||||
"id": "ficbook",
|
||||
"name": "ficbook",
|
||||
"site": "https://ficbook.net",
|
||||
"lang": "русский язык",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/russian/ficbook.js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/src/ru/ficbook/icon.png"
|
||||
},
|
||||
{
|
||||
"id": "freedlit.space",
|
||||
"name": "LitSpace",
|
||||
"site": "https://freedlit.space",
|
||||
"lang": "русский язык",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/russian/LitSpace.js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/src/ru/freedlit/icon.png"
|
||||
},
|
||||
{
|
||||
"id": "ifreedom",
|
||||
"name": "Свободный Мир Ранобэ[ifreedom]",
|
||||
"site": "https://ifreedom.su",
|
||||
"lang": "русский язык",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/russian/СвободныйМирРанобэ[ifreedom].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/ifreedom/icons/ifreedom.png"
|
||||
},
|
||||
{
|
||||
"id": "jaomix.ru",
|
||||
"name": "Jaomix",
|
||||
"site": "https://jaomix.ru",
|
||||
"lang": "русский язык",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/russian/jaomix.js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/src/ru/jaomix/icon.png"
|
||||
},
|
||||
{
|
||||
"id": "ReN",
|
||||
"name": "Renovels",
|
||||
"site": "https://renovels.org",
|
||||
"lang": "русский язык",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/russian/renovels.js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/src/ru/renovels/icon.png"
|
||||
},
|
||||
{
|
||||
"id": "RLIB",
|
||||
"name": "RanobeLib",
|
||||
"site": "https://ranobelib.me",
|
||||
"lang": "русский язык",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/russian/ranobelib.js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/src/ru/ranobelib/icon.png"
|
||||
},
|
||||
{
|
||||
"id": "RNBH.org",
|
||||
"name": "RanobeHub",
|
||||
"site": "https://ranobehub.org/",
|
||||
"lang": "русский язык",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/russian/ranobehub.js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/src/ru/ranobehub/icon.png"
|
||||
},
|
||||
{
|
||||
"id": "RNRF",
|
||||
"name": "РанобэРФ",
|
||||
"site": "https://ранобэ.рф",
|
||||
"lang": "русский язык",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/russian/ranoberf.js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/src/ru/ranoberf/icon.png"
|
||||
},
|
||||
{
|
||||
"id": "TL",
|
||||
"name": "NovelTL",
|
||||
"site": "https://novel.tl",
|
||||
"lang": "русский язык",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/russian/novelTL.js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/src/ru/noveltl/icon.png"
|
||||
},
|
||||
{
|
||||
"id": "tl.rulate",
|
||||
"name": "Rulate[rulate]",
|
||||
"site": "https://tl.rulate.ru",
|
||||
"lang": "русский язык",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/russian/Rulate[rulate].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/rulate/icons/rulate.png"
|
||||
}
|
||||
],
|
||||
"español, castellano": [
|
||||
{
|
||||
"id": "tunovelaligera",
|
||||
"name": "TuNovelaLigera",
|
||||
"site": "https://tunovelaligera.com/",
|
||||
"lang": "español, castellano",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/spanish/tunovelaligera.js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/src/es/tunovelaligera/icon.png"
|
||||
}
|
||||
],
|
||||
"Türkçe": [
|
||||
{
|
||||
"id": "lshnovel",
|
||||
"name": "Liebe Schnee Hiver Novel",
|
||||
"site": "https://lshnovel.com/",
|
||||
"lang": "Türkçe",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/turkish/lshnovel.js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/wpmangastream/icons/lshnovel.png"
|
||||
},
|
||||
{
|
||||
"id": "turkcelightnovels",
|
||||
"name": "TurkceLightNovels[madara]",
|
||||
"site": "https://turkcelightnovels.com/",
|
||||
"lang": "Türkçe",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/turkish/TurkceLightNovels[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/turkcelightnovels.png"
|
||||
},
|
||||
{
|
||||
"id": "webnoveloku",
|
||||
"name": "WebNovelOku [madara]",
|
||||
"site": "https://www.webnoveloku.com/",
|
||||
"lang": "Türkçe",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/turkish/WebNovelOku[madara].js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/multisrc/madara/icons/webnoveloku.png"
|
||||
}
|
||||
],
|
||||
"Україна": [
|
||||
{
|
||||
"id": "smakolykytl",
|
||||
"name": "Смаколики",
|
||||
"site": "https://smakolykytl.site/",
|
||||
"lang": "Україна",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/ukraine/smakolykytl.js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/src/ua/smakolykytl/icon.png"
|
||||
}
|
||||
],
|
||||
"Tiếng Việt": [
|
||||
{
|
||||
"id": "ln.hako",
|
||||
"name": "Hako",
|
||||
"site": "https://ln.hako.vn",
|
||||
"lang": "Tiếng Việt",
|
||||
"version": "1.0.0",
|
||||
"url": "https://raw.githubusercontent.com/nyagami/plugins/classes/.js/plugins/vietnamese/LNHako.js",
|
||||
"iconUrl": "https://raw.githubusercontent.com/nyagami/plugins/classes/icons/src/vi/hakolightnovel/icon.png"
|
||||
}
|
||||
]
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -3,6 +3,9 @@ node_modules
|
||||
.env
|
||||
config.json
|
||||
|
||||
# generated multisrc .ts files
|
||||
plugins/*/*\[*\]*.ts
|
||||
|
||||
# ignore TS translation folder but keep plugins folder
|
||||
.js/*
|
||||
!.js/plugins
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
"start": "nodemon",
|
||||
"test": "exit 0",
|
||||
"json": "tsc && node ./.js/scripts/json_plugins.js && git add plugins && git add .dist && git add .js/plugins",
|
||||
"generate": "ts-node ./scripts/multisrc/generate.ts",
|
||||
"generate": "ts-node ./scripts/multisrc/generate.ts && tsc",
|
||||
"clearMulti": "ts-node ./scripts/clearMultisrc.ts",
|
||||
"less": "npx less ./test_web/static/css/index.less ./test_web/static/css/index.css"
|
||||
},
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"ar-mtl","sourceSite":"https://ar-mtl.club/","sourceName":"ArMTL","filters":{},"options":{"useNewChapterEndpoint":true,"lang":"Arabic"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"arnovel","sourceSite":"https://arnovel.me/","sourceName":"ArNovel","filters":{"sort":{"label":"الترتيب حسب","value":"","options":[{"label":"Default","value":""},{"label":"A-Z","value":"alphabet"},{"label":"الآخير","value":"latest"},{"label":"الأكثر مشاهدة","value":"views"},{"label":"التقييم","value":"rating"},{"label":"جديد","value":"new-manga"},{"label":"شائع","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"التصنيفات","value":"","options":[{"label":"NONE","value":""},{"label":"أكشن","value":"%d8%a3%d9%83%d8%b4%d9%86"},{"label":"إتشي","value":"%d8%a5%d8%aa%d8%b4%d9%80%d9%8a"},{"label":"بالغ","value":"%d8%a8%d8%a7%d9%84%d8%ba"},{"label":"تاريخي","value":"%d8%aa%d8%a7%d8%b1%d9%8a%d8%ae%d9%8a"},{"label":"تراجدي","value":"%d8%aa%d8%b1%d8%a7%d8%ac%d8%af%d9%8a"},{"label":"جوسي","value":"%d8%ac%d9%88%d8%b3%d9%8a"},{"label":"حريم","value":"%d8%ad%d8%b1%d9%8a%d9%85"},{"label":"حياة مدرسية","value":"%d8%ad%d9%8a%d8%a7%d8%a9-%d9%85%d8%af%d8%b1%d8%b3%d9%8a%d8%a9"},{"label":"خارق لطبيعية","value":"%d8%ae%d8%a7%d8%b1%d9%82-%d9%84%d8%b7%d8%a8%d9%8a%d8%b9%d9%8a%d8%a9"},{"label":"خيال","value":"%d8%ae%d9%8a%d8%a7%d9%84"},{"label":"خيال علمي","value":"%d8%ae%d9%8a%d8%a7%d9%84-%d8%b9%d9%84%d9%85%d9%8a"},{"label":"دراما","value":"%d8%af%d8%b1%d8%a7%d9%85%d8%a7"},{"label":"راشد","value":"%d8%b1%d8%a7%d8%b4%d8%af"},{"label":"رعب","value":"%d8%b1%d8%b9%d8%a8"},{"label":"رومنسي","value":"%d8%b1%d9%88%d9%85%d9%86%d8%b3%d9%8a"},{"label":"رياضي","value":"%d8%b1%d9%8a%d8%a7%d8%b6%d9%8a"},{"label":"سينين","value":"%d8%b3%d9%8a%d9%86%d9%8a%d9%86"},{"label":"شريحة من الحياة","value":"%d8%b4%d8%b1%d9%8a%d8%ad%d8%a9-%d9%85%d9%86-%d8%a7%d9%84%d8%ad%d9%8a%d8%a7%d8%a9"},{"label":"شوجو","value":"%d8%b4%d9%88%d8%ac%d9%88"},{"label":"شونين","value":"%d8%b4%d9%88%d9%86%d9%8a%d9%86"},{"label":"غموض","value":"%d8%ba%d9%85%d9%88%d8%b6"},{"label":"فنون قتال","value":"%d9%81%d9%86%d9%88%d9%86-%d9%82%d8%aa%d8%a7%d9%84"},{"label":"كوميديا","value":"%d9%83%d9%88%d9%85%d9%8a%d8%af%d9%8a%d8%a7"},{"label":"مغامرات","value":"%d9%85%d8%ba%d8%a7%d9%85%d8%b1%d8%a7%d8%aa"},{"label":"منتهية","value":"%d9%85%d9%86%d8%aa%d9%87%d9%8a%d8%a9"},{"label":"ميكا","value":"%d9%85%d9%8a%d9%83%d8%a7"},{"label":"نفسي","value":"%d9%86%d9%81%d8%b3%d9%8a"}],"type":FilterTypes.Picker}},"options":{"path":{"genres":"home/novel-genre"},"useNewChapterEndpoint":true,"lang":"Arabic"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"hizomanga","sourceSite":"https://hizomanga.com/","sourceName":"HizoManga","filters":{"sort":{"label":"ترتيب حسب","value":"","options":[{"label":"Default","value":""},{"label":"A-Z","value":"alphabet"},{"label":"New","value":"new-manga"},{"label":"الأحدث","value":"latest"},{"label":"الأكثر مشاهدة","value":"views"},{"label":"التقييم","value":"rating"},{"label":"الرائج","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"التصنيفات","value":"","options":[{"label":"NONE","value":""},{"label":"آلات","value":"mechanisms"},{"label":"أكشن","value":"action"},{"label":"إثارة","value":"excitement"},{"label":"إيسكاي","value":"%d8%a5%d9%8a%d8%b3%d9%83%d8%a7%d9%8a"},{"label":"الحياة اليومية","value":"slice-of-life"},{"label":"الحياة مدرسية","value":"school-life"},{"label":"تاريخي","value":"historical"},{"label":"تراجيدي","value":"tragic"},{"label":"جريمة","value":"%d8%ac%d8%b1%d9%8a%d9%85%d8%a9"},{"label":"جندر بندر","value":"%d8%ac%d9%86%d8%af%d8%b1-%d8%a8%d9%86%d8%af%d8%b1"},{"label":"جوسي","value":"josei"},{"label":"حريم","value":"harem"},{"label":"خارق للطبيعة","value":"supernatural"},{"label":"خيال","value":"fantasy"},{"label":"خيال علمي","value":"sci-fi"},{"label":"دراما","value":"drama"},{"label":"دموي","value":"%d8%af%d9%85%d9%88%d9%8a"},{"label":"راشد","value":"mature"},{"label":"رعب","value":"horror"},{"label":"رومانسي","value":"romance"},{"label":"رياضة","value":"sports"},{"label":"زمنكاني","value":"my-time"},{"label":"زومبي","value":"%d8%b2%d9%88%d9%85%d8%a8%d9%8a"},{"label":"سينين","value":"seinen"},{"label":"شريحة من الحياة","value":"%d8%b4%d8%b1%d9%8a%d8%ad%d8%a9-%d9%85%d9%86-%d8%a7%d9%84%d8%ad%d9%8a%d8%a7%d8%a9"},{"label":"شوجو","value":"shoujo"},{"label":"شونين","value":"shounen"},{"label":"طبي","value":"%d8%b7%d8%a8%d9%8a"},{"label":"غموض","value":"ambiguity"},{"label":"فنون قتالية","value":"martial-arts"},{"label":"قوة خارقة","value":"superpower"},{"label":"كوميدي","value":"comedy"},{"label":"مغامرات","value":"adventure"},{"label":"نفسي","value":"psychological"}],"type":FilterTypes.Picker}},"options":{"path":{"novels":"serie","novel":"serie","chapter":"serie","genres":"manga-genre"},"useNewChapterEndpoint":true,"lang":"Arabic"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,152 +0,0 @@
|
||||
import { CheerioAPI, load } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
|
||||
interface WPmangaStreamOptions {
|
||||
reverseChapters?: boolean;
|
||||
lang?: string;
|
||||
}
|
||||
|
||||
export interface WPmangaStreamMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: WPmangaStreamOptions;
|
||||
}
|
||||
|
||||
class WPmangaStreamPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: WPmangaStreamOptions;
|
||||
|
||||
constructor(metadata: WPmangaStreamMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[wpmangastream]";
|
||||
this.icon = `multisrc/wpmangastream/icons/${metadata.id}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
}
|
||||
|
||||
async popularNovels(page: number): Promise<Plugin.NovelItem[]> {
|
||||
const url = this.site + "series/?page=" + page + "&status=&order=popular";
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
const loadedCheerio = load(body);
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio("article.maindet").each(function () {
|
||||
const name = loadedCheerio(this).find("h2").text();
|
||||
const image = loadedCheerio(this).find("img");
|
||||
const url = loadedCheerio(this).find("h2 a").attr("href");
|
||||
|
||||
if (!url) return;
|
||||
novels.push({
|
||||
name,
|
||||
cover: image.attr("data-src") || image.attr("src"),
|
||||
url,
|
||||
});
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
|
||||
async parseNovelAndChapters(url: string): Promise<Plugin.SourceNovel> {
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
const loadedCheerio = load(body);
|
||||
|
||||
const novel: Plugin.SourceNovel = { url };
|
||||
|
||||
// novel.url = url;
|
||||
novel.name = loadedCheerio("h1.entry-title").text();
|
||||
novel.cover =
|
||||
loadedCheerio("img.wp-post-image").attr("data-src") ||
|
||||
loadedCheerio("img.wp-post-image").attr("src");
|
||||
novel.status = loadedCheerio("div.sertostat > span").attr("class");
|
||||
|
||||
loadedCheerio("div.serl > span").each(function () {
|
||||
const detailName = loadedCheerio(this).text().trim();
|
||||
const detail = loadedCheerio(this).next().text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "الكاتب":
|
||||
case "Author":
|
||||
case "Auteur":
|
||||
novel.author = detail;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
novel.genres = loadedCheerio(".sertogenre")
|
||||
.children("a")
|
||||
.map((i, el) => loadedCheerio(el).text())
|
||||
.toArray()
|
||||
.join(",");
|
||||
|
||||
let summary = loadedCheerio(".sersys > p").siblings().remove("div").end();
|
||||
novel.summary = "";
|
||||
for (let i = 0; i < summary.length; i++) {
|
||||
const p = summary[i];
|
||||
novel.summary += loadedCheerio(p).text().trim() + "\\n\\n";
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = loadedCheerio(".eplister li")
|
||||
.map((index, element) => ({
|
||||
name:
|
||||
loadedCheerio(element).find(".epl-num").text() +
|
||||
loadedCheerio(element).find(".epl-title").text(),
|
||||
releaseTime: loadedCheerio(element).find(".epl-date").text().trim(),
|
||||
url: loadedCheerio(element).find("a").attr("href") || "",
|
||||
}))
|
||||
.get()
|
||||
.filter((chapter) => chapter.name && chapter.url);
|
||||
|
||||
if (this.options?.reverseChapters && chapters.length) chapters.reverse();
|
||||
|
||||
novel.chapters = chapters;
|
||||
return novel;
|
||||
}
|
||||
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
const loadedCheerio = load(body);
|
||||
|
||||
const chapterText = loadedCheerio(".epcontent").html() || "";
|
||||
return chapterText;
|
||||
}
|
||||
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
const url = this.site + "?s=" + searchTerm;
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
const loadedCheerio = load(body);
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio("article.maindet").each(function () {
|
||||
const name = loadedCheerio(this).find("h2").text();
|
||||
const image = loadedCheerio(this).find("img");
|
||||
const url = loadedCheerio(this).find("h2 a").attr("href");
|
||||
|
||||
if (!url) return;
|
||||
novels.push({
|
||||
name,
|
||||
cover: image.attr("data-src") || image.attr("src"),
|
||||
url,
|
||||
});
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
|
||||
fetchImage = fetchFile;
|
||||
}
|
||||
|
||||
const plugin = new WPmangaStreamPlugin({"id":"kol-novel","sourceSite":"https://kolnovel.com/","sourceName":"Kol Novel","options":{"lang":"arabic","reverseChapters":true}});
|
||||
export default plugin;
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"novel4up","sourceSite":"https://novel4up.com/","sourceName":"Novel4Up","filters":{"sort":{"label":"ترتيب حسب:","value":"","options":[{"label":"Default","value":""},{"label":"أ-ي","value":"alphabet"},{"label":"الأحدث","value":"latest"},{"label":"الأكثر مشاهدة","value":"views"},{"label":"التقييم","value":"rating"},{"label":"الجديد","value":"new-manga"},{"label":"الشائع","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"التصنيفات","value":"","options":[{"label":"NONE","value":""},{"label":"أكشن","value":"action"},{"label":"الخارق للطبيعة","value":"supernatural"},{"label":"تاريخي","value":"historical"},{"label":"تحقيق","value":"detective"},{"label":"تراجيديا","value":"tragedy"},{"label":"حريم","value":"harem"},{"label":"حياة مدرسية","value":"school-life"},{"label":"خيال علمي","value":"sci-fi"},{"label":"دراما","value":"drama"},{"label":"رعب","value":"horror"},{"label":"رومانسي","value":"romance"},{"label":"رياضة","value":"sports"},{"label":"سحر","value":"magic"},{"label":"شريحة من الحياة","value":"slice-of-life"},{"label":"شوانهوا","value":"xuanhuan"},{"label":"شوجو","value":"shoujo"},{"label":"شونين","value":"shounen"},{"label":"غموض","value":"mystery"},{"label":"فانتازيا","value":"fantasy"},{"label":"فنون قتال","value":"martial-arts"},{"label":"كوميديا","value":"comedy"},{"label":"مغامرة","value":"adventure"},{"label":"ميكا","value":"mecha"},{"label":"نفسي","value":"psychological"},{"label":"ون شوت","value":"one-shot"},{"label":"ووشيا","value":"wuxia"}],"type":FilterTypes.Picker}},"options":{"lang":"Arabic"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"riwyat","sourceSite":"https://riwyat.com/","sourceName":"Riwyat","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"GENRES","value":"","options":[{"label":"NONE","value":""},{"label":"أكشن","value":"%d8%a3%d9%83%d8%b4%d9%86"},{"label":"أيتشي","value":"%d8%a3%d9%8a%d8%aa%d8%b4%d9%8a"},{"label":"استراتجي","value":"%d8%a7%d8%b3%d8%aa%d8%b1%d8%a7%d8%aa%d8%ac%d9%8a"},{"label":"العصر الحديث","value":"%d8%a7%d9%84%d8%b9%d8%b5%d8%b1-%d8%a7%d9%84%d8%ad%d8%af%d9%8a%d8%ab"},{"label":"انتقام","value":"%d8%a7%d9%86%d8%aa%d9%82%d8%a7%d9%85"},{"label":"بالغ","value":"%d8%a8%d8%a7%d9%84%d8%ba"},{"label":"بناء مملكة","value":"%d8%a8%d9%86%d8%a7%d8%a1-%d9%85%d9%85%d9%84%d9%83%d8%a9"},{"label":"بوليسي","value":"%d8%a8%d9%88%d9%84%d9%8a%d8%b3%d9%8a"},{"label":"تاريخي","value":"%d8%aa%d8%a7%d8%b1%d9%8a%d8%ae%d9%8a"},{"label":"جوسي","value":"%d8%ac%d9%88%d8%b3%d9%8a"},{"label":"حريم","value":"%d8%ad%d8%b1%d9%8a%d9%85"},{"label":"حياة يومية","value":"%d8%ad%d9%8a%d8%a7%d8%a9-%d9%8a%d9%88%d9%85%d9%8a%d8%a9"},{"label":"خيال","value":"%d8%ae%d9%8a%d8%a7%d9%84"},{"label":"خيال علمي","value":"%d8%ae%d9%8a%d8%a7%d9%84-%d8%b9%d9%84%d9%85%d9%8a"},{"label":"دراما","value":"%d8%af%d8%b1%d8%a7%d9%85%d8%a7"},{"label":"رعب","value":"%d8%b1%d8%b9%d8%a8"},{"label":"رومانسية","value":"%d8%b1%d9%88%d9%85%d8%a7%d9%86%d8%b3%d9%8a%d8%a9"},{"label":"رياضي","value":"%d8%b1%d9%8a%d8%a7%d8%b6%d9%8a"},{"label":"زيانشيا","value":"xianxia"},{"label":"سنين","value":"%d8%b3%d9%86%d9%8a%d9%86"},{"label":"شريحة حياة","value":"%d8%b4%d8%b1%d9%8a%d8%ad%d8%a9-%d8%ad%d9%8a%d8%a7%d8%a9"},{"label":"شوانهوان","value":"xuanhuan"},{"label":"شوجو","value":"%d8%b4%d9%88%d8%ac%d9%88"},{"label":"شونين","value":"%d8%b4%d9%88%d9%86%d9%8a%d9%86"},{"label":"شيانشيا","value":"%d8%b4%d9%8a%d8%a7%d9%86%d8%b4%d9%8a%d8%a7"},{"label":"عسكري","value":"%d8%b9%d8%b3%d9%83%d8%b1%d9%8a"},{"label":"غموض","value":"%d8%ba%d9%85%d9%88%d8%b6"},{"label":"فانتازيا","value":"%d9%81%d8%a7%d9%86%d8%aa%d8%a7%d8%b2%d9%8a%d8%a7"},{"label":"فنون قتالية","value":"%d9%81%d9%86%d9%88%d9%86-%d9%82%d8%aa%d8%a7%d9%84%d9%8a%d8%a9"},{"label":"قوى خارقة","value":"%d9%82%d9%88%d9%89-%d8%ae%d8%a7%d8%b1%d9%82%d8%a9"},{"label":"كوميديا","value":"%d9%83%d9%88%d9%85%d9%8a%d8%af%d9%8a%d8%a7"},{"label":"كوميك","value":"%d9%83%d9%88%d9%85%d9%8a%d9%83"},{"label":"للكبار","value":"%d9%84%d9%84%d9%83%d8%a8%d8%a7%d8%b1"},{"label":"مأساة","value":"%d9%85%d8%a3%d8%b3%d8%a7%d8%a9"},{"label":"مانجا","value":"%d9%85%d8%a7%d9%86%d8%ac%d8%a7"},{"label":"مانها","value":"%d9%85%d8%a7%d9%86%d9%87%d8%a7"},{"label":"مانهوا","value":"%d9%85%d8%a7%d9%86%d9%87%d9%88%d8%a7"},{"label":"مدرسي","value":"%d9%85%d8%af%d8%b1%d8%b3%d9%8a"},{"label":"مصاصي دماء","value":"%d9%85%d8%b5%d8%a7%d8%b5%d9%8a-%d8%af%d9%85%d8%a7%d8%a1"},{"label":"مغامرة","value":"%d9%85%d8%ba%d8%a7%d9%85%d8%b1%d8%a9"},{"label":"مكتملة","value":"%d9%85%d9%83%d8%aa%d9%85%d9%84%d8%a9"},{"label":"نفسي","value":"%d9%86%d9%81%d8%b3%d9%8a"},{"label":"نهاية العالم","value":"%d9%86%d9%87%d8%a7%d9%8a%d8%a9-%d8%a7%d9%84%d8%b9%d8%a7%d9%84%d9%85"},{"label":"واب تون","value":"%d9%88%d8%a7%d8%a8-%d8%aa%d9%88%d9%86"},{"label":"وان شوت","value":"%d9%88%d8%a7%d9%86-%d8%b4%d9%88%d8%aa"}],"type":FilterTypes.Picker}},"options":{"useNewChapterEndpoint":true,"lang":"Arabic"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"teamxnovel","sourceSite":"https://teamxnovel.com/","sourceName":"TeamXNovel","filters":{},"options":{"useNewChapterEndpoint":true,"lang":"Arabic"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"boxnovel","sourceSite":"https://boxnovel.com/","sourceName":"BoxNovel","filters":{"sort":{"label":"Order by","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"value":"","type":FilterTypes.Picker},"genres":{"label":"GENRES","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adventure","value":"adventure"},{"label":"Comedy","value":"comedy"},{"label":"Drama","value":"drama"},{"label":"Ecchi","value":"ecchi"},{"label":"Fantasy","value":"fantasy"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Josei","value":"josei"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Mystery","value":"mystery"},{"label":"Psychological","value":"psychological"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shoujo","value":"shoujo"},{"label":"Shounen","value":"shounen"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"},{"label":"Yaoi","value":"yaoi"}],"value":"","type":FilterTypes.Picker}},"options":{"path":{"genres":"manga-genre"},"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"clicknovel","sourceSite":"https://clicknovel.net/","sourceName":"ClickNovel","filters":{},"options":{"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"cratenovel","sourceSite":"https://cratenovel.com/","sourceName":"CrateNovel","filters":{},"options":{"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"daonovel","sourceSite":"https://daonovel.com/","sourceName":"DaoNovel","filters":{"sort":{"value":"","label":"Order by","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker}},"options":{"path":{"novels":"novels-list","novel":"novels","chapter":"novels"},"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"fanTLS","sourceSite":"https://fanstranslations.com/","sourceName":"Fans Translations","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker}},"options":{"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"1stkissnovel","sourceSite":"https://1stkissnovel.org/","sourceName":"FirstKissNovel","filters":{"sort":{"label":"Order by","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"value":"","type":FilterTypes.Picker},"genres":{"label":"GENRES","value":"","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adult","value":"adult"},{"label":"Adventure","value":"adventure"},{"label":"Anime","value":"anime"},{"label":"Apocalypse","value":"apocalypse"},{"label":"Boy's Love","value":"boys-love"},{"label":"Comedy","value":"comedy"},{"label":"Completed","value":"completed"},{"label":"Cooking","value":"cooking"},{"label":"Demons","value":"demons"},{"label":"Detective","value":"detective"},{"label":"Drama","value":"drama"},{"label":"Ecchi","value":"ecchi"},{"label":"Fan-Fiction","value":"fan-fiction"},{"label":"Fantasy","value":"fantasy"},{"label":"Food","value":"food"},{"label":"Game","value":"game"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Girls Love","value":"girls-love"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Humor","value":"humor"},{"label":"Isekai","value":"isekai"},{"label":"Josei","value":"josei"},{"label":"Magic","value":"magic"},{"label":"Magical","value":"magical"},{"label":"Manhua","value":"manhua"},{"label":"Manhwa","value":"manhwa"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Medical","value":"medical"},{"label":"Military","value":"military"},{"label":"Moder","value":"moder"},{"label":"Modern","value":"modern"},{"label":"Murim","value":"murim"},{"label":"Music","value":"music"},{"label":"Mystery","value":"mystery"},{"label":"Psychological","value":"psychological"},{"label":"Reverse","value":"reverse"},{"label":"Reverse harem","value":"reverse-harem"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shoujo","value":"shoujo"},{"label":"Shoujo Ai","value":"shoujo-ai"},{"label":"Shounen","value":"shounen"},{"label":"Shounen Ai","value":"shounen-ai"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Sports","value":"sports"},{"label":"Super power","value":"super-power"},{"label":"Superhero","value":"superhero"},{"label":"Supernatural","value":"supernatural"},{"label":"Thriller","value":"thriller"},{"label":"Tragedy","value":"tragedy"},{"label":"Urban Life","value":"urban-life"},{"label":"Vampire","value":"vampire"},{"label":"Webtoons","value":"webtoons"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"},{"label":"Yaoi","value":"yaoi"},{"label":"Yuri","value":"yuri"}],"type":FilterTypes.Picker}},"options":{"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"freenovel.me","sourceSite":"https://freenovel.me/","sourceName":"FreeNovelMe","filters":{"sort":{"label":"Order by","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"value":"","type":FilterTypes.Picker},"genres":{"label":"GENRES","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adult","value":"adult"},{"label":"Adventure","value":"adventure"},{"label":"Cartoon","value":"cartoon"},{"label":"Comedy","value":"comedy"},{"label":"Cooking","value":"cooking"},{"label":"Detective","value":"detective"},{"label":"Drama","value":"drama"},{"label":"Fantasy","value":"fantasy"},{"label":"Game","value":"game"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Historical","value":"historical"},{"label":"History","value":"history"},{"label":"Horror","value":"horror"},{"label":"Josei","value":"josei"},{"label":"Live action","value":"live-action"},{"label":"Martial","value":"martial"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Mystery","value":"mystery"},{"label":"One shot","value":"one-shot"},{"label":"Premium","value":"premium"},{"label":"Psychological","value":"psychological"},{"label":"Reincarnation","value":"reincarnation"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"}],"value":"","type":FilterTypes.Picker}},"options":{"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"guavaread","sourceSite":"https://guavaread.com/","sourceName":"Guavaread","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"GENRES","value":"","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adult","value":"adult"},{"label":"Adventure","value":"adventure"},{"label":"Comedy","value":"comedy"},{"label":"Complete","value":"complete"},{"label":"Cooking","value":"cooking"},{"label":"Detective","value":"detective"},{"label":"Drama","value":"drama"},{"label":"Dropped","value":"dropped"},{"label":"Ecchi","value":"ecchi"},{"label":"Fantasy","value":"fantasy"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Josei","value":"josei"},{"label":"Mature","value":"mature"},{"label":"Mystery","value":"mystery"},{"label":"Original Story","value":"original-story"},{"label":"Pilot","value":"pilot"},{"label":"Psychological","value":"psychological"},{"label":"R-15","value":"r-15"},{"label":"R-19","value":"r-19"},{"label":"Reverse Harem","value":"reverse-harem"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Shoujo","value":"shoujo"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"}],"type":FilterTypes.Picker}},"options":{"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"lnheaven","sourceSite":"https://lightnovelheaven.com/","sourceName":"LightNovelHeaven","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker}},"options":{"path":{"novels":"series","novel":"series","chapter":"series"},"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"lunarletters","sourceSite":"https://www.lunarletters.com/","sourceName":"LunarLetters","filters":{"sort":{"label":"Order by","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"value":"","type":FilterTypes.Picker}},"options":{"path":{"novels":"series","novel":"series","chapter":"series"},"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"mtlnovel.club","sourceSite":"https://mtlnovel.club/","sourceName":"MTLNovel.Club","filters":{},"options":{"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"mtl-novel","sourceSite":"https://mtl-novel.com/","sourceName":"MTL-Novel","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"GENRES","value":"","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adult","value":"adult"},{"label":"Adventure","value":"adventure"},{"label":"Chinese","value":"chinese"},{"label":"Comedy","value":"comedy"},{"label":"Conan","value":"conan"},{"label":"Drama","value":"drama"},{"label":"Erciyuan","value":"erciyuan"},{"label":"Fairy Tail","value":"fairy-tail"},{"label":"Faloo","value":"faloo"},{"label":"Fan-Fiction","value":"fan-fiction"},{"label":"Fantasy","value":"fantasy"},{"label":"FoodWars!","value":"foodwars"},{"label":"Game","value":"game"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Hunter x Hunter","value":"hunter-x-hunter"},{"label":"Japanese","value":"japanese"},{"label":"Jojo","value":"jojo"},{"label":"Josei","value":"josei"},{"label":"Korean","value":"korean"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Marvel","value":"marvel"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Military","value":"military"},{"label":"Mystery","value":"mystery"},{"label":"Naruto","value":"naruto"},{"label":"One piece","value":"one-piece"},{"label":"Pokemon","value":"pokemon"},{"label":"Psychological","value":"psychological"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shoujo","value":"shoujo"},{"label":"Shoujo Ai","value":"shoujo-ai"},{"label":"Shounen Ai","value":"shounen-ai"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Sport","value":"sport"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"System","value":"system"},{"label":"Tragedy","value":"tragedy"},{"label":"Urban","value":"urban"},{"label":"Urban Life","value":"urban-life"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"},{"label":"Yaoi","value":"yaoi"},{"label":"Yuri","value":"yuri"}],"type":FilterTypes.Picker}},"options":{"path":{"genres":"manga-genre"},"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"mostnovel","sourceSite":"https://mostnovel.com/","sourceName":"MostNovel","filters":{"sort":{"value":"","label":"Order by","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker},"genres":{"value":"","label":"GENRES","options":[{"label":"NONE","value":""},{"label":"ACG","value":"acg"},{"label":"Action","value":"action"},{"label":"Adult","value":"adult"},{"label":"Adventure","value":"adventure"},{"label":"AGA","value":"aga"},{"label":"Anime","value":"anime"},{"label":"Anime & Comics","value":"anime-comics"},{"label":"Bender","value":"bender"},{"label":"BL","value":"bl"},{"label":"Cartoon","value":"cartoon"},{"label":"Comedy","value":"comedy"},{"label":"Comic","value":"comic"},{"label":"Contemporary Romance","value":"contemporary-romance"},{"label":"Cooking","value":"cooking"},{"label":"Cultivation","value":"cultivation"},{"label":"Detective","value":"detective"},{"label":"Doujinshi","value":"doujinshi"},{"label":"Drama","value":"drama"},{"label":"Eastern Fantasy","value":"eastern-fantasy"},{"label":"Ecchi","value":"ecchi"},{"label":"Fantasy","value":"fantasy"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Horror&Thriller","value":"horrorthriller"},{"label":"Josei","value":"josei"},{"label":"Live action","value":"live-action"},{"label":"Magical Realism","value":"magical-realism"},{"label":"Manga","value":"manga"},{"label":"Manhua","value":"manhua"},{"label":"Manhwa","value":"manhwa"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Modern","value":"modern"},{"label":"Movies","value":"movies"},{"label":"Mystery","value":"mystery"},{"label":"One shot","value":"one-shot"},{"label":"Psychological","value":"psychological"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shoujo","value":"shoujo"},{"label":"Shoujo Ai","value":"shoujo-ai"},{"label":"Shounen","value":"shounen"},{"label":"Shounen Ai","value":"shounen-ai"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smart MC","value":"smart-mc"},{"label":"Smut","value":"smut"},{"label":"Soft Yaoi","value":"soft-yaoi"},{"label":"Soft Yuri","value":"soft-yuri"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"},{"label":"Urban Life","value":"urban-life"},{"label":"Video Games","value":"video-games"},{"label":"Webtoon","value":"webtoon"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"},{"label":"Yaoi","value":"yaoi"},{"label":"Yuri","value":"yuri"}],"type":FilterTypes.Picker}},"options":{"path":{"novels":"manga","novel":"manga","chapter":"manga","genres":"manga-genre"},"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"mysticalmerries","sourceSite":"https://mysticalmerries.com/","sourceName":"MysticalSeries","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"GENRES","value":"","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adaptation","value":"adaptation"},{"label":"Adventure","value":"adventure"},{"label":"bilibili","value":"bilibili"},{"label":"Chinese Novel","value":"chinese-novel"},{"label":"Comedy","value":"comedy"},{"label":"Crossdressing","value":"crossdressing"},{"label":"Drama","value":"drama"},{"label":"Dropped","value":"dropped"},{"label":"Family","value":"family"},{"label":"Fantasy","value":"fantasy"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Isekai","value":"isekai"},{"label":"Korean Novel","value":"korean-novell"},{"label":"Manga","value":"manga"},{"label":"Manhua","value":"manhua"},{"label":"Manhwa","value":"manhwa"},{"label":"Modern Romance","value":"modern-romance"},{"label":"Mystery","value":"mystery"},{"label":"Office Workers","value":"office-workers"},{"label":"One shot","value":"one-shot"},{"label":"Pilot Novel","value":"pilot-novel"},{"label":"R15","value":"r15"},{"label":"R19","value":"r19"},{"label":"Regression","value":"regression"},{"label":"Reincarnation","value":"reincarnation"},{"label":"Reverse Harem","value":"reverse-harem"},{"label":"Romance Fantasy","value":"romance-fantasy"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Supernatural","value":"supernatural"},{"label":"Violence","value":"violence"}],"type":FilterTypes.Picker}},"options":{"path":{"novels":"series","novel":"series","chapter":"series","genres":"genre"},"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"neosekaiTLS","sourceSite":"https://www.neosekaitranslations.com/","sourceName":"NeoSekai Translations","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"GENRES","value":"","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adventure","value":"adventure"},{"label":"Comedy","value":"comedy"},{"label":"Drama","value":"drama"},{"label":"Fantasy","value":"fantasy"},{"label":"Harem","value":"harem"},{"label":"Horror","value":"horror"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Mystery","value":"mystery"},{"label":"Psychological","value":"psychological"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-Fi","value":"sci-fi"},{"label":"Slice of Life","value":"slice-of-life"}],"type":FilterTypes.Picker}},"options":{"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"nocturneTLS","sourceSite":"https://nocturnetls.net/","sourceName":"Nocturne Translations","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"GENRES","value":"","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adult","value":"adult"},{"label":"Adventure","value":"adventure"},{"label":"Anime","value":"anime"},{"label":"Cartoon","value":"cartoon"},{"label":"Comedy","value":"comedy"},{"label":"Comic","value":"comic"},{"label":"Cooking","value":"cooking"},{"label":"Detective","value":"detective"},{"label":"Doujinshi","value":"doujinshi"},{"label":"Drama","value":"drama"},{"label":"Ecchi","value":"ecchi"},{"label":"Fantasy","value":"fantasy"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Josei","value":"josei"},{"label":"Live action","value":"live-action"},{"label":"Manga","value":"manga"},{"label":"Manhua","value":"manhua"},{"label":"Manhwa","value":"manhwa"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Mystery","value":"mystery"},{"label":"One shot","value":"one-shot"},{"label":"Psychological","value":"psychological"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shoujo","value":"shoujo"},{"label":"Shoujo Ai","value":"shoujo-ai"},{"label":"Shounen","value":"shounen"},{"label":"Shounen Ai","value":"shounen-ai"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Soft Yaoi","value":"soft-yaoi"},{"label":"Soft Yuri","value":"soft-yuri"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"},{"label":"Webtoon","value":"webtoon"},{"label":"Yaoi","value":"yaoi"},{"label":"Yuri","value":"yuri"}],"type":FilterTypes.Picker}},"options":{"path":{"novels":"novels","novel":"novels","chapter":"novels","genres":"manga-genre"},"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"noobchanTL","sourceSite":"https://noobchan.xyz/","sourceName":"Noobchan Translation","filters":{},"options":{"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"novelmultiverse","sourceSite":"https://www.novelmultiverse.com/","sourceName":"NovelMultiverse","filters":{"sort":{"value":"","label":"Order by","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"GENRES","value":"","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adult","value":"adult"},{"label":"Adventure","value":"adventure"},{"label":"Anime","value":"anime"},{"label":"Cartoon","value":"cartoon"},{"label":"Comedy","value":"comedy"},{"label":"Comic","value":"comic"},{"label":"Cooking","value":"cooking"},{"label":"Detective","value":"detective"},{"label":"Doujinshi","value":"doujinshi"},{"label":"Drama","value":"drama"},{"label":"Ecchi","value":"ecchi"},{"label":"Fantasy","value":"fantasy"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Josei","value":"josei"},{"label":"Live action","value":"live-action"},{"label":"Manga","value":"manga"},{"label":"Manhua","value":"manhua"},{"label":"Manhwa","value":"manhwa"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Mystery","value":"mystery"},{"label":"One shot","value":"one-shot"},{"label":"Original","value":"original"},{"label":"Psychological","value":"psychological"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shoujo","value":"shoujo"},{"label":"Shoujo Ai","value":"shoujo-ai"},{"label":"Shounen","value":"shounen"},{"label":"Shounen Ai","value":"shounen-ai"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Soft Yaoi","value":"soft-yaoi"},{"label":"Soft Yuri","value":"soft-yuri"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"},{"label":"Translation","value":"translation"},{"label":"Webtoon","value":"webtoon"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"},{"label":"Yaoi","value":"yaoi"},{"label":"Yuri","value":"yuri"}],"type":FilterTypes.Picker}},"options":{"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"novelr18","sourceSite":"https://novelr18.com/","sourceName":"NovelR18","filters":{"sort":{"label":"Sort by :","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest Update","value":"latest"},{"label":"Most Views","value":"views"},{"label":"Newly Added Novels","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker}},"options":{"path":{"novels":"novel","novel":"manga","chapter":"manga"},"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"novelTL","sourceSite":"https://noveltranslate.com/","sourceName":"NovelTranslate","filters":{"sort":{"label":"Order by","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"value":"","type":FilterTypes.Picker},"genres":{"label":"GENRES","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adult","value":"adult"},{"label":"Adventure","value":"adventure"},{"label":"Bleach","value":"bleach"},{"label":"Chinese","value":"chinese"},{"label":"Comedy","value":"comedy"},{"label":"Conan","value":"conan"},{"label":"cooking","value":"cooking"},{"label":"Dragon Ball","value":"dragon-ball"},{"label":"Drama","value":"drama"},{"label":"Ecchi","value":"ecchi"},{"label":"Erciyuan","value":"erciyuan"},{"label":"Fairy Tail","value":"fairy-tail"},{"label":"Faloo","value":"faloo"},{"label":"Fan-Fiction","value":"fan-fiction"},{"label":"Fantasy","value":"fantasy"},{"label":"FoodWars!","value":"foodwars"},{"label":"Game","value":"game"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Hunter x Hunter","value":"hunter-x-hunter"},{"label":"Isekai","value":"isekai"},{"label":"Japanese","value":"japanese"},{"label":"Jojo","value":"jojo"},{"label":"Josei","value":"josei"},{"label":"Korean","value":"korean"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Marvel","value":"marvel"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Military","value":"military"},{"label":"Mystery","value":"mystery"},{"label":"Naruto","value":"naruto"},{"label":"One piece","value":"one-piece"},{"label":"Pokemon","value":"pokemon"},{"label":"Political","value":"political"},{"label":"Psychological","value":"psychological"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shoujo","value":"shoujo"},{"label":"Shoujo Ai","value":"shoujo-ai"},{"label":"Shounen","value":"shounen"},{"label":"Shounen Ai","value":"shounen-ai"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Sport","value":"sport"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"System","value":"system"},{"label":"Toriko","value":"toriko"},{"label":"Tragedy","value":"tragedy"},{"label":"Urban","value":"urban"},{"label":"Urban Life","value":"urban-life"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"},{"label":"Yaoi","value":"yaoi"},{"label":"Yuri","value":"yuri"}],"value":"","type":FilterTypes.Picker}},"options":{"path":{"novels":"all-novels","novel":"manga","chapter":"manga","genres":"manga-genre"},"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"novelroom","sourceSite":"https://novelroom.net/","sourceName":"Novelroom.net","filters":{},"options":{"path":{"novels":"manga","novel":"manga","chapter":"manga"},"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"novelstic","sourceSite":"https://novelstic.com/","sourceName":"Novelstic","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker}},"options":{"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"onlymtl","sourceSite":"https://www.onlymtl.com/","sourceName":"OnlyMTL","filters":{},"options":{"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"readwebnovels","sourceSite":"https://readwebnovels.net/","sourceName":"ReadWebNovels","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker}},"options":{"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"sleeptTLS","sourceSite":"https://sleepytranslations.com/","sourceName":"SleepyTranslations","filters":{"sort":{"label":"Order by","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"value":"","type":FilterTypes.Picker}},"options":{"path":{"novels":"series","novel":"series","chapter":"series"},"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"sonicmtl","sourceSite":"https://www.sonicmtl.com/","sourceName":"SonicMTL","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"GENRES","value":"","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adult","value":"adult"},{"label":"Adventure","value":"adventure"},{"label":"Comedy","value":"comedy"},{"label":"Cooking","value":"cooking"},{"label":"Detective","value":"detective"},{"label":"Doujinshi","value":"doujinshi"},{"label":"Drama","value":"drama"},{"label":"Ecchi","value":"ecchi"},{"label":"Fan-Fiction","value":"fan-fiction"},{"label":"Fantasy","value":"fantasy"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Josei","value":"josei"},{"label":"Live action","value":"live-action"},{"label":"Manga","value":"manga"},{"label":"Manhua","value":"manhua"},{"label":"Manhwa","value":"manhwa"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Mystery","value":"mystery"},{"label":"One shot","value":"one-shot"},{"label":"Psychological","value":"psychological"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shoujo","value":"shoujo"},{"label":"Shoujo Ai","value":"shoujo-ai"},{"label":"Shounen","value":"shounen"},{"label":"Shounen Ai","value":"shounen-ai"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Soft Yaoi","value":"soft-yaoi"},{"label":"Soft Yuri","value":"soft-yuri"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"},{"label":"Urban Life","value":"urban-life"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"},{"label":"Yaoi","value":"yaoi"},{"label":"Yuri","value":"yuri"}],"type":FilterTypes.Picker}},"options":{"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"sugarbbscan","sourceSite":"https://sugarbbscan.com/","sourceName":"Sugar Babies","filters":{},"options":{"path":{"novels":"series","novel":"series","chapter":"series"},"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"sweetEscapeTL","sourceSite":"https://sweetescapetranslations.com/","sourceName":"Sweet Escape Translations","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"GENRES","value":"","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adult","value":"adult"},{"label":"Comedy","value":"comedy"},{"label":"Drama","value":"drama"},{"label":"Fantasy","value":"fantasy"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Mature","value":"mature"},{"label":"Modern","value":"modern"},{"label":"Mystery","value":"mystery"},{"label":"R-15","value":"r-15"},{"label":"Romance","value":"romance"},{"label":"Slice of Life","value":"slice-of-life"}],"type":FilterTypes.Picker}},"options":{"path":{"novels":"manga","novel":"manga","chapter":"manga","genres":"manga-genre"},"useNewChapterEndpoint":false,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"webnovelover","sourceSite":"https://www.webnovelover.com/","sourceName":"WebNovelLover","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"GENRES","value":"","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adapted into drama","value":"adapted-into-drama"},{"label":"Adventure","value":"adventure"},{"label":"Comedy","value":"comedy"},{"label":"Completed","value":"completed"},{"label":"Drama","value":"drama"},{"label":"English Novel","value":"english-novel"},{"label":"Fantasy","value":"fantasy"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Indo Novel","value":"indo-novel"},{"label":"Josei","value":"josei"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mystery","value":"mystery"},{"label":"Rebirth","value":"rebirth"},{"label":"Reincarnation","value":"reincarnation"},{"label":"Romance","value":"romance"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Shoujo","value":"shoujo"},{"label":"Shounen","value":"shounen"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Spiritual","value":"spiritual"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"},{"label":"Transmigration","value":"transmigration"},{"label":"University","value":"university"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"},{"label":"Youth","value":"youth"}],"type":FilterTypes.Picker}},"options":{"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"wuxiaworld.site","sourceSite":"https://wuxiaworld.site/","sourceName":"WuxiaWorld.Site","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker}},"options":{"useNewChapterEndpoint":true,"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"zetroTL","sourceSite":"https://zetrotranslation.com/","sourceName":"Zetro Translation","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"GENRES","value":"","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adventure","value":"adventure"},{"label":"Comedy","value":"comedy"},{"label":"Dark Elf","value":"dark-elf"},{"label":"Drama","value":"drama"},{"label":"Ecchi","value":"ecchi"},{"label":"Fantasy","value":"fantasy"},{"label":"Harem","value":"harem"},{"label":"Horror","value":"horror"},{"label":"Isekai","value":"isekai"},{"label":"Mecha","value":"mecha"},{"label":"Mystery","value":"mystery"},{"label":"NTR","value":"ntr"},{"label":"Original Works","value":"original-works"},{"label":"Rom-Com","value":"rom-com"},{"label":"Romance","value":"romance"},{"label":"School","value":"school"},{"label":"Shoujo","value":"shoujo"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Villain","value":"villain"},{"label":"Yuri","value":"yuri"}],"type":FilterTypes.Picker}},"options":{"path":{"genres":"genre"},"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"zinnovel","sourceSite":"https://zinnovel.com/","sourceName":"ZinnNovel","filters":{"sort":{"label":"Order by","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"value":"","type":FilterTypes.Picker},"genres":{"label":"GENRES","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adult","value":"adult"},{"label":"Adventure","value":"adventure"},{"label":"Anime","value":"anime"},{"label":"Cartoon","value":"cartoon"},{"label":"Comedy","value":"comedy"},{"label":"Comic","value":"comic"},{"label":"Cooking","value":"cooking"},{"label":"Detective","value":"detective"},{"label":"Doujinshi","value":"doujinshi"},{"label":"Drama","value":"drama"},{"label":"Ecchi","value":"ecchi"},{"label":"Fantasy","value":"fantasy"},{"label":"Game","value":"game"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Isekai","value":"isekai"},{"label":"Josei","value":"josei"},{"label":"Live action","value":"live-action"},{"label":"Lolicon","value":"lolicon"},{"label":"Magical Realism","value":"magical-realism"},{"label":"Manga","value":"manga"},{"label":"Manhua","value":"manhua"},{"label":"Manhwa","value":"manhwa"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Mystery","value":"mystery"},{"label":"One shot","value":"one-shot"},{"label":"Psychological","value":"psychological"},{"label":"Reincarnation","value":"reincarnation"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shoujo","value":"shoujo"},{"label":"Shoujo Ai","value":"shoujo-ai"},{"label":"Shounen","value":"shounen"},{"label":"Shounen Ai","value":"shounen-ai"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Soft Yaoi","value":"soft-yaoi"},{"label":"Soft Yuri","value":"soft-yuri"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"},{"label":"Video Games","value":"video-games"},{"label":"Webtoon","value":"webtoon"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"},{"label":"Yaoi","value":"yaoi"},{"label":"Yuri","value":"yuri"}],"value":"","type":FilterTypes.Picker}},"options":{"path":{"novels":"manga","novel":"manga","chapter":"manga","genres":"manga-genre"},"lang":"English"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,152 +0,0 @@
|
||||
import { CheerioAPI, load } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
|
||||
interface WPmangaStreamOptions {
|
||||
reverseChapters?: boolean;
|
||||
lang?: string;
|
||||
}
|
||||
|
||||
export interface WPmangaStreamMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: WPmangaStreamOptions;
|
||||
}
|
||||
|
||||
class WPmangaStreamPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: WPmangaStreamOptions;
|
||||
|
||||
constructor(metadata: WPmangaStreamMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[wpmangastream]";
|
||||
this.icon = `multisrc/wpmangastream/icons/${metadata.id}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
}
|
||||
|
||||
async popularNovels(page: number): Promise<Plugin.NovelItem[]> {
|
||||
const url = this.site + "series/?page=" + page + "&status=&order=popular";
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
const loadedCheerio = load(body);
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio("article.maindet").each(function () {
|
||||
const name = loadedCheerio(this).find("h2").text();
|
||||
const image = loadedCheerio(this).find("img");
|
||||
const url = loadedCheerio(this).find("h2 a").attr("href");
|
||||
|
||||
if (!url) return;
|
||||
novels.push({
|
||||
name,
|
||||
cover: image.attr("data-src") || image.attr("src"),
|
||||
url,
|
||||
});
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
|
||||
async parseNovelAndChapters(url: string): Promise<Plugin.SourceNovel> {
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
const loadedCheerio = load(body);
|
||||
|
||||
const novel: Plugin.SourceNovel = { url };
|
||||
|
||||
// novel.url = url;
|
||||
novel.name = loadedCheerio("h1.entry-title").text();
|
||||
novel.cover =
|
||||
loadedCheerio("img.wp-post-image").attr("data-src") ||
|
||||
loadedCheerio("img.wp-post-image").attr("src");
|
||||
novel.status = loadedCheerio("div.sertostat > span").attr("class");
|
||||
|
||||
loadedCheerio("div.serl > span").each(function () {
|
||||
const detailName = loadedCheerio(this).text().trim();
|
||||
const detail = loadedCheerio(this).next().text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "الكاتب":
|
||||
case "Author":
|
||||
case "Auteur":
|
||||
novel.author = detail;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
novel.genres = loadedCheerio(".sertogenre")
|
||||
.children("a")
|
||||
.map((i, el) => loadedCheerio(el).text())
|
||||
.toArray()
|
||||
.join(",");
|
||||
|
||||
let summary = loadedCheerio(".sersys > p").siblings().remove("div").end();
|
||||
novel.summary = "";
|
||||
for (let i = 0; i < summary.length; i++) {
|
||||
const p = summary[i];
|
||||
novel.summary += loadedCheerio(p).text().trim() + "\\n\\n";
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = loadedCheerio(".eplister li")
|
||||
.map((index, element) => ({
|
||||
name:
|
||||
loadedCheerio(element).find(".epl-num").text() +
|
||||
loadedCheerio(element).find(".epl-title").text(),
|
||||
releaseTime: loadedCheerio(element).find(".epl-date").text().trim(),
|
||||
url: loadedCheerio(element).find("a").attr("href") || "",
|
||||
}))
|
||||
.get()
|
||||
.filter((chapter) => chapter.name && chapter.url);
|
||||
|
||||
if (this.options?.reverseChapters && chapters.length) chapters.reverse();
|
||||
|
||||
novel.chapters = chapters;
|
||||
return novel;
|
||||
}
|
||||
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
const loadedCheerio = load(body);
|
||||
|
||||
const chapterText = loadedCheerio(".epcontent").html() || "";
|
||||
return chapterText;
|
||||
}
|
||||
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
const url = this.site + "?s=" + searchTerm;
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
const loadedCheerio = load(body);
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio("article.maindet").each(function () {
|
||||
const name = loadedCheerio(this).find("h2").text();
|
||||
const image = loadedCheerio(this).find("img");
|
||||
const url = loadedCheerio(this).find("h2 a").attr("href");
|
||||
|
||||
if (!url) return;
|
||||
novels.push({
|
||||
name,
|
||||
cover: image.attr("data-src") || image.attr("src"),
|
||||
url,
|
||||
});
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
|
||||
fetchImage = fetchFile;
|
||||
}
|
||||
|
||||
const plugin = new WPmangaStreamPlugin({"id":"lightnovelfr","sourceSite":"https://lightnovelfr.com/","sourceName":"Ligh Novel FR","options":{"lang":"French","reverseChapters":true}});
|
||||
export default plugin;
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"meionovel","sourceSite":"https://meionovel.id/","sourceName":"MeioNovel","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"GENRES","value":"","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adventure","value":"adventure"},{"label":"Comedy","value":"comedy"},{"label":"Cooking","value":"cooking"},{"label":"Drama","value":"drama"},{"label":"Ecchi","value":"ecchi"},{"label":"Fanfiction","value":"fanfiction"},{"label":"Fantasy","value":"fantasy"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Isekai","value":"isekai"},{"label":"Josei","value":"josei"},{"label":"Magic","value":"magic"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Mystery","value":"mystery"},{"label":"One shot","value":"one-shot"},{"label":"Psychological","value":"psychological"},{"label":"Reverse Harem","value":"reverse-harem"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shoujo","value":"shoujo"},{"label":"Shoujo Ai","value":"shoujo-ai"},{"label":"Shounen","value":"shounen"},{"label":"Shounen Ai","value":"shounen-ai"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Smut","value":"smut"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"},{"label":"Virtual Reality","value":"virtual-reality"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"},{"label":"Yuri","value":"yuri"}],"type":FilterTypes.Picker}},"options":{"useNewChapterEndpoint":true,"lang":"Indonesian"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"morenovel","sourceSite":"https://morenovel.net/","sourceName":"MoreNovel","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"GENRES","value":"","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adventure","value":"adventure"},{"label":"Comedy","value":"comedy"},{"label":"Drama","value":"drama"},{"label":"Ecchi","value":"ecchi"},{"label":"Fantasy","value":"fantasy"},{"label":"Gender Bender","value":"gender-bender"},{"label":"Harem","value":"harem"},{"label":"Historical","value":"historical"},{"label":"Horror","value":"horror"},{"label":"Josei","value":"josei"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Mystery","value":"mystery"},{"label":"Psychological","value":"psychological"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shoujo","value":"shoujo"},{"label":"Shoujo Ai","value":"shoujo-ai"},{"label":"Shounen","value":"shounen"},{"label":"Shounen Ai","value":"shounen-ai"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"},{"label":"Yaoi","value":"yaoi"},{"label":"Yuri","value":"yuri"}],"type":FilterTypes.Picker}},"options":{"useNewChapterEndpoint":true,"lang":"Indonesian"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"wbnovel","sourceSite":"https://wbnovel.com/","sourceName":"WBNovel","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker},"genres":{"label":"GENRES","value":"","options":[{"label":"NONE","value":""},{"label":"Action","value":"action"},{"label":"Adventure","value":"adventure"},{"label":"Alchemy","value":"alchemy"},{"label":"Comedy","value":"comedy"},{"label":"Crafting","value":"crafting"},{"label":"Cultivation","value":"cultivation"},{"label":"Drama","value":"drama"},{"label":"Dungeon Crawling","value":"dungeon-crawling"},{"label":"Eci","value":"eci"},{"label":"Fantasy","value":"fantasy"},{"label":"Game","value":"game"},{"label":"Harem","value":"harem"},{"label":"Horror","value":"horror"},{"label":"Josei","value":"josei"},{"label":"Kingdom Building","value":"kingdom-building"},{"label":"Martial Arts","value":"martial-arts"},{"label":"Mature","value":"mature"},{"label":"Mecha","value":"mecha"},{"label":"Modern Setting","value":"modern-setting"},{"label":"Mystery","value":"mystery"},{"label":"Pets","value":"pets"},{"label":"Psychological","value":"psychological"},{"label":"Reincarnator","value":"reincarnator"},{"label":"Romance","value":"romance"},{"label":"School Life","value":"school-life"},{"label":"Sci-fi","value":"sci-fi"},{"label":"Seinen","value":"seinen"},{"label":"Shounen","value":"shounen"},{"label":"Slice of Life","value":"slice-of-life"},{"label":"Sports","value":"sports"},{"label":"Supernatural","value":"supernatural"},{"label":"Tragedy","value":"tragedy"},{"label":"Transmigration","value":"transmigration"},{"label":"Virtual Reality","value":"virtual-reality"},{"label":"Wuxia","value":"wuxia"},{"label":"Xianxia","value":"xianxia"},{"label":"Xuanhuan","value":"xuanhuan"}],"type":FilterTypes.Picker}},"options":{"lang":"Indonesian"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,167 +0,0 @@
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
// import { defaultCover } from "@libs/defaultCover";
|
||||
|
||||
export interface IfreedomMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
filters?: Filters;
|
||||
}
|
||||
|
||||
class IfreedomPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
filters?: Filters;
|
||||
|
||||
constructor(metadata: IfreedomMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[ifreedom]";
|
||||
this.icon = `multisrc/ifreedom/icons/${metadata.id}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
|
||||
async popularNovels(
|
||||
page: number,
|
||||
{ filters, showLatestNovels }: Plugin.PopularNovelsOptions,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let url = this.site + "/vse-knigi/?sort=" +
|
||||
(showLatestNovels ? "По дате обновления" : filters?.sort?.value || "По рейтингу");
|
||||
|
||||
if (filters?.status?.value instanceof Array) {
|
||||
url += filters.status.value.map((i) => "&status[]=" + i).join("");
|
||||
}
|
||||
if (filters?.lang?.value instanceof Array) {
|
||||
url += filters.lang.value.map((i) => "&lang[]=" + i).join("");
|
||||
}
|
||||
if (filters?.genre?.value instanceof Array) {
|
||||
url += filters.genre.value.map((i) => "&genre[]=" + i).join("");
|
||||
}
|
||||
url += "&bpage=" + page;
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novels: Plugin.NovelItem[] = loadedCheerio(
|
||||
"div.one-book-home > div.img-home a",
|
||||
)
|
||||
.map((index, element) => ({
|
||||
name: loadedCheerio(element).attr("title") || "",
|
||||
cover: loadedCheerio(element).find("img").attr("src"),
|
||||
url: loadedCheerio(element).attr("href") || "",
|
||||
}))
|
||||
.get()
|
||||
.filter((novel) => novel.name && novel.url);
|
||||
|
||||
return novels;
|
||||
}
|
||||
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
name: loadedCheerio(".entry-title").text(),
|
||||
cover: loadedCheerio(".img-ranobe > img").attr("src"),
|
||||
summary: loadedCheerio('meta[name="description"]').attr("content"),
|
||||
};
|
||||
|
||||
loadedCheerio("div.data-ranobe").each(function () {
|
||||
switch (loadedCheerio(this).find("b").text()) {
|
||||
case "Автор":
|
||||
novel.author = loadedCheerio(this)
|
||||
.find("div.data-value")
|
||||
.text()
|
||||
.trim();
|
||||
break;
|
||||
case "Жанры":
|
||||
novel.genres = loadedCheerio("div.data-value > a")
|
||||
.map((index, element) => loadedCheerio(element).text()?.trim())
|
||||
.get()
|
||||
.join(",");
|
||||
break;
|
||||
case "Статус книги":
|
||||
novel.status = loadedCheerio("div.data-value")
|
||||
.text()
|
||||
.includes("активен")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
if (novel.author == "Не указан") delete novel.author;
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio("div.li-ranobe").each(function () {
|
||||
const name = loadedCheerio(this).find("a").text();
|
||||
const url = loadedCheerio(this).find("a").attr("href");
|
||||
if (!loadedCheerio(this).find("label.buy-ranobe").length && name && url) {
|
||||
const releaseTime = loadedCheerio(this)
|
||||
.find("div.li-col2-ranobe").text().trim();
|
||||
|
||||
chapters.push({ name, releaseTime, url });
|
||||
}
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".entry-content img").each(function () {
|
||||
const srcset = loadedCheerio(this).attr("srcset")?.split?.(" ");
|
||||
if (srcset?.length) {
|
||||
const bestlink = srcset.filter((url) => url.startsWith("http")).unshift();
|
||||
if (typeof bestlink == 'string') loadedCheerio(this).attr("src", bestlink);
|
||||
}
|
||||
});
|
||||
|
||||
const chapterText = loadedCheerio(".entry-content").html() || "";
|
||||
return chapterText;
|
||||
}
|
||||
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
page: number | undefined = 1,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const url =
|
||||
this.site + "/vse-knigi/?searchname=" + searchTerm + "&bpage=" + page;
|
||||
const result = await fetchApi(url).then((res) => res.text());
|
||||
const loadedCheerio = parseHTML(result);
|
||||
|
||||
const novels: Plugin.NovelItem[] = loadedCheerio(
|
||||
"div.one-book-home > div.img-home a",
|
||||
)
|
||||
.map((index, element) => ({
|
||||
name: loadedCheerio(element).attr("title") || "",
|
||||
cover: loadedCheerio(element).find("img").attr("src"),
|
||||
url: loadedCheerio(element).attr("href") || "",
|
||||
}))
|
||||
.get()
|
||||
.filter((novel) => novel.name && novel.url);
|
||||
|
||||
return novels;
|
||||
}
|
||||
|
||||
fetchImage = fetchFile;
|
||||
}
|
||||
|
||||
const plugin = new IfreedomPlugin({"id":"bookhamster","sourceSite":"https://bookhamster.ru","sourceName":"Bookhamster","filters":{"sort":{"type":FilterTypes.Picker,"label":"Сортировка:","options":[{"label":"По дате добавления","value":"По дате добавления"},{"label":"По дате обновления","value":"По дате обновления"},{"label":"По количеству глав","value":"По количеству глав"},{"label":"По названию","value":"По названию"},{"label":"По просмотрам","value":"По просмотрам"},{"label":"По рейтингу","value":"По рейтингу"}],"value":"По рейтингу"},"status":{"type":FilterTypes.CheckboxGroup,"label":"Статус:","options":[{"label":"Перевод активен","value":"Перевод активен"},{"label":"Перевод приостановлен","value":"Перевод приостановлен"},{"label":"Произведение завершено","value":"Произведение завершено"}],"value":[]},"lang":{"type":FilterTypes.CheckboxGroup,"label":"Язык:","options":[{"label":"Английский","value":"Английский"},{"label":"Китайский","value":"Китайский"},{"label":"Корейский","value":"Корейский"},{"label":"Японский","value":"Японский"}],"value":[]},"genre":{"type":FilterTypes.CheckboxGroup,"label":"Жанры:","options":[{"label":"Боевик","value":"Боевик"},{"label":"Боевые Искусства","value":"Боевые Искусства"},{"label":"Вампиры","value":"Вампиры"},{"label":"Виртуальный Мир","value":"Виртуальный Мир"},{"label":"Гарем","value":"Гарем"},{"label":"Героическое фэнтези","value":"Героическое фэнтези"},{"label":"Детектив","value":"Детектив"},{"label":"Дзёсэй","value":"Дзёсэй"},{"label":"Драма","value":"Драма"},{"label":"Игра","value":"Игра"},{"label":"История","value":"История"},{"label":"Киберпанк","value":"Киберпанк"},{"label":"Комедия","value":"Комедия"},{"label":"ЛитРПГ","value":"ЛитРПГ"},{"label":"Меха","value":"Меха"},{"label":"Милитари","value":"Милитари"},{"label":"Мистика","value":"Мистика"},{"label":"Научная Фантастика","value":"Научная Фантастика"},{"label":"Повседневность","value":"Повседневность"},{"label":"Постапокалипсис","value":"Постапокалипсис"},{"label":"Приключения","value":"Приключения"},{"label":"Психология","value":"Психология"},{"label":"Романтика","value":"Романтика"},{"label":"Сверхъестественное","value":"Сверхъестественное"},{"label":"Сёдзё","value":"Сёдзё"},{"label":"Сёнэн","value":"Сёнэн"},{"label":"Сёнэн-ай","value":"Сёнэн-ай"},{"label":"Спорт","value":"Спорт"},{"label":"Сэйнэн","value":"Сэйнэн"},{"label":"Сюаньхуа","value":"Сюаньхуа"},{"label":"Трагедия","value":"Трагедия"},{"label":"Триллер","value":"Триллер"},{"label":"Ужасы","value":"Ужасы"},{"label":"Фантастика","value":"Фантастика"},{"label":"Фэнтези","value":"Фэнтези"},{"label":"Школьная жизнь","value":"Школьная жизнь"},{"label":"Экшн","value":"Экшн"},{"label":"Эротика","value":"Эротика"},{"label":"Этти","value":"Этти"},{"label":"Яой","value":"Яой"},{"label":"Adult","value":"Adult"},{"label":"Mature","value":"Mature"},{"label":"Xianxia","value":"Xianxia"},{"label":"Xuanhuan","value":"Xuanhuan"}],"value":[]}}});
|
||||
export default plugin;
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,167 +0,0 @@
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
// import { defaultCover } from "@libs/defaultCover";
|
||||
|
||||
export interface IfreedomMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
filters?: Filters;
|
||||
}
|
||||
|
||||
class IfreedomPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
filters?: Filters;
|
||||
|
||||
constructor(metadata: IfreedomMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[ifreedom]";
|
||||
this.icon = `multisrc/ifreedom/icons/${metadata.id}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
|
||||
async popularNovels(
|
||||
page: number,
|
||||
{ filters, showLatestNovels }: Plugin.PopularNovelsOptions,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let url = this.site + "/vse-knigi/?sort=" +
|
||||
(showLatestNovels ? "По дате обновления" : filters?.sort?.value || "По рейтингу");
|
||||
|
||||
if (filters?.status?.value instanceof Array) {
|
||||
url += filters.status.value.map((i) => "&status[]=" + i).join("");
|
||||
}
|
||||
if (filters?.lang?.value instanceof Array) {
|
||||
url += filters.lang.value.map((i) => "&lang[]=" + i).join("");
|
||||
}
|
||||
if (filters?.genre?.value instanceof Array) {
|
||||
url += filters.genre.value.map((i) => "&genre[]=" + i).join("");
|
||||
}
|
||||
url += "&bpage=" + page;
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novels: Plugin.NovelItem[] = loadedCheerio(
|
||||
"div.one-book-home > div.img-home a",
|
||||
)
|
||||
.map((index, element) => ({
|
||||
name: loadedCheerio(element).attr("title") || "",
|
||||
cover: loadedCheerio(element).find("img").attr("src"),
|
||||
url: loadedCheerio(element).attr("href") || "",
|
||||
}))
|
||||
.get()
|
||||
.filter((novel) => novel.name && novel.url);
|
||||
|
||||
return novels;
|
||||
}
|
||||
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
name: loadedCheerio(".entry-title").text(),
|
||||
cover: loadedCheerio(".img-ranobe > img").attr("src"),
|
||||
summary: loadedCheerio('meta[name="description"]').attr("content"),
|
||||
};
|
||||
|
||||
loadedCheerio("div.data-ranobe").each(function () {
|
||||
switch (loadedCheerio(this).find("b").text()) {
|
||||
case "Автор":
|
||||
novel.author = loadedCheerio(this)
|
||||
.find("div.data-value")
|
||||
.text()
|
||||
.trim();
|
||||
break;
|
||||
case "Жанры":
|
||||
novel.genres = loadedCheerio("div.data-value > a")
|
||||
.map((index, element) => loadedCheerio(element).text()?.trim())
|
||||
.get()
|
||||
.join(",");
|
||||
break;
|
||||
case "Статус книги":
|
||||
novel.status = loadedCheerio("div.data-value")
|
||||
.text()
|
||||
.includes("активен")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
if (novel.author == "Не указан") delete novel.author;
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio("div.li-ranobe").each(function () {
|
||||
const name = loadedCheerio(this).find("a").text();
|
||||
const url = loadedCheerio(this).find("a").attr("href");
|
||||
if (!loadedCheerio(this).find("label.buy-ranobe").length && name && url) {
|
||||
const releaseTime = loadedCheerio(this)
|
||||
.find("div.li-col2-ranobe").text().trim();
|
||||
|
||||
chapters.push({ name, releaseTime, url });
|
||||
}
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".entry-content img").each(function () {
|
||||
const srcset = loadedCheerio(this).attr("srcset")?.split?.(" ");
|
||||
if (srcset?.length) {
|
||||
const bestlink = srcset.filter((url) => url.startsWith("http")).unshift();
|
||||
if (typeof bestlink == 'string') loadedCheerio(this).attr("src", bestlink);
|
||||
}
|
||||
});
|
||||
|
||||
const chapterText = loadedCheerio(".entry-content").html() || "";
|
||||
return chapterText;
|
||||
}
|
||||
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
page: number | undefined = 1,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const url =
|
||||
this.site + "/vse-knigi/?searchname=" + searchTerm + "&bpage=" + page;
|
||||
const result = await fetchApi(url).then((res) => res.text());
|
||||
const loadedCheerio = parseHTML(result);
|
||||
|
||||
const novels: Plugin.NovelItem[] = loadedCheerio(
|
||||
"div.one-book-home > div.img-home a",
|
||||
)
|
||||
.map((index, element) => ({
|
||||
name: loadedCheerio(element).attr("title") || "",
|
||||
cover: loadedCheerio(element).find("img").attr("src"),
|
||||
url: loadedCheerio(element).attr("href") || "",
|
||||
}))
|
||||
.get()
|
||||
.filter((novel) => novel.name && novel.url);
|
||||
|
||||
return novels;
|
||||
}
|
||||
|
||||
fetchImage = fetchFile;
|
||||
}
|
||||
|
||||
const plugin = new IfreedomPlugin({"id":"ifreedom","sourceSite":"https://ifreedom.su","sourceName":"Свободный Мир Ранобэ","filters":{"sort":{"type":FilterTypes.Picker,"label":"Сортировка:","options":[{"label":"По дате добавления","value":"По дате добавления"},{"label":"По дате обновления","value":"По дате обновления"},{"label":"По количеству глав","value":"По количеству глав"},{"label":"По названию","value":"По названию"},{"label":"По просмотрам","value":"По просмотрам"},{"label":"По рейтингу","value":"По рейтингу"}],"value":"По рейтингу"},"status":{"type":FilterTypes.CheckboxGroup,"label":"Статус:","options":[{"label":"Перевод активен","value":"Перевод активен"},{"label":"Перевод приостановлен","value":"Перевод приостановлен"},{"label":"Произведение завершено","value":"Произведение завершено"}],"value":[]},"lang":{"type":FilterTypes.CheckboxGroup,"label":"Язык:","options":[{"label":"Английский","value":"Английский"},{"label":"Китайский","value":"Китайский"},{"label":"Корейский","value":"Корейский"},{"label":"Японский","value":"Японский"}],"value":[]},"genre":{"type":FilterTypes.CheckboxGroup,"label":"Жанры:","options":[{"label":"Боевик","value":"Боевик"},{"label":"Боевые Искусства","value":"Боевые Искусства"},{"label":"Вампиры","value":"Вампиры"},{"label":"Виртуальный Мир","value":"Виртуальный Мир"},{"label":"Гарем","value":"Гарем"},{"label":"Героическое фэнтези","value":"Героическое фэнтези"},{"label":"Детектив","value":"Детектив"},{"label":"Дзёсэй","value":"Дзёсэй"},{"label":"Драма","value":"Драма"},{"label":"Игра","value":"Игра"},{"label":"История","value":"История"},{"label":"Киберпанк","value":"Киберпанк"},{"label":"Комедия","value":"Комедия"},{"label":"ЛитРПГ","value":"ЛитРПГ"},{"label":"Меха","value":"Меха"},{"label":"Милитари","value":"Милитари"},{"label":"Мистика","value":"Мистика"},{"label":"Научная Фантастика","value":"Научная Фантастика"},{"label":"Повседневность","value":"Повседневность"},{"label":"Постапокалипсис","value":"Постапокалипсис"},{"label":"Приключения","value":"Приключения"},{"label":"Психология","value":"Психология"},{"label":"Романтика","value":"Романтика"},{"label":"Сверхъестественное","value":"Сверхъестественное"},{"label":"Сёдзё","value":"Сёдзё"},{"label":"Сёнэн","value":"Сёнэн"},{"label":"Сёнэн-ай","value":"Сёнэн-ай"},{"label":"Спорт","value":"Спорт"},{"label":"Сэйнэн","value":"Сэйнэн"},{"label":"Сюаньхуа","value":"Сюаньхуа"},{"label":"Трагедия","value":"Трагедия"},{"label":"Триллер","value":"Триллер"},{"label":"Ужасы","value":"Ужасы"},{"label":"Фантастика","value":"Фантастика"},{"label":"Фэнтези","value":"Фэнтези"},{"label":"Школьная жизнь","value":"Школьная жизнь"},{"label":"Экшн","value":"Экшн"},{"label":"Эротика","value":"Эротика"},{"label":"Этти","value":"Этти"},{"label":"Яой","value":"Яой"},{"label":"Adult","value":"Adult"},{"label":"Mature","value":"Mature"},{"label":"Xianxia","value":"Xianxia"},{"label":"Xuanhuan","value":"Xuanhuan"}],"value":[]}}});
|
||||
export default plugin;
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"turkcelightnovels","sourceSite":"https://turkcelightnovels.com/","sourceName":"TurkceLightNovels","filters":{"sort":{"label":"Order by","value":"","options":[{"label":"Default","value":""},{"label":"Rating","value":"rating"},{"label":"A-Z","value":"alphabet"},{"label":"Latest","value":"latest"},{"label":"Most Views","value":"views"},{"label":"New","value":"new-manga"},{"label":"Trending","value":"trending"}],"type":FilterTypes.Picker}},"options":{"path":{"novels":"light-novel","novel":"light-novel","chapter":"light-novel"},"lang":"Turkish"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Filters, FilterTypes } from "@libs/filterInputs";
|
||||
import { Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
interface MadaraOptionPath {
|
||||
genres?: string;
|
||||
novels?: string;
|
||||
novel?: string;
|
||||
chapter?: string;
|
||||
}
|
||||
|
||||
const MadaraDefaultPath = {
|
||||
genres: "novel-genre",
|
||||
novels: "novel",
|
||||
novel: "novel",
|
||||
chapter: "novel",
|
||||
};
|
||||
|
||||
interface MadaraOptions {
|
||||
useNewChapterEndpoint?: boolean;
|
||||
path?: MadaraOptionPath;
|
||||
lang?: string;
|
||||
orderBy?: string;
|
||||
}
|
||||
|
||||
export interface MadaraMetadata {
|
||||
id: string;
|
||||
sourceSite: string;
|
||||
sourceName: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters;
|
||||
}
|
||||
class MadaraPlugin implements Plugin.PluginBase {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
site: string;
|
||||
version: string;
|
||||
userAgent: string;
|
||||
cookieString: string;
|
||||
options?: MadaraOptions;
|
||||
filters?: Filters | undefined;
|
||||
|
||||
constructor(metadata: MadaraMetadata) {
|
||||
this.id = metadata.id;
|
||||
this.name = metadata.sourceName + "[madara]";
|
||||
const iconFileName = metadata.sourceName
|
||||
.replace(/\s+/g, "")
|
||||
.toLowerCase();
|
||||
this.icon = `multisrc/madara/icons/${iconFileName}.png`;
|
||||
this.site = metadata.sourceSite;
|
||||
this.version = "1.0.0";
|
||||
this.userAgent = "";
|
||||
this.cookieString = "";
|
||||
this.options = metadata.options;
|
||||
this.filters = metadata.filters;
|
||||
}
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{
|
||||
filters,
|
||||
showLatestNovels,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
let url = this.site;
|
||||
if (filters?.genres?.value) {
|
||||
url += (this.options?.path?.genres || MadaraDefaultPath.genres) +
|
||||
"/" +
|
||||
filters.genres.value;
|
||||
} else {
|
||||
url += this.options?.path?.novels || MadaraDefaultPath.novels;
|
||||
}
|
||||
|
||||
url +=
|
||||
"/page/" +
|
||||
pageNo +
|
||||
"/" +
|
||||
"?m_orderby=" +
|
||||
(showLatestNovels ? "latest" : filters?.sort?.value || "rating");
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges").remove();
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel: Plugin.NovelItem = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".manga-title-badges, #manga-title span").remove();
|
||||
novel.name =
|
||||
loadedCheerio(".post-title h1").text().trim() ||
|
||||
loadedCheerio("#manga-title h1").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("data-lazy-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("data-src") ||
|
||||
loadedCheerio(".summary_image > a > img").attr("src") ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio(".post-content_item, .post-content").each(function () {
|
||||
const detailName = loadedCheerio(this).find("h5").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
case "التصنيفات":
|
||||
novel.genres = detail.replace(/[\\t\\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
case "المؤلف":
|
||||
case "المؤلف (ين)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
case "الحالة":
|
||||
novel.status =
|
||||
detail.includes("OnGoing") || detail.includes("مستمرة")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio("div.summary__content .code-block,script").remove();
|
||||
novel.summary =
|
||||
loadedCheerio("div.summary__content").text().trim() ||
|
||||
loadedCheerio("#tab-manga-about").text().trim() ||
|
||||
loadedCheerio('.post-content_item h5:contains("Summary")')
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let html;
|
||||
|
||||
if (this.options?.useNewChapterEndpoint !== true) {
|
||||
const novelId =
|
||||
loadedCheerio(".rating-post-id").attr("value") ||
|
||||
loadedCheerio("#manga-chapters-holder").attr("data-id") ||
|
||||
"";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
html = await fetchApi(this.site + "wp-admin/admin-ajax.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((res) => res.text());
|
||||
} else {
|
||||
html = await fetchApi(novelUrl + "ajax/chapters/", {
|
||||
method: "POST",
|
||||
}).then((res) => res.text());
|
||||
}
|
||||
|
||||
if (html !== "0") {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find("span.chapter-release-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format("LL");
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find("a").attr("href") || "";
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
}
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio(".text-left").html() ||
|
||||
loadedCheerio(".text-right").html() ||
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
"";
|
||||
|
||||
return chapterText;
|
||||
}
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
pageNo?: number | undefined
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
const url = this.site + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
let novelUrl =
|
||||
loadedCheerio(this)
|
||||
.find(".post-title")
|
||||
.find("a")
|
||||
.attr("href") || "";
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
}
|
||||
async fetchImage(url: string): Promise<string | undefined> {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
}
|
||||
|
||||
const plugin = new MadaraPlugin({"id":"webnoveloku","sourceSite":"https://www.webnoveloku.com/","sourceName":"WebNovelOku ","filters":{"sort":{"label":"Sırala","value":"","options":[{"label":"Default","value":""},{"label":"A-Z","value":"alphabet"},{"label":"En Son","value":"latest"},{"label":"Görüntülenme","value":"views"},{"label":"Popülarite","value":"trending"},{"label":"Reyting","value":"rating"},{"label":"Yeni","value":"new-manga"}],"type":FilterTypes.Picker}},"options":{"lang":"Turkish"}});
|
||||
export default plugin;
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import * as path from 'path'
|
||||
import * as fs from 'fs'
|
||||
|
||||
const pluginDir = 'plugins'
|
||||
fs.readdirSync(pluginDir).forEach(lang => {
|
||||
for (let pluginDir of ['plugins', path.join('.js', 'plugins')]){
|
||||
if(fs.existsSync(pluginDir)){
|
||||
fs.readdirSync(pluginDir).forEach(lang => {
|
||||
const langDir = path.join(pluginDir, lang);
|
||||
fs.readdirSync(langDir).forEach(plugin => {
|
||||
if(plugin.endsWith('.ts') && plugin.includes("[")){
|
||||
if(plugin.includes("[") && plugin.includes("]")){
|
||||
fs.unlinkSync(path.join(langDir, plugin));
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ const run = async () => {
|
||||
const success = await generate(name);
|
||||
if (success) console.log(`[${name}] OK`);
|
||||
}
|
||||
console.log('Generating: .js files');
|
||||
};
|
||||
|
||||
run();
|
||||
|
||||
Reference in New Issue
Block a user