Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: empty ongoing anime list in the home page #14

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
130 changes: 130 additions & 0 deletions controllers/index.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
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;

setTimeout(function(){
res.render("index", {
title: "Mirai",
navList: navList,
updateList: updateList,
mangaUpdateList: mangaUpdateList,
newAnimeList: newAnimeList,
popularList: popularList,
ongoingList: ongoingList,
});
},
3000);
};

module.exports = RenderHomePage;
178 changes: 178 additions & 0 deletions controllers/loader.controller.js
Original file line number Diff line number Diff line change
@@ -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
};
44 changes: 44 additions & 0 deletions controllers/manga.controller.js
Original file line number Diff line number Diff line change
@@ -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,
};
Loading