From 742b4f0e40b38a8329126b969a0490ca871577e0 Mon Sep 17 00:00:00 2001 From: Swakshan Date: Tue, 31 Dec 2024 13:13:03 +0530 Subject: [PATCH] extension(soaper): Added details --- javascript/anime/src/all/soaper.js | 46 ++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/javascript/anime/src/all/soaper.js b/javascript/anime/src/all/soaper.js index 07e8e9b5..543329de 100644 --- a/javascript/anime/src/all/soaper.js +++ b/javascript/anime/src/all/soaper.js @@ -6,7 +6,7 @@ const mangayomiSources = [{ "iconUrl": "https://www.google.com/s2/favicons?sz=128&domain=https://soaper.cc/", "typeSource": "multi", "isManga": false, - "version": "0.0.2", + "version": "0.0.3", "dateFormat": "", "dateFormatLocale": "", "pkgPath": "anime/src/all/soaper.js" @@ -42,7 +42,7 @@ class DefaultExtension extends MProvider { for (var movie of movies) { var linkSection = movie.selectFirst("div.img-group > a") - var link = linkSection.getHref; + var link = linkSection.getHref.substring(1,); var poster = linkSection.selectFirst("img").getSrc var imageUrl = `${baseUrl}${poster}` var name = movie.selectFirst("h5").text; @@ -50,7 +50,6 @@ class DefaultExtension extends MProvider { list.push({ name, imageUrl, link }); } - var hasNextPage = false if (slug.indexOf("search.html?") == -1) { var pagination = doc.select("ul.pagination > li") @@ -92,7 +91,6 @@ class DefaultExtension extends MProvider { return await this.filterList("all", "all", "new", page); } - async search(query, page, filters) { var seriesList = [] var movieList = [] @@ -103,7 +101,7 @@ class DefaultExtension extends MProvider { for (var movie of movies) { var link = movie.link - if (link.indexOf("/tv_") != -1) { + if (link.indexOf("tv_") != -1) { seriesList.push(movie); } else { movieList.push(movie); @@ -121,7 +119,43 @@ class DefaultExtension extends MProvider { } async getDetail(url) { - throw new Error("getDetail not implemented"); + var doc = await this.request(url); + + const baseUrl = await this.getPreference("pref_override_base_url") + var name = doc.selectFirst(".col-sm-12.col-lg-12.text-center").selectFirst("h4").text.trim() + var poster = doc.selectFirst(".thumbnail.text-center").selectFirst("img").getSrc + var imageUrl = `${baseUrl}${poster}` + + var description = doc.selectFirst("p#wrap").text.trim() + var link = `${baseUrl}/${url}` + + var chapters = [] + if (url.indexOf("tv_") != -1) { + var seasonList = doc.select(".alert.alert-info-ex.col-sm-12") + var seasonCount = seasonList.length + for (var season of seasonList) { + var eps = season.select(".col-sm-12.col-md-6.col-lg-4.myp1") + for (var ep of eps) { + var epLinkSection = ep.selectFirst("a") + var epLink = epLinkSection.getHref + var epName = epLinkSection.text + + chapters.push({ + name: `S${seasonCount}E${epName}`, + url: epLink, + }) + } + seasonCount--; + } + + } else { + chapters.push({ + name: "Movie", + url: url, + }) + } + + return { name, imageUrl, description, link, chapters } } // For anime episode video list async getVideoList(url) {