diff --git a/src/backend/Scrappers/animepahe.js b/src/backend/Scrappers/animepahe.js index 601ea1d..4683575 100644 --- a/src/backend/Scrappers/animepahe.js +++ b/src/backend/Scrappers/animepahe.js @@ -6,7 +6,6 @@ const cheerio = require("cheerio"); const axios = require("axios"); const path = require("path"); const fs = require("fs"); - // variables const baseUrl = "https://animepahe.ru"; const userDataPath = app.getPath("userData"); @@ -71,59 +70,66 @@ async function fetchRecentEpisodes(page = 1) { } // Animeinfo -async function AnimeInfo(id) { +async function AnimeInfo( + id, + { dub = false, fetch_info = true, page = 1 } = {} +) { const animeInfo = { id: id, title: "", }; try { - const response = await ddosGuardRequest(`${baseUrl}/anime/${id}`); - - const $ = (0, cheerio.load)(response.data); + if (fetch_info) { + const response = await ddosGuardRequest(`${baseUrl}/anime/${id}`); + + const $ = (0, cheerio.load)(response.data); + + animeInfo.title = $("div.title-wrapper > h1 > span").first().text(); + animeInfo.image = + `/proxy/image?url=` + $("div.anime-poster a").attr("href"); + animeInfo.cover = + `/proxy/image?url=` + `https:${$("div.anime-cover").attr("data-src")}`; + animeInfo.description = $("div.anime-summary").text(); + animeInfo.genres = $("div.anime-genre ul li") + .map((i, el) => $(el).find("a").attr("title")) + .get(); + switch ( + $('div.col-sm-4.anime-info p:icontains("Status:") a').text().trim() + ) { + case "Currently Airing": + animeInfo.status = "Ongoing"; + break; + case "Finished Airing": + animeInfo.status = "Completed"; + break; + default: + animeInfo.status = "Unknown"; + } - animeInfo.title = $("div.title-wrapper > h1 > span").first().text(); - animeInfo.image = - `/proxy/image?url=` + $("div.anime-poster a").attr("href"); - animeInfo.cover = - `/proxy/image?url=` + `https:${$("div.anime-cover").attr("data-src")}`; - animeInfo.description = $("div.anime-summary").text(); - animeInfo.genres = $("div.anime-genre ul li") - .map((i, el) => $(el).find("a").attr("title")) - .get(); - switch ( - $('div.col-sm-4.anime-info p:icontains("Status:") a').text().trim() - ) { - case "Currently Airing": - animeInfo.status = "Ongoing"; - break; - case "Finished Airing": - animeInfo.status = "Completed"; - break; - default: - animeInfo.status = "Unknown"; + animeInfo.type = $('div.col-sm-4.anime-info p:icontains("Type") a') + .text() + .trim() + .toUpperCase(); + + animeInfo.aired = $('div.col-sm-4.anime-info p:icontains("Aired")') + .text() + .replace("Aired:", "") + .replaceAll("\n", " ") + .replaceAll(" ", "") + .trim(); } - animeInfo.type = $('div.col-sm-4.anime-info p:icontains("Type") a') - .text() - .trim() - .toUpperCase(); - - animeInfo.aired = $('div.col-sm-4.anime-info p:icontains("Aired")') - .text() - .replace("Aired:", "") - .replaceAll("\n", " ") - .replaceAll(" ", "") - .trim(); - const { episodes, last_page, total_episodes } = await fetchEpisodesPages( id, - 1 + page, + dub ); - animeInfo.total_episodes = total_episodes; + animeInfo.totalEpisodes = total_episodes; animeInfo.last_page = last_page; animeInfo.episodes = episodes; + animeInfo.provider = "pahe"; return animeInfo; } catch (error) { @@ -133,25 +139,37 @@ async function AnimeInfo(id) { } // Fetching Episodes Pages -async function fetchEpisodesPages(id, page = 1) { +async function fetchEpisodesPages(id, page, dub) { try { let episodes = []; const { data: { last_page, data, total }, } = await ddosGuardRequest( - `${baseUrl}/api?m=release&id=${id}&sort=episode_desc&page=${page}` + `${baseUrl}/api?m=release&id=${id}&sort=episode_asc&page=${page}` ); - episodes.push( - ...data.map((item) => ({ - id: `${id}/${item.session}`, - number: item.episode, - title: item.title, - duration: item.duration, - // dub: item.audio && item.audio === "jpn" ? false : true, - })) - ); + if (dub) { + episodes.push( + ...data + .filter((item) => item?.audio && item?.audio?.toLowerCase() === "eng") + .map((item) => ({ + id: `${id}/${item.session}`, + number: item.episode, + title: item.title, + duration: item.duration, + })) + ); + } else { + episodes.push( + ...data.map((item) => ({ + id: `${id}/${item.session}`, + number: item.episode, + title: item.title, + duration: item.duration, + })) + ); + } return { episodes: episodes, @@ -164,62 +182,12 @@ async function fetchEpisodesPages(id, page = 1) { } } -// Find Episode -async function FindEpisodeByNumber(id, TotalEpisodes, EpisodeNumber) { - try { - if ( - TotalEpisodes && - (TotalEpisodes < EpisodeNumber || TotalEpisodes <= 0 || !EpisodeNumber) - ) { - throw new Error("No Episode Found"); - } - - let page = Math.ceil((TotalEpisodes - EpisodeNumber) / 30) + 1; - - let episode; - let data; - - const fetchPage = async (pageNum) => { - const response = await ddosGuardRequest( - `${baseUrl}/api?m=release&id=${id}&sort=episode_desc&page=${pageNum}` - ); - data = response.data.data; - }; - - await fetchPage(page); - - episode = data.find((item) => item.episode === EpisodeNumber); - - if (!episode) { - if (data && data[0] && data[0]?.episode > EpisodeNumber) { - console.log( - `Episode not found on page ${page}. Fetching page ${page - 1}...` - ); - await fetchPage(page - 1); - episode = data.find((item) => item.episode === EpisodeNumber); - } else if (data && data[data.length - 1]?.episode < EpisodeNumber) { - console.log( - `Episode not found on page ${page}. Fetching page ${page + 1}...` - ); - await fetchPage(page + 1); - episode = data.find((item) => item.episode === EpisodeNumber); - } - } - - if (episode) { - return await fetchAnimeEpisodeServer(`${id}/${episode.session}`); - } else { - throw new Error("Episode not found after checking adjacent pages."); - } - } catch (err) { - console.log("Error:", err.message); - return { results: [] }; - } -} - // fetching Episodes Download Links async function fetchEpisodeSources(episodeId) { try { + let dub = episodeId.endsWith("$dub"); + episodeId = episodeId.replace("$dub", ""); + const response = await ddosGuardRequest(`${baseUrl}/play/${episodeId}`, { headers: { Referer: `${baseUrl}`, @@ -236,16 +204,23 @@ async function fetchEpisodeSources(episodeId) { const iSource = { sources: [], }; + for (const link of links) { const res = await extract(new URL(link.url)); res[0].quality = link.quality; res[0].isDub = link.audio === "eng"; - iSource.sources.push(res[0]); + if (dub && res[0].isDub) { + iSource.sources.push(res[0]); + } else if (!dub && !res[0].isDub) { + iSource.sources.push(res[0]); + } else { + continue; + } } return iSource; } catch (err) { console.error("Error fetching data from AnimePahe:", err); - return { results: [] }; + return { sources: [] }; } } @@ -338,7 +313,6 @@ module.exports = { AnimeInfo, fetchEpisodeSources, fetchEpisodesPages, - FindEpisodeByNumber, fetchRecentEpisodes, ddosGuardRequest, }; diff --git a/src/backend/database.js b/src/backend/database.js index 4f6b1f0..959429f 100644 --- a/src/backend/database.js +++ b/src/backend/database.js @@ -138,7 +138,7 @@ async function downloadEpisodeByQuality( try { let preferredQualities = ["1080p", "720p", "360p", "default", "backup"]; const provider = await providerFetch(config.provider); - const sourcesArray = await fetchEpisodeSources(provider, epid); + const sourcesArray = await fetchEpisodeSources(provider.provider, epid); let selectedSource = sourcesArray.sources.find( (source) => source.quality === config?.quality ?? "1080p" ); diff --git a/src/backend/download.js b/src/backend/download.js index 6a8f263..e26c14d 100644 --- a/src/backend/download.js +++ b/src/backend/download.js @@ -15,60 +15,144 @@ async function downloadfunction(animeid, startep, endep) { if (!startep || !animeid) throw new Error("Something seems to be missing.."); if (!(startep > 0)) throw new Error("Start ep is 0"); const provider = await providerFetch(); - const animedata = await animeinfo(provider, animeid); - if (!animedata) throw new Error("no anime found with this id"); + const config = await settingfetch(); - let Title = animedata.title; let info = []; let errors = []; let Success = []; - let TryToDownload = []; - const config = await settingfetch(); + if (provider.provider_name !== "pahe") { + let TryToDownload = []; + const animedata = await animeinfo(provider.provider, animeid); + if (!animedata) throw new Error("no anime found with this id"); + let Title = animedata.title; - if (!endep) { - TryToDownload.push(startep - 1); - } else { - if (startep > endep) throw new Error("Start ep is greater than End ep"); - for (let i = startep; i <= endep; i++) { - TryToDownload.push(i - 1); + if (!endep) { + TryToDownload.push(startep - 1); + } else { + if (startep > endep) throw new Error("Start ep is greater than End ep"); + for (let i = startep; i <= endep; i++) { + TryToDownload.push(i - 1); + } } - } - // checking if ep are ther in sources - for (let i = 0; i < TryToDownload.length; i++) { - let epid = animedata.episodes[TryToDownload[i]].id; - if (!epid) { - return errors.push( - `${Title} | ${TryToDownload[i] + 1} Not Found [ skiped ]` - ); - } + // checking if ep are ther in sources + for (let i = 0; i < TryToDownload.length; i++) { + let epid = animedata.episodes[TryToDownload[i]].id; + if (!epid) { + return errors.push( + `${Title} | ${TryToDownload[i] + 1} Not Found [ skiped ]` + ); + } - let true_false = await checkEpisodeDownload(epid); + let true_false = await checkEpisodeDownload(epid); - if (true_false) { - errors.push( - `${Title} | ${TryToDownload[i] + 1} Already In Queue [ skiped ]` - ); + if (true_false) { + errors.push( + `${Title} | ${TryToDownload[i] + 1} Already In Queue [ skiped ]` + ); + } else { + await addToQueue({ + Type: "Anime", + EpNum: TryToDownload[i] + 1, + Title: animedata.title, + config: { + provider: config?.provider, + quality: config?.quality, + mergeSubtitles: config?.mergeSubtitles, + subtitleFormat: config?.subtitleFormat, + CustomDownloadLocation: config?.CustomDownloadLocation, + }, + epid: epid, + totalSegments: 0, + currentSegments: 0, + }); + Success.push(`${Title} | ${TryToDownload[i] + 1} Added To queue`); + } } - - await addToQueue({ - Type: "Anime", - EpNum: TryToDownload[i] + 1, - Title: animedata.title, - config: { - provider: config?.provider, - quality: config?.quality, - mergeSubtitles: config?.mergeSubtitles, - subtitleFormat: config?.subtitleFormat, - CustomDownloadLocation: config?.CustomDownloadLocation, - }, - epid: epid, - totalSegments: 0, - currentSegments: 0, + } else { + let currentPage = Math.ceil(startep / 30); + let animedata = await animeinfo(provider.provider, animeid, { + dub: config?.subDub === "dub" ? true : false, + fetch_info: true, + page: currentPage, }); + if (!animedata) throw new Error("no anime found with this id"); + let Title = animedata.title; + + let allEpisodes = [...animedata.episodes]; + if (!endep) { + const episode = animedata.episodes.find((ep) => ep.number === startep); + if (episode) { + allEpisodes = [episode]; + } else { + allEpisodes = []; + errors.push(`${Title} | ${startep} Not Found [skipped]`); + } + } else { + // finding more ep if needed + if (endep && endep > startep) { + let lastFetchedEp = Math.max(...allEpisodes.map((ep) => ep.number)); + let nextPage = currentPage + 1; + while (lastFetchedEp < endep) { + const datanew = await animeinfo(provider.provider, animeid, { + dub: config?.subDub === "dub" ? true : false, + fetch_info: false, + page: nextPage, + }); + if (!datanew || !datanew.episodes || datanew.episodes.length === 0) { + break; + } + allEpisodes = [...allEpisodes, ...datanew.episodes]; + lastFetchedEp = Math.max(...allEpisodes.map((ep) => ep.number)); + nextPage++; + } + } + // filtering ep + allEpisodes = allEpisodes + .filter((ep) => ep.number >= startep && ep.number <= endep) + .sort((a, b) => a.number - b.number); + } + + // doing a foreach + if (allEpisodes.length > 0) { + for (let i = 0; i < allEpisodes.length; i++) { + let epid = allEpisodes[i].id; - Success.push(`${Title} | ${TryToDownload[i] + 1} Added To queue`); + if (!epid) { + return errors.push( + `${Title} | ${allEpisodes[i].number} Not Found [skipped]` + ); + } + + let true_false = await checkEpisodeDownload(epid); + + if (true_false) { + errors.push( + `${Title} | ${allEpisodes[i].number} Already In Queue [ skiped ]` + ); + } else { + await addToQueue({ + Type: "Anime", + EpNum: allEpisodes[i].number, + Title: animedata.title, + config: { + provider: config?.provider, + quality: config?.quality, + mergeSubtitles: config?.mergeSubtitles, + subtitleFormat: config?.subtitleFormat, + CustomDownloadLocation: config?.CustomDownloadLocation, + }, + epid: `${epid}${ + config?.subDub && config?.subDub === "dub" ? "$dub" : "" + }`, + totalSegments: 0, + currentSegments: 0, + }); + Success.push(`${Title} | ${allEpisodes[i].number} Added To queue`); + } + } + } } await saveQueue(); diff --git a/src/backend/utils/AnimeManga.js b/src/backend/utils/AnimeManga.js index 2afa1bd..72bd133 100644 --- a/src/backend/utils/AnimeManga.js +++ b/src/backend/utils/AnimeManga.js @@ -59,8 +59,8 @@ async function findanime(provider, Anime_NAME, page) { }; } // anime info -async function animeinfo(provider, animeId) { - const data = await provider.AnimeInfo(animeId); +async function animeinfo(provider, animeId, ExtraParameters = {}) { + const data = await provider.AnimeInfo(animeId, ExtraParameters); return data; } // fetch m3u8 links diff --git a/src/backend/utils/settings.js b/src/backend/utils/settings.js index 78d6ab5..1b68a5b 100644 --- a/src/backend/utils/settings.js +++ b/src/backend/utils/settings.js @@ -17,7 +17,7 @@ let config = []; const providers = { gogo: require("../Scrappers/gogo"), zoro: require("../Scrappers/zoro"), - // pahe: require("../Scrappers/animepahe"), + pahe: require("../Scrappers/animepahe"), // anivibe: require("../Scrappers/anivibe"), }; @@ -33,7 +33,8 @@ async function settingupdate( mergeSubtitles = null, subtitleFormat = null, Pagination = null, - concurrentDownloads = null + concurrentDownloads = null, + subDub = null ) { const currentSettings = settings.get("config"); // quality @@ -74,6 +75,9 @@ async function settingupdate( } if (subtitleFormat === null) subtitleFormat = currentSettings?.subtitleFormat || "ttv"; + + if (subDub === null) subDub = currentSettings?.subDub || "sub"; + // quality config.quality = quality; // mal on off @@ -96,6 +100,8 @@ async function settingupdate( config.concurrentDownloads = concurrentDownloads; // subtitleFormat config.subtitleFormat = subtitleFormat; + // subDub + config.subDub = subDub; await settingSave(); // return config @@ -109,97 +115,118 @@ async function settingupdate( Pagination, concurrentDownloads, subtitleFormat, + subDub, }; } // returns valid settings async function settingfetch() { - let changes = false; - // making sure download folder exists - if (!config?.CustomDownloadLocation) { - config.CustomDownloadLocation = getDownloadsFolder(); - changes = true; - } - - // if downloads folder exists check if its can be access - if (config?.CustomDownloadLocation) { - try { - await ensureDirectoryExists(config?.CustomDownloadLocation); - } catch (error) { + try { + let changes = false; + // making sure download folder exists + if (!config?.CustomDownloadLocation) { config.CustomDownloadLocation = getDownloadsFolder(); changes = true; } - } - // checking provider is valid - if (!config?.provider || !providers.hasOwnProperty(config?.provider)) { - config.provider = "gogo"; - changes = true; - } - // checking quality - if ( - !config?.quality || - !["1080p", "720p", "360p"].includes(config?.quality) - ) { - config.quality = "1080p"; - changes = true; - } - // checking mergeSubtitles - if ( - !config?.mergeSubtitles || - !["on", "off"].includes(config?.mergeSubtitles) - ) { - config.mergeSubtitles = "on"; - changes = true; - } + // if downloads folder exists check if its can be access + if (config?.CustomDownloadLocation) { + try { + await ensureDirectoryExists(config?.CustomDownloadLocation); + } catch (error) { + config.CustomDownloadLocation = getDownloadsFolder(); + changes = true; + } + } + // checking provider is valid + if (!config?.provider || !providers.hasOwnProperty(config?.provider)) { + config.provider = "gogo"; + changes = true; + } + // checking quality + if ( + !config?.quality || + !["1080p", "720p", "360p"].includes(config?.quality) + ) { + config.quality = "1080p"; + changes = true; + } - // checking subtitle format - if ( - !config?.subtitleFormat || - !["ttv", "srt"].includes(config?.subtitleFormat) - ) { - config.subtitleFormat = "ttv"; - changes = true; - } + // checking mergeSubtitles + if ( + !config?.mergeSubtitles || + !["on", "off"].includes(config?.mergeSubtitles) + ) { + config.mergeSubtitles = "on"; + changes = true; + } - if (changes) { - await settingSave(); - } + // checking subtitle format + if ( + !config?.subtitleFormat || + !["ttv", "srt"].includes(config?.subtitleFormat) + ) { + config.subtitleFormat = "ttv"; + changes = true; + } - return config; + if (!config?.subDub) { + config.subDub = "sub"; + changes = true; + } + + if (changes) { + await settingSave(); + } + + return config; + } catch (err) { + console.log(err); + logger.error(`Error message: ${err.message}`); + logger.error(`Stack trace: ${err.stack}`); + } } // load settings async function SettingsLoad() { - const storedConfig = await settings.get("config"); - config = - storedConfig && typeof storedConfig === "object" - ? storedConfig - : { - quality: "1080p", - mal_on_off: false, - status: "plan_to_watch", - malToken: null, - CustomDownloadLocation: getDownloadsFolder(), - provider: "gogo", - mergeSubtitles: "on", - subtitleFormat: "ttv", - Pagination: "off", - concurrentDownloads: 5, - }; - - if (config.malToken != null) { - await refresh_token(config.malToken); - await MalLogin(token); + try { + const storedConfig = await settings.get("config"); + config = + storedConfig && typeof storedConfig === "object" + ? storedConfig + : { + quality: "1080p", + mal_on_off: false, + status: "plan_to_watch", + malToken: null, + CustomDownloadLocation: getDownloadsFolder(), + provider: "zoro", + mergeSubtitles: "on", + subtitleFormat: "ttv", + Pagination: "off", + concurrentDownloads: 5, + subDub: "sub", + }; + + if (config.malToken != null) { + await refresh_token(config.malToken); + await MalLogin(token); + } + await settingSave(); + } catch (err) { + console.log(err); + logger.error(`Error message: ${err.message}`); + logger.error(`Stack trace: ${err.stack}`); } - await settingSave(); } // fetch which provider async function providerFetch(provider = config.provider) { - return provider && providers[provider] - ? providers[config?.provider] - : providers["gogo"]; + return { + provider_name: provider, + provider: + provider && providers[provider] ? providers[provider] : providers["zoro"], + }; } // sync the config with database diff --git a/src/gui.js b/src/gui.js index 4dba019..75bbd94 100644 --- a/src/gui.js +++ b/src/gui.js @@ -89,6 +89,7 @@ appExpress.post("/api/settings", async (req, res) => { Pagination, concurrentDownloads, subtitleFormat, + subDub, } = req.body; try { if ( @@ -126,7 +127,8 @@ appExpress.post("/api/settings", async (req, res) => { mergeSubtitles, subtitleFormat, Pagination, - concurrentDownloads + concurrentDownloads, + subDub ); const data = await settingfetch(); @@ -152,6 +154,10 @@ appExpress.post("/api/settings", async (req, res) => { // Pagination & concurrentDownloads message += `\nPagination : ${data.Pagination}\nConcurrent Downloads: ${data.concurrentDownloads}`; + if (data.provider === "pahe") { + message += `\nsubDub : ${data.subDub}`; + } + res.status(200).json({ message: message }); } catch (err) { const errorMessage = err.message.split("\n")[0]; @@ -168,7 +174,7 @@ appExpress.post("/api/latest", async (req, res) => { const { page } = req.body; try { const provider = await providerFetch(); - const resentep = await latestAnime(provider, page); + const resentep = await latestAnime(provider.provider, page); res.status(200).json(resentep); } catch (err) { console.log(err); @@ -200,7 +206,7 @@ appExpress.post("/api/findanime", async (req, res) => { title = title.replace("Results For", ""); try { const provider = await providerFetch(); - const animefound = await animesearch(provider, title, page); + const animefound = await animesearch(provider.provider, title, page); res.status(200).json(animefound); } catch (err) { console.log(err); @@ -383,7 +389,7 @@ appExpress.post("/api/watch", async (req, res) => { const { ep, epNum } = req.body; try { const provider = await providerFetch(); - const animedata = await animeinfo(provider, ep); + const animedata = await animeinfo(provider.provider, ep); let AnimeEpId = animedata.episodes[parseInt(epNum) - 1]; const sourcesArray = await fetchEpisodeSources(provider, AnimeEpId?.id) .sources; @@ -402,7 +408,7 @@ appExpress.post("/api/watch", async (req, res) => { // home page appExpress.get("/", async (req, res) => { const provider = await providerFetch(); - const resentep = await latestAnime(provider, 1); + const resentep = await latestAnime(provider.provider, 1); const config = await settingfetch(); res.render("index.ejs", { data: resentep, @@ -477,7 +483,7 @@ appExpress.get("/search", async (req, res) => { } else if (animeToSearch) { try { const provider = await providerFetch(); - const data = await animesearch(provider, animeToSearch); + const data = await animesearch(provider.provider, animeToSearch); res.render("index.ejs", { data: data, catagorie: `Results For ${animeToSearch}`, @@ -505,8 +511,9 @@ appExpress.get("/log", async (req, res) => { appExpress.get("/info", async (req, res) => { const animeId = req.query.animeid.trim(); const provider = await providerFetch(); - const data = await animeinfo(provider, animeId); - res.render("info.ejs", { data: data }); + const data = await animeinfo(provider.provider, animeId); + const setting = await settingfetch(); + res.render("info.ejs", { data: data, subDub: setting?.subDub ?? "sub" }); }); // manga info page appExpress.get("/mangainfo", async (req, res) => { @@ -546,14 +553,10 @@ appExpress.get("/proxy/image", async (req, res) => { try { const response = await ddosGuardRequest(imageUrl, { - responseType: "stream", + responseType: "arraybuffer", }); - - const contentType = - response.headers["content-type"] || "application/octet-stream"; - res.set("Content-Type", contentType); - - response.data.pipe(res); + res.set("Content-Type", response.headers["content-type"]); + res.send(response.data); } catch (error) { console.error("Error fetching image:", error); res.status(500).send("Internal server error."); diff --git a/src/gui/info.ejs b/src/gui/info.ejs index 8459d63..c6ab3fc 100644 --- a/src/gui/info.ejs +++ b/src/gui/info.ejs @@ -1,6 +1,7 @@ + Anime Downloader @@ -132,208 +133,10 @@ -
-
-
- <%= data.title %> - -
- Type : <%= data.type %> ( <%= data.subOrDub ? data.subOrDub : - "UNKNOWN" %> ) -
- Total Episodes: <%= data?.totalEpisodes %> -
- <%= data?.status ? `Status: ${data?.status}` : "" %> <% if - (data?.status) { %> -
- <% } %> <%= data?.subs > 0 ? `Subs Episodes: ${data.subs}` : "" %> - <% if (data?.subs > 0) { %> -
- <% } %> <%= data?.dubs > 0 ? `Dubs Episodes: ${data.dubs}` : "" %> - <% if (data?.dubs > 0) { %> -
- <% } %> -
-
-
-
<%= data.title %>
-
<%= data.description %>
-
- <% data?.genres?.forEach(genre => { %> - - <% }); %> -
-
-

Download Options

-
- - <% if (data.id.includes('-both')) { %> - -
- -
- - -
-
- -
- - - <% } else { %> -
- - -
- -
-
- <% for (let i = data.episodes.length - 1; i >= 0; i--) { %> - - <% } %> -
-
- <% } %> - -
-
-
- + <% if (data?.provider && data.provider === "pahe") { %> <%- + include("info/pahe.ejs") %> <% } else { %> <%- include("info/all.ejs") %> <% + } %> + diff --git a/src/gui/info/all.ejs b/src/gui/info/all.ejs new file mode 100644 index 0000000..76dc82b --- /dev/null +++ b/src/gui/info/all.ejs @@ -0,0 +1,201 @@ +
+
+
+ <%= data.title %> + +
+ Type : <%= data.type %> ( <%= data.subOrDub ? data.subOrDub : "UNKNOWN" + %> ) +
+ Total Episodes: <%= data?.totalEpisodes %> +
+ <%= data?.status ? `Status: ${data?.status}` : "" %> <% if + (data?.status) { %> +
+ <% } %> <%= data?.subs > 0 ? `Subs Episodes: ${data.subs}` : "" %> <% if + (data?.subs > 0) { %> +
+ <% } %> <%= data?.dubs > 0 ? `Dubs Episodes: ${data.dubs}` : "" %> <% if + (data?.dubs > 0) { %> +
+ <% } %> +
+
+
+
<%= data.title %>
+
<%= data.description %>
+
+ <% data?.genres?.forEach(genre => { %> + + <% }); %> +
+
+

Download Options

+
+ + <% if (data.id.includes('-both')) { %> + +
+ +
+ + +
+
+ +
+ + + <% } else { %> +
+ + +
+ +
+
+ <% for (let i = data.episodes.length - 1; i >= 0; i--) { %> + + <% } %> +
+
+ <% } %> + +
+
+
diff --git a/src/gui/info/pahe.ejs b/src/gui/info/pahe.ejs new file mode 100644 index 0000000..bbf7257 --- /dev/null +++ b/src/gui/info/pahe.ejs @@ -0,0 +1,90 @@ +
+
+
+ <%= data.title %> + +
+ Type : <%= data.type %> ( <%= subDub %> ) +
+ Total Episodes: <%= data?.totalEpisodes %> +
+ <%= data?.status ? `Status: ${data?.status}` : "" %> +
+
+
+
<%= data.title %>
+
<%= data.description %>
+
+ <% data?.genres?.forEach(genre => { %> + + <% }); %> +
+
+

Download Options

+
+
+ + +
+ +
+
+ <% for (let i = data.totalEpisodes - 1; i >= 0; i--) { %> + + <% } %> +
+
+ +
+
+
diff --git a/src/gui/settings.ejs b/src/gui/settings.ejs index 0fbb773..75440a7 100644 --- a/src/gui/settings.ejs +++ b/src/gui/settings.ejs @@ -104,7 +104,16 @@ > - + + + + + + @@ -182,6 +191,7 @@ const providerElement = document.getElementById("providerSelect"); const mergeSubtitlesElement = document.getElementById("mergeSubtitles"); const subtitleFormatElement = document.getElementById("subtitleFormat"); + const subDubElement = document.getElementById("subDub"); const data = { status: statusElement ? statusElement.value : null, @@ -200,6 +210,7 @@ concurrentDownloads: concurrentDownloadsElement ? concurrentDownloadsElement.value : null, + subDub: subDubElement ? subDubElement.value : null, }; showLoadingAnimation(); @@ -241,12 +252,18 @@ const mergeSubtitlesElement = document.getElementById("mergeSubtitles"); const subtitleOptionElement = document.getElementById("subtitleOption"); const subtitleFormatOptionElement = document.getElementById("subtitleFormatOption"); + const subDubOptionElement = document.getElementById("subDubOption"); + + subtitleOptionElement.style.display = providerElement.value === "zoro" ? "block" : "none"; + if (providerElement.value === "zoro" && mergeSubtitlesElement.value === "off") { subtitleFormatOptionElement.style.display = "block"; } else { subtitleFormatOptionElement.style.display = "none"; } + + subDubOptionElement.style.display = providerElement.value === "pahe" ? "block" : "none"; } document.getElementById("mergeSubtitles")?.addEventListener("change", toggleSubtitleOption); document.addEventListener("DOMContentLoaded", toggleSubtitleOption); diff --git a/src/package.json b/src/package.json index 40770bd..46e3537 100644 --- a/src/package.json +++ b/src/package.json @@ -1,6 +1,6 @@ { "name": "animedownloader", - "version": "2.6.2", + "version": "2.7.1", "description": "Download anime in batches & its fast :3", "main": "gui.js", "scripts": {