From ecc78d0075109aed3a3578667104cab5a8518687 Mon Sep 17 00:00:00 2001 From: Ayush Singh <52620158+singhayushh@users.noreply.github.com> Date: Fri, 12 Mar 2021 19:55:48 +0530 Subject: [PATCH 1/2] Project restructuring with separate controllers and utils directories * routes restructured into separate directories * imports updated * home page controller added * anime streaming routes and controllers updated * content loader routes and controllers updated * search routes and controllers updated * manga routes and controllers updated --- app.js | 16 +-- controllers/index.controller.js | 127 ++++++++++++++++++++++ controllers/loader.controller.js | 178 +++++++++++++++++++++++++++++++ controllers/manga.controller.js | 44 ++++++++ controllers/search.controller.js | 22 ++++ controllers/stream.controller.js | 89 ++++++++++++++++ package-lock.json | 2 +- routes/animelist.js | 35 ------ routes/index.js | 130 +--------------------- routes/loader.js | 47 -------- routes/loader/animelist.js | 8 ++ routes/loader/loader.js | 8 ++ routes/loader/loadpage.js | 8 ++ routes/loader/newloader.js | 7 ++ routes/loadlatest.js | 23 ---- routes/loadmanga.js | 22 ---- routes/loadpage.js | 64 ----------- routes/loadvideo.js | 88 --------------- routes/manga/loadlatest.js | 7 ++ routes/manga/loadmanga.js | 7 ++ routes/manga/viewmanga.js | 7 ++ routes/newloader.js | 47 -------- routes/search.js | 23 ---- routes/search/search.js | 9 ++ routes/stream/loadvideo.js | 9 ++ routes/viewmanga.js | 16 --- {routes => utils}/mangapark.js | 0 27 files changed, 541 insertions(+), 502 deletions(-) create mode 100644 controllers/index.controller.js create mode 100644 controllers/loader.controller.js create mode 100644 controllers/manga.controller.js create mode 100644 controllers/search.controller.js create mode 100644 controllers/stream.controller.js delete mode 100644 routes/animelist.js delete mode 100644 routes/loader.js create mode 100644 routes/loader/animelist.js create mode 100644 routes/loader/loader.js create mode 100644 routes/loader/loadpage.js create mode 100644 routes/loader/newloader.js delete mode 100644 routes/loadlatest.js delete mode 100644 routes/loadmanga.js delete mode 100644 routes/loadpage.js delete mode 100644 routes/loadvideo.js create mode 100644 routes/manga/loadlatest.js create mode 100644 routes/manga/loadmanga.js create mode 100644 routes/manga/viewmanga.js delete mode 100644 routes/newloader.js delete mode 100644 routes/search.js create mode 100644 routes/search/search.js create mode 100644 routes/stream/loadvideo.js delete mode 100644 routes/viewmanga.js rename {routes => utils}/mangapark.js (100%) diff --git a/app.js b/app.js index 57a9c34..2b5aed2 100644 --- a/app.js +++ b/app.js @@ -5,14 +5,14 @@ const cookieParser = require("cookie-parser"); const logger = require("morgan"); const indexRouter = require("./routes/index"); -const loadRouter = require("./routes/loadpage"); -const videoRouter = require("./routes/loadvideo"); -const animeList = require("./routes/animelist"); -const searchRoute = require("./routes/search"); -const loadManga = require("./routes/loadmanga"); -const loadChapter = require("./routes/viewmanga"); -const loadLatest = require("./routes/loadlatest"); -const loaderRoute = require("./routes/loader"); +const loadRouter = require("./routes/loader/loadpage"); +const animeList = require("./routes/loader/animelist"); +const loaderRoute = require("./routes/loader/loader"); +const loadManga = require("./routes/manga/loadmanga"); +const loadChapter = require("./routes/manga/viewmanga"); +const loadLatest = require("./routes/manga/loadlatest"); +const searchRoute = require("./routes/search/search"); +const videoRouter = require("./routes/stream/loadvideo"); const app = express(); app.set("views", path.join(__dirname, "views")); diff --git a/controllers/index.controller.js b/controllers/index.controller.js new file mode 100644 index 0000000..0dba147 --- /dev/null +++ b/controllers/index.controller.js @@ -0,0 +1,127 @@ +const request = require("request"); +const cheerio = require("cheerio"); +const mangaPark = require("../utils/mangapark"); +const mangaParkObj = new mangaPark(); + +const RenderHomePage = async (req, res, next) => { + var navList = []; + var updateList = []; + var newAnimeList = []; + var popularList = []; + var ongoingList = []; + + // Fetch Gogoanime popular anime links + request( + "https://www.gogoanime1.com/home/popular-animes", + (error, response, html) => { + if (!error && response.statusCode == 200) { + const $ = cheerio.load(html); + + $(".big-list .wide-anime-box").each((i, el) => { + var anime = {}; + var genre = []; + anime.picture = $(el).find(".anime-image").attr("style"); + anime.link = $(el).find(".anime-image").attr("href"); + anime.name = $(el).find(".wab-title a").text(); + anime.description = $(el).find(".wab-desc").text(); + $(el) + .find(".wab-links a") + .each((j, ex) => { + genre.push($(ex).text()); + }); + anime.genre = genre; + popularList.push(anime); + }); + } else { + console.log(error); + } + } + ); + + // Fetch Gogoanime latest up[date] links + request("https://www.gogoanime1.com", (error, response, html) => { + if (!error && response.statusCode == 200) { + const $ = cheerio.load(html); + + $(".main-menu li").each((i, el) => { + var link = {}; + link.href = $(el).find("a").attr("href"); + link.text = $(el).find("a").text(); + navList.push(link); + }); + + $(".animeList .nl-item").each((i, el) => { + var update = {}; + update.mainLink = $(el).find(".nli-image").attr("href"); + update.imageLink = $(el).find(".nli-image img").attr("src"); + update.epLink = $(el).find(".nli-ep").attr("href"); + update.epName = $(el).find(".nli-ep").text(); + update.epUpdate = $(el).find(".release").text(); + updateList.push(update); + }); + + $(".tnTabber .bl-grid").each((i, el) => { + var newanime = {}; + var genre = []; + newanime.animeLink = $(el).find(".blb-image").attr("href"); + newanime.imageLink = $(el).find(".blb-image img").attr("src"); + newanime.animeTitle = $(el).find(".blb-title").text(); + $(el) + .find(".blb-links a") + .each((j, elv) => { + genre.push($(elv).text()); + }); + newanime.genre = genre; + newAnimeList.push(newanime); + }); + } else { + console.log(error); + } + }); + + // Fetch Gogoanime latest up[date] links + request( + "https://www.gogoanime1.com/home/ongoing", + (error, response, html) => { + if (!error && response.statusCode == 200) { + const $ = cheerio.load(html); + + $(".big-list .bl-grid").each((i, el) => { + var ongoing = {}; + var genre = []; + ongoing.mainLink = $(el).find(".blb-image").attr("href"); + ongoing.imageLink = $(el).find(".blb-image img").attr("src"); + ongoing.title = $(el).find(".blb-title").text(); + console.log(ongoing); + $(el) + .find(".blb-links a") + .each((j, elj) => { + if (j <= 20) { + genre.push($(elj).text()); + } + }); + ongoing.genre = genre; + ongoingList.push(ongoing); + }); + console.log(ongoingList); + } else { + console.log(error); + } + } + ); + + mangass = await mangaParkObj.getMangaList(1); + const mangaUpdateList = mangass.LatestManga; + + res.render("index", { + title: "Mirai", + navList: navList, + updateList: updateList, + mangaUpdateList: mangaUpdateList, + newAnimeList: newAnimeList, + popularList: popularList, + ongoingList: ongoingList, + }); +}; + +module.exports = RenderHomePage; diff --git a/controllers/loader.controller.js b/controllers/loader.controller.js new file mode 100644 index 0000000..040996a --- /dev/null +++ b/controllers/loader.controller.js @@ -0,0 +1,178 @@ +const request = require("request"); +const cheerio = require("cheerio"); + +let seriesDetails = {}; +let navList = []; + +// Fetch Gogoanime latest header links +request("https://www.gogoanime1.com", (error, response, html) => { + if (!error && response.statusCode == 200) { + const $ = cheerio.load(html); + + $(".main-menu li").each((i, el) => { + let link = {}; + link.href = $(el).find("a").attr("href"); + link.text = $(el).find("a").text(); + navList.push(link); + }); + } else { + console.log(error); + } +}); + +const RenderAnimeList = (req, res, next) => { + const url = req.query.url; + let series = []; + request(url, (error, response, html) => { + if (!error && response.statusCode == 200) { + const $ = cheerio.load(html); + + $(".container-left .container-item").each((i, el) => { + let index = $(el).find(".ci-title").text(); + let linkstoindex = $(el).find("li"); + + let links = []; + linkstoindex.each((j, elx) => { + let info = {}; + info.href = $(elx).find("a").attr("href"); + info.text = $(elx).find("a").text(); + links.push(info); + }); + + series.push({ index, links }); + }); + res.render("animelist", { title: "Mirai", series: series }); + } else { + console.log(error); + } + }); +}; + +const LoaderController = (req, res, next) => { + let latestk = []; + let url = req.body.link; + request(url, (error, response, html) => { + if (!error && response.statusCode == 200) { + const $ = cheerio.load(html); + $(".truyen-list .list-truyen-item-wrap").each((j, eld) => { + let item = {}; + item.mangaLink = $(eld).children().first("a").attr("href"); + item.imageLink = $(eld).find("img").attr("src"); + item.views = $(eld).find(".aye_icon").text(); + item.description = $(eld).find("p").text(); + item.title = $(eld).find("h3 a").text(); + item.update = $(eld).find(".list-story-item-wrap-chapter").text(); + item.updateLink = $(eld) + .find(".list-story-item-wrap-chapter") + .attr("href"); + latestk.push(item); + }); + let total = $(".panel_page_number .group_qty").find("a").text(); + let linksk = []; + $(".panel_page_number .group_page a").each((y, elx) => { + let link = {}; + link.text = $(elx).text(); + link.href = $(elx).attr("href"); + link.class = $(elx).attr("class"); + linksk.push(link); + }); + + res.render("latest", { + title: "Mirai", + latest: latestk, + total: total, + links: linksk, + }); + } else { + console.log(error); + } + }); +}; + +const RenderLoadEpisodes = (req, res, next) => { + let url = req.query.url; + let episodeList = []; + let detailer = []; + request(url, (error, response, html) => { + if (!error && response.statusCode == 200) { + const $ = cheerio.load(html); + //Get series details + seriesDetails.name = $(".anime-title").text(); + seriesDetails.details = $(".anime-details").text(); + seriesDetails.image = $(".animeDetail-image").find("img").attr("src"); + seriesDetails.started = $(".animeDetail-tags").children().last().text(); + $(".animeDetail-tags .animeDetail-item").each((i, el) => { + let detailsx = {}; + detailsx.name = $(el).find("span").text(); + detailsx.value = $(el).text(); + detailer.push(detailsx); + }); + //Get episodes list and links + let episodeDiv = $(".tnContent").attr("style", "display: none;"); + episodeDiv.find("li").each((i, el) => { + let link = {}; + link.href = $(el).find("a").attr("href"); + link.episode = $(el).find("a").text(); + episodeList.push(link); + }); + + res.render("loadepisode", { + title: "Mirai", + navList: navList, + episodeList: episodeList, + seriesDetails: seriesDetails, + detailer: detailer, + }); + } else { + console.log(error); + } + }); +}; + +const RenderNewLoader = (req, res, next) => { + let latestk = []; + let url = req.body.link; + request(url, (error, response, html) => { + if (!error && response.statusCode == 200) { + const $ = cheerio.load(html); + $(".truyen-list .list-truyen-item-wrap").each((j, eld) => { + let item = {}; + item.mangaLink = $(eld).children().first("a").attr("href"); + item.imageLink = $(eld).find("img").attr("src"); + item.views = $(eld).find(".aye_icon").text(); + item.description = $(eld).find("p").text(); + item.title = $(eld).find("h3 a").text(); + item.update = $(eld).find(".list-story-item-wrap-chapter").text(); + item.updateLink = $(eld) + .find(".list-story-item-wrap-chapter") + .attr("href"); + latestk.push(item); + }); + let total = $(".panel_page_number .group_qty").find("a").text(); + let linksk = []; + $(".panel_page_number .group_page a").each((y, elx) => { + let link = {}; + link.text = $(elx).text(); + link.href = $(elx).attr("href"); + link.class = $(elx).attr("class"); + linksk.push(link); + }); + + res.render("newloader", { + title: "Mirai", + latest: latestk, + total: total, + links: linksk, + }); + } else { + console.log(error); + } + }); +}; + +module.exports = { + RenderAnimeList, + LoaderController, + RenderLoadEpisodes, + RenderNewLoader +}; diff --git a/controllers/manga.controller.js b/controllers/manga.controller.js new file mode 100644 index 0000000..c46b06d --- /dev/null +++ b/controllers/manga.controller.js @@ -0,0 +1,44 @@ +const mangaPark = require("../utils/mangapark"); +const mangaParkObj = new mangaPark(); + +const RenderLatestManga = async (req, res, next) => { + const data = await mangaParkObj.getLatestMangaData(); + res.render("latest", { + title: "Mirai", + latest: data.LatestManga, + }); +}; + +const RenderLoadManga = async (req, res, next) => { + var url = req.query.url; + const manga = await mangaParkObj.getMangaInfo(url); + res.render("loadmanga", { + title: "Mirai", + mangaDetails: { + image: manga.mangaInfo.thumb, + name: manga.mangaInfo.title, + summary: manga.mangaInfo.desc, + release: "", + views: "", + }, + + chapterList: manga.mangaInfo.chapterList, + }); +}; + +const RenderViewManga = async (req, res, next) => { + const url = req.query.url; + const image = await mangaParkObj.getImageList(url); + const information = await mangaParkObj.getChapterInfo(url); + res.render("viewmanga", { + title: "Anime Master", + images: image.images, + details: information, + }); +}; + +module.exports = { + RenderLatestManga, + RenderLoadManga, + RenderViewManga, +}; diff --git a/controllers/search.controller.js b/controllers/search.controller.js new file mode 100644 index 0000000..6f3f610 --- /dev/null +++ b/controllers/search.controller.js @@ -0,0 +1,22 @@ +const request = require("request"); +const mangaPark = require("../utils/mangapark"); +const mangaParkObj = new mangaPark(); + +const SearchController = (req, res, next) => { + request( + "https://www.gogoanime1.com/search/topSearch?q=" + req.query.q, + (error, response, html) => { + res.send(response.body); + } + ); +}; + +const MangaSearchController = async (req, res, next) => { + let manga = await mangaParkObj.search(10, req.query.q, []); + res.send(manga); +}; + +module.exports = { + SearchController, + MangaSearchController, +}; \ No newline at end of file diff --git a/controllers/stream.controller.js b/controllers/stream.controller.js new file mode 100644 index 0000000..0631b9f --- /dev/null +++ b/controllers/stream.controller.js @@ -0,0 +1,89 @@ +const request = require("request"); +const cheerio = require("cheerio"); + +let navList = []; + +// Fetch Gogoanime latest header links +request("https://www.gogoanime1.com", (error, response, html) => { + if (!error && response.statusCode == 200) { + const $ = cheerio.load(html); + + $(".main-menu li").each((i, el) => { + let link = {}; + link.href = $(el).find("a").attr("href"); + link.text = $(el).find("a").text(); + navList.push(link); + }); + } else { + console.log(error); + } +}); + +const RenderPlayEpisode = (req, res, next) => { + let url = req.query.url; + //generate series URL by exploding + let split = url.split("/"); + let seriesUrl = split[0] + "//" + split[2] + "/" + split[3] + "/" + split[4]; + //request Episode List + let episodeList = []; + request(seriesUrl, (error, response, html) => { + if (!error && response.statusCode == 200) { + const $ = cheerio.load(html); + //Get episodes list and links + let episodeDiv = $(".ci-contents").last(".check-list"); + episodeDiv.find("li").each((i, el) => { + let link = {}; + link.href = $(el).find("a").attr("href"); + link.episode = $(el).find("a").text(); + episodeList.push(link); + }); + episodeList = episodeList.reverse(); + //request current episode data + request(url, (error, response, html) => { + if (!error && response.statusCode == 200) { + const $ = cheerio.load(html); + let detailsEpisode = {}; + detailsEpisode.name = $(".vmn-title").find("h1").text(); + detailsEpisode.downloadLink = $(".vmn-buttons") + .children() + .last() + .attr("href"); + res.render("playepisode", { + title: "Mirai", + navList: navList, + detailsEpisode: detailsEpisode, + seriesUrl: seriesUrl, + episodeList: episodeList, + url: url, + }); + } else { + console.log(error); + } + }); + } else { + console.log(error); + } + }); +}; + +const VideoURLController = (req, res) => { + request(req.body.link, (error, response, html) => { + if (!error && response.statusCode == 200) { + const $ = cheerio.load(html); + let detailsEpisode = {}; + detailsEpisode.name = $(".vmn-title").find("h1").text(); + detailsEpisode.downloadLink = $(".vmn-buttons") + .children() + .last() + .attr("href"); + res.send(JSON.stringify(detailsEpisode)); + } else { + console.log(error); + } + }); +}; + +module.exports = { + RenderPlayEpisode, + VideoURLController, +}; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index cda1acc..376790b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "nekoto", + "name": "mirai", "version": "10.16.0", "lockfileVersion": 1, "requires": true, diff --git a/routes/animelist.js b/routes/animelist.js deleted file mode 100644 index d73dcab..0000000 --- a/routes/animelist.js +++ /dev/null @@ -1,35 +0,0 @@ -const express = require("express"); -const request = require("request"); -const cheerio = require("cheerio"); - -const router = express.Router(); - -router.get("/", function (req, res, next) { - const url = req.query.url; - let series = []; - request(url, (error, response, html) => { - if (!error && response.statusCode == 200) { - const $ = cheerio.load(html); - - $(".container-left .container-item").each((i, el) => { - let index = $(el).find(".ci-title").text(); - let linkstoindex = $(el).find("li"); - - let links = []; - linkstoindex.each((j, elx) => { - let info = {}; - info.href = $(elx).find("a").attr("href"); - info.text = $(elx).find("a").text(); - links.push(info); - }); - - series.push({ index, links }); - }); - res.render("animelist", { title: "Mirai", series: series }); - } else { - console.log(error); - } - }); -}); - -module.exports = router; diff --git a/routes/index.js b/routes/index.js index 4867df7..cb3df24 100644 --- a/routes/index.js +++ b/routes/index.js @@ -1,134 +1,8 @@ var express = require("express"); -const request = require("request"); -const cheerio = require("cheerio"); -const mangaPark = require("./mangapark"); -const mangaParkObj = new mangaPark(); +const RenderHomePage = require("../controllers/index.controller"); var router = express.Router(); /* GET home page. */ -router.get("/", async function (req, res, next) { - var navList = []; - var updateList = []; - var mangaUpdateList = []; - var newAnimeList = []; - var popularList = []; - var ongoingList = []; - var spotlight = []; - - // Fetch Gogoanime popular anime links - request( - "https://www.gogoanime1.com/home/popular-animes", - (error, response, html) => { - if (!error && response.statusCode == 200) { - const $ = cheerio.load(html); - - $(".big-list .wide-anime-box").each((i, el) => { - var anime = {}; - var genre = []; - anime.picture = $(el).find(".anime-image").attr("style"); - anime.link = $(el).find(".anime-image").attr("href"); - anime.name = $(el).find(".wab-title a").text(); - anime.description = $(el).find(".wab-desc").text(); - $(el) - .find(".wab-links a") - .each((j, ex) => { - genre.push($(ex).text()); - }); - anime.genre = genre; - popularList.push(anime); - }); - } else { - console.log(error); - } - } - ); - - // Fetch Gogoanime latest up[date] links - request("https://www.gogoanime1.com", (error, response, html) => { - if (!error && response.statusCode == 200) { - const $ = cheerio.load(html); - - $(".main-menu li").each((i, el) => { - var link = {}; - link.href = $(el).find("a").attr("href"); - link.text = $(el).find("a").text(); - navList.push(link); - }); - - $(".animeList .nl-item").each((i, el) => { - var update = {}; - update.mainLink = $(el).find(".nli-image").attr("href"); - update.imageLink = $(el).find(".nli-image img").attr("src"); - update.epLink = $(el).find(".nli-ep").attr("href"); - update.epName = $(el).find(".nli-ep").text(); - update.epUpdate = $(el).find(".release").text(); - updateList.push(update); - }); - - $(".tnTabber .bl-grid").each((i, el) => { - var newanime = {}; - var genre = []; - newanime.animeLink = $(el).find(".blb-image").attr("href"); - newanime.imageLink = $(el).find(".blb-image img").attr("src"); - newanime.animeTitle = $(el).find(".blb-title").text(); - $(el) - .find(".blb-links a") - .each((j, elv) => { - genre.push($(elv).text()); - }); - newanime.genre = genre; - newAnimeList.push(newanime); - }); - } else { - console.log(error); - } - }); - - // Fetch Gogoanime latest up[date] links - request( - "https://www.gogoanime1.com/home/ongoing", - (error, response, html) => { - if (!error && response.statusCode == 200) { - const $ = cheerio.load(html); - - $(".big-list .bl-grid").each((i, el) => { - var ongoing = {}; - var genre = []; - ongoing.mainLink = $(el).find(".blb-image").attr("href"); - ongoing.imageLink = $(el).find(".blb-image img").attr("src"); - ongoing.title = $(el).find(".blb-title").text(); - console.log(ongoing); - $(el) - .find(".blb-links a") - .each((j, elj) => { - if (j <= 20) { - genre.push($(elj).text()); - } - - }); - ongoing.genre = genre; - ongoingList.push(ongoing); - }); - console.log(ongoingList); - } else { - console.log(error); - } - } - ); - - // Fetch Gogoanime latest manga links - // getMangaList - mangass = await mangaParkObj.getMangaList(1); - // console.log(ongoingList); - res.render("index", { - title: "Mirai", - navList: navList, - updateList: updateList, - mangaUpdateList: mangass.LatestManga, - newAnimeList: newAnimeList, - popularList: popularList, - ongoingList: ongoingList, - }); -}); +router.get("/", RenderHomePage); module.exports = router; diff --git a/routes/loader.js b/routes/loader.js deleted file mode 100644 index e39031a..0000000 --- a/routes/loader.js +++ /dev/null @@ -1,47 +0,0 @@ -const express = require("express"); -const request = require("request"); -const cheerio = require("cheerio"); - -const router = express.Router(); - -router.post("/", function (req, res, next) { - let latestk = []; - let url = req.body.link; - request(url, (error, response, html) => { - if (!error && response.statusCode == 200) { - const $ = cheerio.load(html); - $(".truyen-list .list-truyen-item-wrap").each((j, eld) => { - let item = {}; - item.mangaLink = $(eld).children().first("a").attr("href"); - item.imageLink = $(eld).find("img").attr("src"); - item.views = $(eld).find(".aye_icon").text(); - item.description = $(eld).find("p").text(); - item.title = $(eld).find("h3 a").text(); - item.update = $(eld).find(".list-story-item-wrap-chapter").text(); - item.updateLink = $(eld) - .find(".list-story-item-wrap-chapter") - .attr("href"); - latestk.push(item); - }); - let total = $(".panel_page_number .group_qty").find("a").text(); - let linksk = []; - $(".panel_page_number .group_page a").each((y, elx) => { - let link = {}; - link.text = $(elx).text(); - link.href = $(elx).attr("href"); - link.class = $(elx).attr("class"); - linksk.push(link); - }); - - res.render("latest", { - title: "Mirai", - latest: latestk, - total: total, - links: linksk, - }); - } else { - console.log(error); - } - }); -}); -module.exports = router; diff --git a/routes/loader/animelist.js b/routes/loader/animelist.js new file mode 100644 index 0000000..bd5db1a --- /dev/null +++ b/routes/loader/animelist.js @@ -0,0 +1,8 @@ +const express = require("express"); +const { RenderAnimeList } = require("../../controllers/loader.controller"); + +const router = express.Router(); + +router.get("/", RenderAnimeList); + +module.exports = router; diff --git a/routes/loader/loader.js b/routes/loader/loader.js new file mode 100644 index 0000000..16ae8a1 --- /dev/null +++ b/routes/loader/loader.js @@ -0,0 +1,8 @@ +const express = require("express"); +const { LoaderController } = require("../../controllers/loader.controller"); + +const router = express.Router(); + +router.post("/", LoaderController); + +module.exports = router; diff --git a/routes/loader/loadpage.js b/routes/loader/loadpage.js new file mode 100644 index 0000000..3e5a288 --- /dev/null +++ b/routes/loader/loadpage.js @@ -0,0 +1,8 @@ +const express = require("express"); +const { RenderLoadEpisodes } = require("../../controllers/loader.controller"); + +const router = express.Router(); + + +router.get("/", RenderLoadEpisodes) +module.exports = router; diff --git a/routes/loader/newloader.js b/routes/loader/newloader.js new file mode 100644 index 0000000..8db20f9 --- /dev/null +++ b/routes/loader/newloader.js @@ -0,0 +1,7 @@ +const express = require("express"); +const { RenderNewLoader } = require("../../controllers/loader.controller"); + +const router = express.Router(); + +router.post("/", RenderNewLoader) +module.exports = router; diff --git a/routes/loadlatest.js b/routes/loadlatest.js deleted file mode 100644 index 6be4eb1..0000000 --- a/routes/loadlatest.js +++ /dev/null @@ -1,23 +0,0 @@ -const express = require("express"); -const request = require("request"); -const cheerio = require("cheerio"); -const mangaPark = require("./mangapark"); -const mangaParkObj = new mangaPark(); -const router = express.Router(); - -// item.mangaLink = $(eld).children().first("a").attr("href"); -// item.imageLink = $(eld).find("img").attr("src"); -// item.views = $(eld).find(".aye_icon").text(); -// item.description = $(eld).find("p").text(); -// item.title = $(eld).find("h3 a").text(); -// item.update = $(eld).find(".list-story-item-wrap-chapter").text(); -// item.updateLink = $(eld); -router.get("/", async function (req, res, next) { - const data = await mangaParkObj.getLatestMangaData(); - // console.log(data.LatestManga); - res.render("latest", { - title: "Mirai", - latest: data.LatestManga, - }); -}); -module.exports = router; diff --git a/routes/loadmanga.js b/routes/loadmanga.js deleted file mode 100644 index 977c53d..0000000 --- a/routes/loadmanga.js +++ /dev/null @@ -1,22 +0,0 @@ -var express = require("express"); -const mangaPark = require("./mangapark"); -const mangaParkObj = new mangaPark(); -var router = express.Router(); - -router.get("/", async function (req, res, next) { - var url = req.query.url; - const manga = await mangaParkObj.getMangaInfo(url); - res.render("loadmanga", { - title: "Mirai", - mangaDetails: { - image: manga.mangaInfo.thumb, - name: manga.mangaInfo.title, - summary: manga.mangaInfo.desc, - release: "", - views: "", - }, - - chapterList: manga.mangaInfo.chapterList, - }); -}); -module.exports = router; diff --git a/routes/loadpage.js b/routes/loadpage.js deleted file mode 100644 index 3c24638..0000000 --- a/routes/loadpage.js +++ /dev/null @@ -1,64 +0,0 @@ -const express = require("express"); -const request = require("request"); -const cheerio = require("cheerio"); - -const router = express.Router(); -let seriesDetails = {}; -let navList = []; - -// Fetch Gogoanime latest header links -request("https://www.gogoanime1.com", (error, response, html) => { - if (!error && response.statusCode == 200) { - const $ = cheerio.load(html); - - $(".main-menu li").each((i, el) => { - let link = {}; - link.href = $(el).find("a").attr("href"); - link.text = $(el).find("a").text(); - navList.push(link); - }); - } else { - console.log(error); - } -}); - -router.get("/", function (req, res, next) { - let url = req.query.url; - let episodeList = []; - let detailer = []; - request(url, (error, response, html) => { - if (!error && response.statusCode == 200) { - const $ = cheerio.load(html); - //Get series details - seriesDetails.name = $(".anime-title").text(); - seriesDetails.details = $(".anime-details").text(); - seriesDetails.image = $(".animeDetail-image").find("img").attr("src"); - seriesDetails.started = $(".animeDetail-tags").children().last().text(); - $(".animeDetail-tags .animeDetail-item").each((i, el) => { - let detailsx = {}; - detailsx.name = $(el).find("span").text(); - detailsx.value = $(el).text(); - detailer.push(detailsx); - }); - //Get episodes list and links - let episodeDiv = $(".tnContent").attr("style", "display: none;"); - episodeDiv.find("li").each((i, el) => { - let link = {}; - link.href = $(el).find("a").attr("href"); - link.episode = $(el).find("a").text(); - episodeList.push(link); - }); - - res.render("loadepisode", { - title: "Mirai", - navList: navList, - episodeList: episodeList, - seriesDetails: seriesDetails, - detailer: detailer, - }); - } else { - console.log(error); - } - }); -}); -module.exports = router; diff --git a/routes/loadvideo.js b/routes/loadvideo.js deleted file mode 100644 index 93d57bf..0000000 --- a/routes/loadvideo.js +++ /dev/null @@ -1,88 +0,0 @@ -const express = require("express"); -const request = require("request"); -const cheerio = require("cheerio"); - -const router = express.Router(); -let navList = []; - -// Fetch Gogoanime latest header links -request("https://www.gogoanime1.com", (error, response, html) => { - if (!error && response.statusCode == 200) { - const $ = cheerio.load(html); - - $(".main-menu li").each((i, el) => { - let link = {}; - link.href = $(el).find("a").attr("href"); - link.text = $(el).find("a").text(); - navList.push(link); - }); - } else { - console.log(error); - } -}); - -router.get("/", function (req, res, next) { - let url = req.query.url; - //generate series URL by exploding - let split = url.split("/"); - let seriesUrl = split[0] + "//" + split[2] + "/" + split[3] + "/" + split[4]; - //request Episode List - let episodeList = []; - request(seriesUrl, (error, response, html) => { - if (!error && response.statusCode == 200) { - const $ = cheerio.load(html); - //Get episodes list and links - let episodeDiv = $(".ci-contents").last(".check-list"); - episodeDiv.find("li").each((i, el) => { - let link = {}; - link.href = $(el).find("a").attr("href"); - link.episode = $(el).find("a").text(); - episodeList.push(link); - }); - episodeList = episodeList.reverse(); - //request current episode data - request(url, (error, response, html) => { - if (!error && response.statusCode == 200) { - const $ = cheerio.load(html); - let detailsEpisode = {}; - detailsEpisode.name = $(".vmn-title").find("h1").text(); - detailsEpisode.downloadLink = $(".vmn-buttons") - .children() - .last() - .attr("href"); - res.render("playepisode", { - title: "Mirai", - navList: navList, - detailsEpisode: detailsEpisode, - seriesUrl: seriesUrl, - episodeList: episodeList, - url: url, - }); - } else { - console.log(error); - } - }); - } else { - console.log(error); - } - }); -}); - -// POST method route -router.post("/getVideoUrl", function (req, res) { - request(req.body.link, (error, response, html) => { - if (!error && response.statusCode == 200) { - const $ = cheerio.load(html); - let detailsEpisode = {}; - detailsEpisode.name = $(".vmn-title").find("h1").text(); - detailsEpisode.downloadLink = $(".vmn-buttons") - .children() - .last() - .attr("href"); - res.send(JSON.stringify(detailsEpisode)); - } else { - console.log(error); - } - }); -}); -module.exports = router; diff --git a/routes/manga/loadlatest.js b/routes/manga/loadlatest.js new file mode 100644 index 0000000..eea3899 --- /dev/null +++ b/routes/manga/loadlatest.js @@ -0,0 +1,7 @@ +const express = require("express"); +const { RenderLatestManga } = require("../../controllers/manga.controller"); +const router = express.Router(); + +router.get("/", RenderLatestManga); + +module.exports = router; diff --git a/routes/manga/loadmanga.js b/routes/manga/loadmanga.js new file mode 100644 index 0000000..ae95286 --- /dev/null +++ b/routes/manga/loadmanga.js @@ -0,0 +1,7 @@ +var express = require("express"); +var router = express.Router(); +const { RenderLoadManga } = require("../../controllers/manga.controller"); + +router.get("/", RenderLoadManga); + +module.exports = router; diff --git a/routes/manga/viewmanga.js b/routes/manga/viewmanga.js new file mode 100644 index 0000000..10b83e1 --- /dev/null +++ b/routes/manga/viewmanga.js @@ -0,0 +1,7 @@ +const express = require("express"); +const router = express.Router(); +const { RenderViewManga } = require("../../controllers/manga.controller"); + +router.get("/", RenderViewManga); + +module.exports = router; diff --git a/routes/newloader.js b/routes/newloader.js deleted file mode 100644 index 96213e3..0000000 --- a/routes/newloader.js +++ /dev/null @@ -1,47 +0,0 @@ -const express = require("express"); -const request = require("request"); -const cheerio = require("cheerio"); - -const router = express.Router(); - -router.post("/", function (req, res, next) { - let latestk = []; - let url = req.body.link; - request(url, (error, response, html) => { - if (!error && response.statusCode == 200) { - const $ = cheerio.load(html); - $(".truyen-list .list-truyen-item-wrap").each((j, eld) => { - let item = {}; - item.mangaLink = $(eld).children().first("a").attr("href"); - item.imageLink = $(eld).find("img").attr("src"); - item.views = $(eld).find(".aye_icon").text(); - item.description = $(eld).find("p").text(); - item.title = $(eld).find("h3 a").text(); - item.update = $(eld).find(".list-story-item-wrap-chapter").text(); - item.updateLink = $(eld) - .find(".list-story-item-wrap-chapter") - .attr("href"); - latestk.push(item); - }); - let total = $(".panel_page_number .group_qty").find("a").text(); - let linksk = []; - $(".panel_page_number .group_page a").each((y, elx) => { - let link = {}; - link.text = $(elx).text(); - link.href = $(elx).attr("href"); - link.class = $(elx).attr("class"); - linksk.push(link); - }); - - res.render("newloader", { - title: "Mirai", - latest: latestk, - total: total, - links: linksk, - }); - } else { - console.log(error); - } - }); -}); -module.exports = router; diff --git a/routes/search.js b/routes/search.js deleted file mode 100644 index 3011d8d..0000000 --- a/routes/search.js +++ /dev/null @@ -1,23 +0,0 @@ -var express = require("express"); -const request = require("request"); -const cheerio = require("cheerio"); -const mangaPark = require("./mangapark"); -const mangaParkObj = new mangaPark(); - -var router = express.Router(); - -router.get("/", function (req, res, next) { - request( - "https://www.gogoanime1.com/search/topSearch?q=" + req.query.q, - (error, response, html) => { - res.send(response.body); - } - ); -}); - -router.get("/mangasearch", async function (req, res, next) { - let manga = await mangaParkObj.search(10, req.query.q, []); - res.send(manga); -}); - -module.exports = router; diff --git a/routes/search/search.js b/routes/search/search.js new file mode 100644 index 0000000..52a4e91 --- /dev/null +++ b/routes/search/search.js @@ -0,0 +1,9 @@ +var express = require("express"); +var router = express.Router(); +const { SearchController, MangaSearchController } = require("../../controllers/search.controller"); + +router.get("/", SearchController); + +router.get("/mangasearch", MangaSearchController); + +module.exports = router; diff --git a/routes/stream/loadvideo.js b/routes/stream/loadvideo.js new file mode 100644 index 0000000..22ebb13 --- /dev/null +++ b/routes/stream/loadvideo.js @@ -0,0 +1,9 @@ +const express = require("express"); +const router = express.Router(); +const { RenderPlayEpisode, VideoURLController } = require("../../controllers/stream.controller"); + + +router.get("/", RenderPlayEpisode); +router.post("/getVideoUrl", VideoURLController); + +module.exports = router; diff --git a/routes/viewmanga.js b/routes/viewmanga.js deleted file mode 100644 index c63dc42..0000000 --- a/routes/viewmanga.js +++ /dev/null @@ -1,16 +0,0 @@ -const express = require("express"); -const mangaPark = require("./mangapark"); -const mangaParkObj = new mangaPark(); -const router = express.Router(); - -router.get("/", async function (req, res, next) { - const url = req.query.url; - const image = await mangaParkObj.getImageList(url); - const information = await mangaParkObj.getChapterInfo(url); - res.render("viewmanga", { - title: "Anime Master", - images: image.images, - details: information, - }); -}); -module.exports = router; diff --git a/routes/mangapark.js b/utils/mangapark.js similarity index 100% rename from routes/mangapark.js rename to utils/mangapark.js From 3fd7ecf69d83bf054a1666400b158e115cd1c2d2 Mon Sep 17 00:00:00 2001 From: singhayushh Date: Wed, 24 Mar 2021 12:53:51 +0530 Subject: [PATCH 2/2] fixed empty ongoing-anime list(#10) --- controllers/index.controller.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/controllers/index.controller.js b/controllers/index.controller.js index 0dba147..a6bc337 100644 --- a/controllers/index.controller.js +++ b/controllers/index.controller.js @@ -113,15 +113,18 @@ const RenderHomePage = async (req, res, next) => { mangass = await mangaParkObj.getMangaList(1); const mangaUpdateList = mangass.LatestManga; - res.render("index", { - title: "Mirai", - navList: navList, - updateList: updateList, - mangaUpdateList: mangaUpdateList, - newAnimeList: newAnimeList, - popularList: popularList, - ongoingList: ongoingList, - }); + setTimeout(function(){ + res.render("index", { + title: "Mirai", + navList: navList, + updateList: updateList, + mangaUpdateList: mangaUpdateList, + newAnimeList: newAnimeList, + popularList: popularList, + ongoingList: ongoingList, + }); + }, + 3000); }; module.exports = RenderHomePage;