Add Icons

This commit is contained in:
Rajarshee Chatterjee
2021-07-23 09:06:10 +05:30
parent 0a7d1d274a
commit b27346e211
4 changed files with 839 additions and 839 deletions
Executable → Regular
+74 -74
View File
@@ -1,74 +1,74 @@
const express = require("express"); const express = require("express");
const sources = require("./sources"); const sources = require("./sources");
const app = express(); const app = express();
app.use( app.use(
express.json({ express.json({
extended: false, extended: false,
}) })
); );
app.get("/", (req, res) => app.get("/", (req, res) =>
res.json({ res.json({
Author: "@rajarsheechatterjee", Author: "@rajarsheechatterjee",
Version: "1.0.0", Version: "1.0.0",
Github: "https://github.com/rajarsheechatterjee/lnreader-extensions", Github: "https://github.com/rajarsheechatterjee/lnreader-extensions",
}) })
); );
// English // English
app.get("/api/", (req, res) => res.json(sources)); app.get("/api/", (req, res) => res.json(sources));
app.use("/api/1/", require("./src/en/boxnovel/BoxNovel")); app.use("/api/1/", require("./src/en/boxnovel/BoxNovel"));
app.use("/api/2/", require("./src/en/readlightnovel/ReadLightNovel")); app.use("/api/2/", require("./src/en/readlightnovel/ReadLightNovel"));
app.use("/api/3/", require("./src/en/fastnovel/FastNovel")); app.use("/api/3/", require("./src/en/fastnovel/FastNovel"));
app.use("/api/4/", require("./src/en/readnovelfull/ReadNovelFull")); app.use("/api/4/", require("./src/en/readnovelfull/ReadNovelFull"));
app.use("/api/5/", require("./src/en/mtlnovel/MTLNovel")); app.use("/api/5/", require("./src/en/mtlnovel/MTLNovel"));
app.use("/api/6/", require("./src/en/novelhall/Novelhall")); app.use("/api/6/", require("./src/en/novelhall/Novelhall"));
app.use("/api/7/", require("./src/en/wuxiaworld/WuxiaWorld")); app.use("/api/7/", require("./src/en/wuxiaworld/WuxiaWorld"));
app.use("/api/8/", require("./src/en/novelfull/NovelFull")); app.use("/api/8/", require("./src/en/novelfull/NovelFull"));
app.use("/api/9/", require("./src/en/noveltrench/NovelTrench")); app.use("/api/9/", require("./src/en/noveltrench/NovelTrench"));
app.use("/api/10/", require("./src/en/vipnovel/VipNovel")); app.use("/api/10/", require("./src/en/vipnovel/VipNovel"));
app.use("/api/11/", require("./src/en/kisslightnovels/KissLightNovels")); app.use("/api/11/", require("./src/en/kisslightnovels/KissLightNovels"));
app.use("/api/12/", require("./src/en/wuxiaworldsite/WuxiaWorldSite")); app.use("/api/12/", require("./src/en/wuxiaworldsite/WuxiaWorldSite"));
app.use("/api/13/", require("./src/en/freewebnovel/FreeWebNovel")); app.use("/api/13/", require("./src/en/freewebnovel/FreeWebNovel"));
app.use("/api/14/", require("./src/en/jpmtl/JPMTL")); app.use("/api/14/", require("./src/en/jpmtl/JPMTL"));
app.use("/api/15/", require("./src/en/lightnovelpub/LightNovelPub")); app.use("/api/15/", require("./src/en/lightnovelpub/LightNovelPub"));
app.use("/api/16/", require("./src/en/wuxiaworldco/WuxiaWorldCo")); app.use("/api/16/", require("./src/en/wuxiaworldco/WuxiaWorldCo"));
app.use("/api/17/", require("./src/en/tapread/TapRead")); app.use("/api/17/", require("./src/en/tapread/TapRead"));
app.use("/api/18/", require("./src/en/novelupdatescc/NovelUpdatesCc")); app.use("/api/18/", require("./src/en/novelupdatescc/NovelUpdatesCc"));
app.use("/api/19/", require("./src/en/readlightnovelcc/ReadLightNovelCc")); app.use("/api/19/", require("./src/en/readlightnovelcc/ReadLightNovelCc"));
app.use("/api/20/", require("./src/en/wuxiaworldcloud/WuxiaWorldCloud")); app.use("/api/20/", require("./src/en/wuxiaworldcloud/WuxiaWorldCloud"));
app.use("/api/21/", require("./src/en/woopread/WoopRead")); app.use("/api/21/", require("./src/en/woopread/WoopRead"));
app.use("/api/22/", require("./src/en/foxaholic/Foxaholic")); app.use("/api/22/", require("./src/en/foxaholic/Foxaholic"));
app.use("/api/27/", require("./src/en/comrademao/ComradeMao")); app.use("/api/27/", require("./src/en/comrademao/ComradeMao"));
app.use("/api/33/", require("./src/en/novelpassion/NovelPassion")); app.use("/api/33/", require("./src/en/novelpassion/NovelPassion"));
app.use("/api/34/", require("./src/en/royalroad/RoyalRoad")); app.use("/api/34/", require("./src/en/royalroad/RoyalRoad"));
app.use("/api/35/", require("./src/en/scribblehub/ScribbleHub")); app.use("/api/35/", require("./src/en/scribblehub/ScribbleHub"));
app.use("/api/37/", require("./src/en/lnmtl/LNMTL")); app.use("/api/37/", require("./src/en/lnmtl/LNMTL"));
app.use("/api/48/", require("./src/en/wuxiablog/WuxiaBlog")); app.use("/api/48/", require("./src/en/wuxiablog/WuxiaBlog"));
app.use("/api/49/", require("./src/en/wuxiacity/WuxiaCity")); app.use("/api/49/", require("./src/en/wuxiacity/WuxiaCity"));
// Spanish // Spanish
app.use("/api/23/", require("./src/es/tunovelaligera/Tunovelaligera")); app.use("/api/23/", require("./src/es/tunovelaligera/Tunovelaligera"));
app.use("/api/24/", require("./src/es/skynovels/Skynovels")); app.use("/api/24/", require("./src/es/skynovels/Skynovels"));
app.use("/api/25/", require("./src/es/einherjarproject/EinherjarProject")); app.use("/api/25/", require("./src/es/einherjarproject/EinherjarProject"));
app.use("/api/26/", require("./src/es/novelasligera/NovelasLigera")); app.use("/api/26/", require("./src/es/novelasligera/NovelasLigera"));
app.use("/api/28/", require("./src/es/yuukitls/YuukiTls")); app.use("/api/28/", require("./src/es/yuukitls/YuukiTls"));
app.use("/api/29/", require("./src/es/hasutl/Hasutl")); app.use("/api/29/", require("./src/es/hasutl/Hasutl"));
app.use("/api/30/", require("./src/es/oasistranslations/OasisTranslations")); app.use("/api/30/", require("./src/es/oasistranslations/OasisTranslations"));
app.use("/api/31/", require("./src/es/novelawuxia/NovelaWuxia")); app.use("/api/31/", require("./src/es/novelawuxia/NovelaWuxia"));
// Japanese // Japanese
app.use("/api/36", require("./src/jp/syosetu/Syosetu")); app.use("/api/36", require("./src/jp/syosetu/Syosetu"));
// Chinese // Chinese
app.use("/api/50/", require("./src/ch/yushubo/Yushubo")); app.use("/api/50/", require("./src/ch/yushubo/Yushubo"));
// MultiSrc // MultiSrc
app.use("/api/", require("./multisrc/madara/MadaraGenerator")); app.use("/api/", require("./multisrc/madara/MadaraGenerator"));
app.use("/api/", require("./multisrc/wpmangastream/WPMangaStreamGenerator")); app.use("/api/", require("./multisrc/wpmangastream/WPMangaStreamGenerator"));
const PORT = process.env.PORT || 5000; const PORT = process.env.PORT || 5000;
app.listen(PORT, () => console.log(`Server started on port ${PORT}`)); app.listen(PORT, () => console.log(`Server started on port ${PORT}`));
Executable → Regular
+471 -471
View File
@@ -1,471 +1,471 @@
extensions = [ extensions = [
/** /**
* English * English
*/ */
{ {
sourceId: 1, sourceId: 1,
sourceUrl: "https://boxnovel.com/", sourceUrl: "https://boxnovel.com/",
sourceName: "BoxNovel", sourceName: "BoxNovel",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/boxnovel/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/boxnovel/icon.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 2, sourceId: 2,
sourceUrl: "https://www.readlightnovel.org/", sourceUrl: "https://www.readlightnovel.org/",
sourceName: "ReadLightNovel", sourceName: "ReadLightNovel",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/readlightnovel/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/readlightnovel/icon.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 3, sourceId: 3,
sourceUrl: "https://fastnovel.net/", sourceUrl: "https://fastnovel.net/",
sourceName: "FastNovel", sourceName: "FastNovel",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/fastnovel/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/fastnovel/icon.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 0, status: 0,
}, },
{ {
sourceId: 4, sourceId: 4,
sourceUrl: "https://readnovelfull.com/", sourceUrl: "https://readnovelfull.com/",
sourceName: "ReadNovelFull", sourceName: "ReadNovelFull",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/readnovelfull/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/readnovelfull/icon.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 5, sourceId: 5,
sourceUrl: "https://www.mtlnovel.com/", sourceUrl: "https://www.mtlnovel.com/",
sourceName: "MTLNovel", sourceName: "MTLNovel",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/mtlnovel/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/mtlnovel/icon.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 6, sourceId: 6,
sourceUrl: "https://www.novelhall.com/", sourceUrl: "https://www.novelhall.com/",
sourceName: "NovelHall", sourceName: "NovelHall",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/novelhall/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/novelhall/icon.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 7, sourceId: 7,
sourceUrl: "https://www.wuxiaworld.com/", sourceUrl: "https://www.wuxiaworld.com/",
sourceName: "WuxiaWorld", sourceName: "WuxiaWorld",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/wuxiaworld/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/wuxiaworld/icon.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 8, sourceId: 8,
sourceUrl: "https://novelfull.com/", sourceUrl: "https://novelfull.com/",
sourceName: "NovelFull", sourceName: "NovelFull",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/novelfull/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/novelfull/icon.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 9, sourceId: 9,
sourceUrl: "https://noveltrench.com/", sourceUrl: "https://noveltrench.com/",
sourceName: "NovelTrench", sourceName: "NovelTrench",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/noveltrench/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/noveltrench/icon.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 10, sourceId: 10,
sourceUrl: "https://vipnovel.com/", sourceUrl: "https://vipnovel.com/",
sourceName: "VipNovel", sourceName: "VipNovel",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/vipnovel/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/vipnovel/icon.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 11, sourceId: 11,
sourceUrl: "https://kisslightnovels.info/", sourceUrl: "https://kisslightnovels.info/",
sourceName: "KissLightNovels", sourceName: "KissLightNovels",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/kisslightnovels/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/kisslightnovels/icon.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 12, sourceId: 12,
sourceUrl: "https://wuxiaworldsite.co/", sourceUrl: "https://wuxiaworldsite.co/",
sourceName: "WuxiaWorldSite", sourceName: "WuxiaWorldSite",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/wuxiaworldsite/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/wuxiaworldsite/icon.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 13, sourceId: 13,
sourceUrl: "https://freewebnovel.com/", sourceUrl: "https://freewebnovel.com/",
sourceName: "FreeWebNovel", sourceName: "FreeWebNovel",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/freewebnovel/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/freewebnovel/icon.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 14, sourceId: 14,
sourceUrl: "https://jpmtl.com/", sourceUrl: "https://jpmtl.com/",
sourceName: "JPMTL", sourceName: "JPMTL",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/jpmtl/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/jpmtl/icon.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 15, sourceId: 15,
sourceUrl: "https://www.lightnovelpub.com/", sourceUrl: "https://www.lightnovelpub.com/",
sourceName: "LightNovelPub", sourceName: "LightNovelPub",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/lightnovelpub/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/lightnovelpub/icon.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 16, sourceId: 16,
sourceUrl: "https://www.wuxiaworld.co/", sourceUrl: "https://www.wuxiaworld.co/",
sourceName: "WuxiaWorld.co", sourceName: "WuxiaWorld.co",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/wuxiaworldco/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/wuxiaworldco/icon.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 17, sourceId: 17,
sourceUrl: "http://www.tapread.com/", sourceUrl: "http://www.tapread.com/",
sourceName: "TapRead", sourceName: "TapRead",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/tapread/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/tapread/icon.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 18, sourceId: 18,
sourceUrl: "https://www.novelupdates.cc/", sourceUrl: "https://www.novelupdates.cc/",
sourceName: "NovelUpdates.cc", sourceName: "NovelUpdates.cc",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/novelupdatescc/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/novelupdatescc/icon.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 19, sourceId: 19,
sourceUrl: "https://m.readlightnovel.cc/", sourceUrl: "https://m.readlightnovel.cc/",
sourceName: "ReadLightNovel.cc", sourceName: "ReadLightNovel.cc",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/readlightnovelcc/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/readlightnovelcc/icon.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 20, sourceId: 20,
sourceUrl: "http://wuxiaworld.cloud/", sourceUrl: "http://wuxiaworld.cloud/",
sourceName: "WuxiaWorld.cloud", sourceName: "WuxiaWorld.cloud",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/wuxiaworldcloud/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/wuxiaworldcloud/icon.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 21, sourceId: 21,
sourceUrl: "https://woopread.com/", sourceUrl: "https://woopread.com/",
sourceName: "WoopRead", sourceName: "WoopRead",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/woopread/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/woopread/icon.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 22, sourceId: 22,
sourceUrl: "https://foxaholic.com/", sourceUrl: "https://foxaholic.com/",
sourceName: "Foxaholic", sourceName: "Foxaholic",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/foxaholic/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/foxaholic/icon.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 27, sourceId: 27,
sourceUrl: "https://comrademao.com/", sourceUrl: "https://comrademao.com/",
sourceName: "ComradeMao", sourceName: "ComradeMao",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/comrademao/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/comrademao/icon.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 33, sourceId: 33,
sourceUrl: "https://www.novelpassion.com/", sourceUrl: "https://www.novelpassion.com/",
sourceName: "NovelPassion", sourceName: "NovelPassion",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/novelpassion/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/novelpassion/icon.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 34, sourceId: 34,
sourceUrl: "https://www.royalroad.com/", sourceUrl: "https://www.royalroad.com/",
sourceName: "Royal Road", sourceName: "Royal Road",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/royalroad/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/royalroad/icon.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 35, sourceId: 35,
sourceUrl: "https://www.scribblehub.com/", sourceUrl: "https://www.scribblehub.com/",
sourceName: "Scribble Hub", sourceName: "Scribble Hub",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/scribblehub/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/scribblehub/icon.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 37, sourceId: 37,
sourceUrl: "https://lnmtl.com/", sourceUrl: "https://lnmtl.com/",
sourceName: "LNMTL", sourceName: "LNMTL",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/lnmtl/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/lnmtl/icon.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 38, sourceId: 38,
sourceUrl: "https://skynovel.org/", sourceUrl: "https://skynovel.org/",
sourceName: "SkyNovel", sourceName: "SkyNovel",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/multisrc/madara/icons/skynovel.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/multisrc/madara/icons/skynovel.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 39, sourceId: 39,
sourceUrl: "https://novelcake.com/", sourceUrl: "https://novelcake.com/",
sourceName: "NovelCake", sourceName: "NovelCake",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/multisrc/madara/icons/novelcake.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/multisrc/madara/icons/novelcake.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 40, sourceId: 40,
sourceUrl: "https://novelsrock.com/", sourceUrl: "https://novelsrock.com/",
sourceName: "NovelsRock", sourceName: "NovelsRock",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/multisrc/madara/icons/novelsrock.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/multisrc/madara/icons/novelsrock.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 41, sourceId: 41,
sourceUrl: "https://zinnovel.com/", sourceUrl: "https://zinnovel.com/",
sourceName: "ZinNovel", sourceName: "ZinNovel",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/multisrc/madara/icons/zinnovel.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/multisrc/madara/icons/zinnovel.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 42, sourceId: 42,
sourceUrl: "https://noveltranslate.com/", sourceUrl: "https://noveltranslate.com/",
sourceName: "NovelTranslate", sourceName: "NovelTranslate",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/multisrc/madara/icons/noveltranslate.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/multisrc/madara/icons/noveltranslate.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 43, sourceId: 43,
sourceUrl: "https://www.lunarletters.com/", sourceUrl: "https://www.lunarletters.com/",
sourceName: "LunarLetters", sourceName: "LunarLetters",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/multisrc/madara/icons/lunarletters.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/multisrc/madara/icons/lunarletters.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 44, sourceId: 44,
sourceUrl: "https://sleepytranslations.com/", sourceUrl: "https://sleepytranslations.com/",
sourceName: "SleepyTranslations", sourceName: "SleepyTranslations",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/multisrc/madara/icons/sleepytranslations.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/multisrc/madara/icons/sleepytranslations.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 45, sourceId: 45,
sourceUrl: "https://freenovel.me/", sourceUrl: "https://freenovel.me/",
sourceName: "FreeNovelMe", sourceName: "FreeNovelMe",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/multisrc/madara/icons/freenovel.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/multisrc/madara/icons/freenovel.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 46, sourceId: 46,
sourceUrl: "https://1stkissnovel.love/", sourceUrl: "https://1stkissnovel.love/",
sourceName: "1stKissNovel", sourceName: "1stKissNovel",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/multisrc/madara/icons/1stkissnovel.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/multisrc/madara/icons/1stkissnovel.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 47, sourceId: 47,
sourceUrl: "https://daonovel.com/", sourceUrl: "https://daonovel.com/",
sourceName: "DaoNovel", sourceName: "DaoNovel",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/multisrc/madara/icons/daonovel.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/multisrc/madara/icons/daonovel.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 48, sourceId: 48,
sourceUrl: "https://www.wuxia.blog/", sourceUrl: "https://www.wuxia.blog/",
sourceName: "Wuxia.Blog", sourceName: "Wuxia.Blog",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/wuxiablog/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/wuxiablog/icon.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
{ {
sourceId: 49, sourceId: 49,
sourceUrl: "https://wuxia.city/", sourceUrl: "https://wuxia.city/",
sourceName: "Wuxia.City", sourceName: "Wuxia.City",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/wuxiacity/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/wuxiacity/icon.png?raw=true",
sourceLanguage: "English", sourceLanguage: "English",
status: 1, status: 1,
}, },
/** /**
* Spanish * Spanish
*/ */
{ {
sourceId: 23, sourceId: 23,
sourceUrl: "https://tunovelaligera.com/", sourceUrl: "https://tunovelaligera.com/",
sourceName: "Tunovelaligera", sourceName: "Tunovelaligera",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/es/tunovelaligera/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/es/tunovelaligera/icon.png?raw=true",
sourceLanguage: "Spanish", sourceLanguage: "Spanish",
status: 1, status: 1,
}, },
{ {
sourceId: 24, sourceId: 24,
sourceUrl: "https://www.skynovels.net/", sourceUrl: "https://www.skynovels.net/",
sourceName: "SkyNovels", sourceName: "SkyNovels",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/es/skynovels/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/es/skynovels/icon.png?raw=true",
sourceLanguage: "Spanish", sourceLanguage: "Spanish",
status: 1, status: 1,
}, },
{ {
sourceId: 25, sourceId: 25,
sourceUrl: "https://einherjarproject.net/", sourceUrl: "https://einherjarproject.net/",
sourceName: "EinherjarProject", sourceName: "EinherjarProject",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/es/einherjarproject/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/es/einherjarproject/icon.png?raw=true",
sourceLanguage: "Spanish", sourceLanguage: "Spanish",
status: 1, status: 1,
}, },
{ {
sourceId: 26, sourceId: 26,
sourceUrl: "https://novelasligera.com/", sourceUrl: "https://novelasligera.com/",
sourceName: "NovelasLigera", sourceName: "NovelasLigera",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/es/novelasligera/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/es/novelasligera/icon.png?raw=true",
sourceLanguage: "Spanish", sourceLanguage: "Spanish",
status: 1, status: 1,
}, },
{ {
sourceId: 28, sourceId: 28,
sourceUrl: "https://yuukitls.com/", sourceUrl: "https://yuukitls.com/",
sourceName: "YuukiTls", sourceName: "YuukiTls",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/es/yuukitls/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/es/yuukitls/icon.png?raw=true",
sourceLanguage: "Spanish", sourceLanguage: "Spanish",
status: 1, status: 1,
}, },
{ {
sourceId: 29, sourceId: 29,
sourceUrl: "https://hasutl.wordpress.com/", sourceUrl: "https://hasutl.wordpress.com/",
sourceName: "Hasu Translations", sourceName: "Hasu Translations",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/es/hasutl/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/es/hasutl/icon.png?raw=true",
sourceLanguage: "Spanish", sourceLanguage: "Spanish",
status: 1, status: 1,
}, },
{ {
sourceId: 30, sourceId: 30,
sourceUrl: "https://oasistranslations.wordpress.com/", sourceUrl: "https://oasistranslations.wordpress.com/",
sourceName: "Oasis Translations", sourceName: "Oasis Translations",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/es/oasistranslations/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/es/oasistranslations/icon.png?raw=true",
sourceLanguage: "Spanish", sourceLanguage: "Spanish",
status: 1, status: 1,
}, },
{ {
sourceId: 31, sourceId: 31,
sourceUrl: "http://www.novelawuxia.com/", sourceUrl: "http://www.novelawuxia.com/",
sourceName: "Novela Wuxia", sourceName: "Novela Wuxia",
sourceCover: sourceCover:
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/es/novelawuxia/icon.png?raw=true", "https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/es/novelawuxia/icon.png?raw=true",
sourceLanguage: "Spanish", sourceLanguage: "Spanish",
status: 1, status: 1,
}, },
/** /**
* Japanese * Japanese
*/ */
{ {
sourceId: 36, sourceId: 36,
sourceUrl: "https://syosetsu.com", sourceUrl: "https://syosetsu.com",
sourceName: "Syosetsu", sourceName: "Syosetsu",
sourceCover: sourceCover:
"https://github.com/skillgg/lnreader-sources/blob/main/src/jp/syosetu/icon.png?raw=true", "https://github.com/skillgg/lnreader-sources/blob/main/src/jp/syosetu/icon.png?raw=true",
sourceLanguage: "Japanese", sourceLanguage: "Japanese",
status: 1, status: 1,
}, },
/** /**
* Arabic * Arabic
*/ */
{ {
sourceId: 53, sourceId: 53,
sourceUrl: "https://kolnovel.com/", sourceUrl: "https://kolnovel.com/",
sourceName: "KolNovel", sourceName: "KolNovel",
sourceCover: sourceCover:
"https://github.com/LNReader/lnreader-sources/blob/main/multisrc/wpmangastream/icons/kolnovel.png?raw=true", "https://github.com/LNReader/lnreader-sources/blob/main/multisrc/wpmangastream/icons/kolnovel.png?raw=true",
sourceLanguage: "Arabic", sourceLanguage: "Arabic",
status: 1, status: 1,
}, },
{ {
sourceId: 54, sourceId: 54,
sourceUrl: "https://rewayat-ar.site/", sourceUrl: "https://rewayat-ar.site/",
sourceName: "Rewayat-Ar", sourceName: "Rewayat-Ar",
sourceCover: sourceCover:
"https://github.com/LNReader/lnreader-sources/blob/main/multisrc/wpmangastream/icons/rewayatar.png?raw=true", "https://github.com/LNReader/lnreader-sources/blob/main/multisrc/wpmangastream/icons/rewayatar.png?raw=true",
sourceLanguage: "Arabic", sourceLanguage: "Arabic",
status: 1, status: 1,
}, },
]; ];
module.exports = extensions; module.exports = extensions;
Executable → Regular
+11 -11
View File
@@ -1,11 +1,11 @@
const express = require("express"); const express = require("express");
const syosetuNovelScrapper = require("./SyosetuScrapper"); const syosetuNovelScrapper = require("./SyosetuScrapper");
const router = express.Router(); const router = express.Router();
router.get("/novels/", syosetuNovelScrapper.novelsScraper); router.get("/novels/", syosetuNovelScrapper.novelsScraper);
router.get("/novel/:novelUrl", syosetuNovelScrapper.novelScraper); router.get("/novel/:novelUrl", syosetuNovelScrapper.novelScraper);
router.get("/novel/:novelUrl/:chapterUrl", syosetuNovelScrapper.chapterScraper); router.get("/novel/:novelUrl/:chapterUrl", syosetuNovelScrapper.chapterScraper);
router.get("/search/", syosetuNovelScrapper.searchScraper); router.get("/search/", syosetuNovelScrapper.searchScraper);
module.exports = router; module.exports = router;
+283 -283
View File
@@ -1,283 +1,283 @@
// scraper and cheerio for scrapping from site // scraper and cheerio for scrapping from site
const { scraper } = require("../../helper"); const { scraper } = require("../../helper");
const cheerio = require("cheerio"); const cheerio = require("cheerio");
const baseUrl = "https://syosetu.com"; // base url for syosetu.com const baseUrl = "https://syosetu.com"; // base url for syosetu.com
// get given page of search (if pagenum is 0 or >100 (max possible on site) see first page) // get given page of search (if pagenum is 0 or >100 (max possible on site) see first page)
const searchUrl = (pagenum, order) => { const searchUrl = (pagenum, order) => {
return `https://yomou.syosetu.com/search.php?order=${order || "hyoka"}${ return `https://yomou.syosetu.com/search.php?order=${order || "hyoka"}${
!isNaN((pagenum = parseInt(pagenum))) // check if pagenum is a number !isNaN((pagenum = parseInt(pagenum))) // check if pagenum is a number
? `&p=${pagenum <= 1 || pagenum > 100 ? "1" : pagenum}` // check if pagenum is between 1 and 100 ? `&p=${pagenum <= 1 || pagenum > 100 ? "1" : pagenum}` // check if pagenum is between 1 and 100
: "" // if isn't don't set ?p : "" // if isn't don't set ?p
}`; }`;
}; };
// get the Syosetu ID of the chapter // get the Syosetu ID of the chapter
const getLastPartOfUrl = (url) => const getLastPartOfUrl = (url) =>
(ex = /.*(?=\/)(.{2,})$/.exec(url)) ? ex[1].replace(/\//g, "") : null; (ex = /.*(?=\/)(.{2,})$/.exec(url)) ? ex[1].replace(/\//g, "") : null;
// get novelUrl from Syosetu ID // get novelUrl from Syosetu ID
const getNovelUrl = (id) => `https://ncode.syosetu.com/${id}`; const getNovelUrl = (id) => `https://ncode.syosetu.com/${id}`;
// get chapterUrl from Syosetu ID and chapter ID // get chapterUrl from Syosetu ID and chapter ID
const getChapterUrl = (id, chn) => const getChapterUrl = (id, chn) =>
`https://ncode.syosetu.com/${id}${chn === "oneshot" ? "" : `/${chn}`}`; `https://ncode.syosetu.com/${id}${chn === "oneshot" ? "" : `/${chn}`}`;
// Because syosetu does not have any covers, I did a replacement for them // Because syosetu does not have any covers, I did a replacement for them
const novelCover = "https://raw.githubusercontent.com/skillgg/lnreader-sources/main/src/jp/syosetu/not_found.png"; const novelCover = "https://raw.githubusercontent.com/skillgg/lnreader-sources/main/src/jp/syosetu/not_found.png";
// ID of this extension // ID of this extension
const extensionId = 36; const extensionId = 36;
// Name of this extension // Name of this extension
const sourceName = "Syosetu"; const sourceName = "Syosetu";
// there are 20 mangas per page // there are 20 mangas per page
// this is number of pages loaded in the first "batch" of loads // this is number of pages loaded in the first "batch" of loads
// TOOD: in-app dynamic loading on scroll // TOOD: in-app dynamic loading on scroll
const maxPageLoad = 3; const maxPageLoad = 3;
const novelsScraper = async (req, res) => { const novelsScraper = async (req, res) => {
// array of all the novels // array of all the novels
let novels = []; let novels = [];
// returns list of novels from given page // returns list of novels from given page
let getNovelsFromPage = async (pagenumber) => { let getNovelsFromPage = async (pagenumber) => {
// load page // load page
console.log(searchUrl(pagenumber)); console.log(searchUrl(pagenumber));
const body = await scraper(searchUrl(pagenumber || null)); const body = await scraper(searchUrl(pagenumber || null));
console.log("Loaded"); console.log("Loaded");
// Cheerio it! // Cheerio it!
const cheerioQuery = cheerio.load(body, { decodeEntities: false }); const cheerioQuery = cheerio.load(body, { decodeEntities: false });
console.log("Parsed"); console.log("Parsed");
let pageNovels = []; let pageNovels = [];
// find class=searchkekka_box // find class=searchkekka_box
cheerioQuery(".searchkekka_box").each(function (i, e) { cheerioQuery(".searchkekka_box").each(function (i, e) {
// get div with link and name // get div with link and name
const novelDIV = cheerioQuery(this).find(".novel_h"); const novelDIV = cheerioQuery(this).find(".novel_h");
// get link element // get link element
const novelA = novelDIV.children()[0]; const novelA = novelDIV.children()[0];
// add new novel to array // add new novel to array
pageNovels.push({ pageNovels.push({
novelName: novelDIV.text(), // get the name novelName: novelDIV.text(), // get the name
novelUrl: getLastPartOfUrl(novelA.attribs.href), // get last part of the link novelUrl: getLastPartOfUrl(novelA.attribs.href), // get last part of the link
extensionId, extensionId,
novelCover, // TODO: IDK what to do about covers... On Syo they don't have them novelCover, // TODO: IDK what to do about covers... On Syo they don't have them
}); });
}); });
console.log("Read"); console.log("Read");
// return all novels from this page // return all novels from this page
return pageNovels; return pageNovels;
}; };
// counter of loaded pages // counter of loaded pages
let pagesLoaded = 0; let pagesLoaded = 0;
do { do {
// always load first one // always load first one
novels.push(...(await getNovelsFromPage(pagesLoaded + 1))); novels.push(...(await getNovelsFromPage(pagesLoaded + 1)));
pagesLoaded++; pagesLoaded++;
console.log("Added"); console.log("Added");
} while (pagesLoaded < maxPageLoad); // check if we should load more } while (pagesLoaded < maxPageLoad); // check if we should load more
/** Use /** Use
* novels.push(...(await getNovelsFromPage(pageNumber))) * novels.push(...(await getNovelsFromPage(pageNumber)))
* if you want to load more * if you want to load more
*/ */
// respond with novels! // respond with novels!
res.json(novels); res.json(novels);
console.log("Finished!"); console.log("Finished!");
}; };
const novelScraper = async (req, res) => { const novelScraper = async (req, res) => {
const novelUrl = getNovelUrl(req.params.novelUrl); const novelUrl = getNovelUrl(req.params.novelUrl);
let chapters = []; let chapters = [];
const body = await scraper(novelUrl); const body = await scraper(novelUrl);
const cheerioQuery = cheerio.load(body, { decodeEntities: false }); const cheerioQuery = cheerio.load(body, { decodeEntities: false });
// create novel object // create novel object
let novel = { let novel = {
extensionId, extensionId,
sourceName, sourceName,
sourceUrl: novelUrl, sourceUrl: novelUrl,
novelUrl: req.params.novelUrl, novelUrl: req.params.novelUrl,
novelName: cheerioQuery(".novel_title").text(), novelName: cheerioQuery(".novel_title").text(),
novelCover, novelCover,
}; };
// Get all the chapters // Get all the chapters
const cqGetChapters = cheerioQuery(".novel_sublist2"); const cqGetChapters = cheerioQuery(".novel_sublist2");
console.log(novelUrl, cqGetChapters.length); console.log(novelUrl, cqGetChapters.length);
if (cqGetChapters.length !== 0) { if (cqGetChapters.length !== 0) {
// has more than 1 chapter // has more than 1 chapter
novel.novelSummary = cheerioQuery("#novel_ex") novel.novelSummary = cheerioQuery("#novel_ex")
.text() .text()
.replace(/<\s*br.*?>/g, "\n"); .replace(/<\s*br.*?>/g, "\n");
cqGetChapters.each(function (i, e) { cqGetChapters.each(function (i, e) {
const chapterA = cheerioQuery(this).find("a"); const chapterA = cheerioQuery(this).find("a");
const [chapterName, releaseDate, chapterUrl] = [ const [chapterName, releaseDate, chapterUrl] = [
// set the variables // set the variables
chapterA.text(), chapterA.text(),
cheerioQuery(this) cheerioQuery(this)
.find("dt") // get title .find("dt") // get title
.text() // get text .text() // get text
.replace(/(.)/g, "") // remove "(edited)" mark .replace(/(.)/g, "") // remove "(edited)" mark
.trim(), // trim spaces .trim(), // trim spaces
getLastPartOfUrl(chapterA.attr("href")), getLastPartOfUrl(chapterA.attr("href")),
]; ];
chapters.push({ chapterName, releaseDate, chapterUrl }); chapters.push({ chapterName, releaseDate, chapterUrl });
}); });
} else { } else {
/** /**
* Because there are oneshots on the site, they have to be treated with special care * Because there are oneshots on the site, they have to be treated with special care
* that's what pisses me off in Shosetsu app. They have this extension, * that's what pisses me off in Shosetsu app. They have this extension,
* but every oneshot is set as "there are no chapters" and all contents are thrown into the description!! * but every oneshot is set as "there are no chapters" and all contents are thrown into the description!!
*/ */
// get summary for oneshot chapter // get summary for oneshot chapter
novel.novelSummary = cheerio // because there is no summary anywhere on the novel page, we have to take it from search page for a one-shot manga novel.novelSummary = cheerio // because there is no summary anywhere on the novel page, we have to take it from search page for a one-shot manga
.load(await scraper(searchUrl() + `&word=${novel.novelName}`), { .load(await scraper(searchUrl() + `&word=${novel.novelName}`), {
decodeEntities: false, decodeEntities: false,
})(".searchkekka_box") // find the manga in search.php })(".searchkekka_box") // find the manga in search.php
.first() .first()
.find(".ex") .find(".ex")
.text() .text()
.replace(/\s{2,}/g, "\n"); // get the description as text .replace(/\s{2,}/g, "\n"); // get the description as text
// add single chapter // add single chapter
chapters.push({ chapters.push({
chapterName: novel.novelName, chapterName: novel.novelName,
releaseDate: cheerioQuery("head") releaseDate: cheerioQuery("head")
.find("meta[name='WWWC']") .find("meta[name='WWWC']")
.attr("content"), // get date from metadata .attr("content"), // get date from metadata
chapterUrl: "oneshot", // set chapterUrl to oneshot so that chapterScraper knows it's a one-shot chapterUrl: "oneshot", // set chapterUrl to oneshot so that chapterScraper knows it's a one-shot
}); });
} }
novel.novelChapters = chapters; novel.novelChapters = chapters;
res.json(novel); res.json(novel);
console.log("Finished!"); console.log("Finished!");
}; };
let chapterScraper = async (req, res) => { let chapterScraper = async (req, res) => {
const novelUrl = req.params.novelUrl; const novelUrl = req.params.novelUrl;
const chapterUrl = req.params.chapterUrl; const chapterUrl = req.params.chapterUrl;
const url = getChapterUrl(novelUrl, chapterUrl); // get Url const url = getChapterUrl(novelUrl, chapterUrl); // get Url
// create cheerioQuery // create cheerioQuery
const cheerioQuery = cheerio.load(await scraper(url), { const cheerioQuery = cheerio.load(await scraper(url), {
decodeEntities: false, decodeEntities: false,
}); });
// create chapter data structure // create chapter data structure
let chapter = { let chapter = {
extensionId: 1, extensionId: 1,
novelUrl, novelUrl,
chapterUrl, chapterUrl,
chapterName: "", chapterName: "",
chapterText: cheerioQuery("#novel_honbun") // get chapter text chapterText: cheerioQuery("#novel_honbun") // get chapter text
.text() .text()
.replace(/<\s*br.*?>/g, "") .replace(/<\s*br.*?>/g, "")
.replace(/\n{2,}/g, "\n"), // remove double breaklines .replace(/\n{2,}/g, "\n"), // remove double breaklines
nextChapter: null, nextChapter: null,
prevChapter: null, prevChapter: null,
}; };
if (chapterUrl === "oneshot") if (chapterUrl === "oneshot")
// oneshot get name // oneshot get name
chapter.chapterName = cheerioQuery("#novel_title").text(); chapter.chapterName = cheerioQuery("#novel_title").text();
else { else {
// single chapter // single chapter
// get name // get name
chapter.chapterName = cheerioQuery(".novel_subtitle").first().text(); chapter.chapterName = cheerioQuery(".novel_subtitle").first().text();
// get next/prev buttons // get next/prev buttons
const chapterButtons = cheerioQuery( const chapterButtons = cheerioQuery(
"#novel_contents .novel_bn" "#novel_contents .novel_bn"
).first(); ).first();
if (chapterButtons.length === 1) { if (chapterButtons.length === 1) {
const button = chapterButtons.find("a"); const button = chapterButtons.find("a");
if (button.text().match(/次/)) if (button.text().match(/次/))
chapter.nextChapter = getLastPartOfUrl(button.attr("href")); chapter.nextChapter = getLastPartOfUrl(button.attr("href"));
else chapter.prevChapter = getLastPartOfUrl(button.attr("href")); else chapter.prevChapter = getLastPartOfUrl(button.attr("href"));
} else { } else {
const firstButton = chapterButtons.find("a").first(); const firstButton = chapterButtons.find("a").first();
const lastButton = chapterButtons.find("a").last(); const lastButton = chapterButtons.find("a").last();
chapter.prevChapter = getLastPartOfUrl(firstButton.attribs.href); chapter.prevChapter = getLastPartOfUrl(firstButton.attribs.href);
chapter.nextChapter = getLastPartOfUrl(lastButton.attribs.href); chapter.nextChapter = getLastPartOfUrl(lastButton.attribs.href);
} }
} }
res.json(chapter); res.json(chapter);
console.log("Finished!"); console.log("Finished!");
}; };
let searchScraper = async (req, res) => { let searchScraper = async (req, res) => {
const searchTerm = req.query.s; const searchTerm = req.query.s;
const orderBy = req.query.o; const orderBy = req.query.o;
// array of all the novels // array of all the novels
let novels = []; let novels = [];
let isNext = true; let isNext = true;
// returns list of novels from given page // returns list of novels from given page
let getNovelsFromPage = async (pagenumber) => { let getNovelsFromPage = async (pagenumber) => {
// load page // load page
const body = await scraper( const body = await scraper(
searchUrl(pagenumber || null, req.query.o || null) + searchUrl(pagenumber || null, req.query.o || null) +
`&word=${searchTerm}` `&word=${searchTerm}`
); );
// Cheerio it! // Cheerio it!
const cheerioQuery = cheerio.load(body, { decodeEntities: false }); const cheerioQuery = cheerio.load(body, { decodeEntities: false });
if (cheerioQuery(".nextlink").length === 0) isNext = false; if (cheerioQuery(".nextlink").length === 0) isNext = false;
let pageNovels = []; let pageNovels = [];
// find class=searchkekka_box // find class=searchkekka_box
cheerioQuery(".searchkekka_box").each(function (i, e) { cheerioQuery(".searchkekka_box").each(function (i, e) {
// get div with link and name // get div with link and name
const novelDIV = cheerioQuery(this).find(".novel_h"); const novelDIV = cheerioQuery(this).find(".novel_h");
// get link element // get link element
const novelA = novelDIV.children()[0]; const novelA = novelDIV.children()[0];
// add new novel to array // add new novel to array
pageNovels.push({ pageNovels.push({
novelName: novelDIV.text(), // get the name novelName: novelDIV.text(), // get the name
novelUrl: getLastPartOfUrl(novelA.attribs.href), // get last part of the link novelUrl: getLastPartOfUrl(novelA.attribs.href), // get last part of the link
extensionId, extensionId,
novelCover, // TODO: IDK what to do about covers... On Syo they don't have them novelCover, // TODO: IDK what to do about covers... On Syo they don't have them
}); });
}); });
// return all novels from this page // return all novels from this page
return pageNovels; return pageNovels;
}; };
// counter of loaded pages // counter of loaded pages
let pagesLoaded = 0; let pagesLoaded = 0;
do { do {
// always load first one // always load first one
novels.push(...(await getNovelsFromPage(pagesLoaded + 1))); novels.push(...(await getNovelsFromPage(pagesLoaded + 1)));
pagesLoaded++; pagesLoaded++;
} while (pagesLoaded < maxPageLoad && isNext); // check if we should load more } while (pagesLoaded < maxPageLoad && isNext); // check if we should load more
/** Use /** Use
* novels.push(...(await getNovelsFromPage(pageNumber))) * novels.push(...(await getNovelsFromPage(pageNumber)))
* if you want to load more * if you want to load more
*/ */
// respond with novels! // respond with novels!
res.json(novels); res.json(novels);
console.log("Finished!"); console.log("Finished!");
}; };
module.exports = mtlNovelScraper = { module.exports = mtlNovelScraper = {
novelsScraper, novelsScraper,
novelScraper, novelScraper,
chapterScraper, chapterScraper,
searchScraper, searchScraper,
}; };