diff --git a/anime/source_generator.dart b/anime/source_generator.dart index d9bed9f8..3e4a2b3a 100644 --- a/anime/source_generator.dart +++ b/anime/source_generator.dart @@ -8,6 +8,7 @@ import 'src/ar/okanime/source.dart'; import 'src/en/aniwave/source.dart'; import 'src/en/gogoanime/source.dart'; import 'src/en/kisskh/source.dart'; +import 'src/en/uhdmovies/source.dart'; import 'src/fr/animesultra/source.dart'; import 'src/fr/franime/source.dart'; import 'src/fr/otakufr/source.dart'; @@ -16,7 +17,6 @@ import 'src/id/oploverz/source.dart'; import 'src/id/otakudesu/source.dart'; import 'src/it/animesaturn/source.dart'; - void main() { List _sourcesList = [ gogoanimeSource, @@ -31,7 +31,8 @@ void main() { oploverz, aniwave, ...dopeflixSourcesList, - animesaturn + animesaturn, + uhdmoviesSource ]; final List> jsonList = _sourcesList.map((source) => source.toJson()).toList(); diff --git a/anime/src/en/uhdmovies/icon.png b/anime/src/en/uhdmovies/icon.png new file mode 100644 index 00000000..073e44f1 Binary files /dev/null and b/anime/src/en/uhdmovies/icon.png differ diff --git a/anime/src/en/uhdmovies/source.dart b/anime/src/en/uhdmovies/source.dart new file mode 100644 index 00000000..43e95a69 --- /dev/null +++ b/anime/src/en/uhdmovies/source.dart @@ -0,0 +1,16 @@ +import '../../../../model/source.dart'; + +Source get uhdmoviesSource => _uhdmoviesSource; +const _uhdmoviesVersion = "0.0.1"; +const _uhdmoviesSourceCodeUrl = + "https://raw.githubusercontent.com/kodjodevf/mangayomi-extensions/main/anime/src/en/uhdmovies/uhdmovies-v$_uhdmoviesVersion.dart"; +Source _uhdmoviesSource = Source( + name: "uhdmovies", + baseUrl: "https://uhdmovies.zip", + lang: "en", + typeSource: "single", + iconUrl: + "https://raw.githubusercontent.com/kodjodevf/mangayomi-extensions/main/anime/src/en/uhdmovies/icon.png", + sourceCodeUrl: _uhdmoviesSourceCodeUrl, + version: _uhdmoviesVersion, + isManga: false); diff --git a/anime/src/en/uhdmovies/uhdmovies-v0.0.1.dart b/anime/src/en/uhdmovies/uhdmovies-v0.0.1.dart new file mode 100644 index 00000000..25b18c82 --- /dev/null +++ b/anime/src/en/uhdmovies/uhdmovies-v0.0.1.dart @@ -0,0 +1,236 @@ +import 'package:mangayomi/bridge_lib.dart'; +import 'dart:convert'; + +class UHDMovies extends MProvider { + UHDMovies(); + + @override + bool get supportsLatest => false; + + @override + Future getPopular(MSource source, int page) async { + final data = {"url": "${preferenceBaseUrl(source.id)}/page/$page"}; + final res = await http('GET', json.encode(data)); + return animeFromElement(res); + } + + @override + Future getLatestUpdates(MSource source, int page) async { + return MPages([], false); + } + + @override + Future search( + MSource source, String query, int page, FilterList filterList) async { + final url = + '${preferenceBaseUrl(source.id)}/page/$page/?s=${query.replaceAll(" ", "+")}'; + final data = {"url": url}; + final res = await http('GET', json.encode(data)); + return animeFromElement(res); + } + + @override + Future getDetail(MSource source, String url) async { + url = Uri.parse(url).path; + final data = {"url": "${preferenceBaseUrl(source.id)}${url}"}; + String res = await http('GET', json.encode(data)); + MManga anime = MManga(); + final description = xpath(res, '//pre/span/text()'); + if (description.isNotEmpty) { + anime.description = description.first; + } + anime.status = MStatus.ongoing; + final episodesTitles = xpath(res, + '//*[contains(@style, "center") or contains(@class, "maxbutton")]/a[contains(@class, "maxbutton") or contains(@href, "?sid=")]/text()'); + final episodesUrls = xpath(res, + '//*[contains(@style, "center") or contains(@class, "maxbutton")]/a[contains(@class, "maxbutton") or contains(@href, "?sid=")]/@href'); + bool isSeries = false; + if (episodesTitles.first.contains("Episode") || + episodesTitles.first.contains("Zip") || + episodesTitles.first.contains("Pack")) { + isSeries = true; + } + List? episodesList = []; + if (!isSeries) { + final moviesTitles = xpath(res, + '//*[contains(@style, "center") or contains(@class, "maxbutton")]/parent::p//preceding-sibling::p[contains(@style, "center")]/text()'); + List titles = []; + for (var title in moviesTitles) { + if (title.isNotEmpty && !title.contains('Download')) { + titles.add(title.split('[').first.trim()); + } + } + for (var i = 0; i < titles.length; i++) { + final title = titles[i]; + final url = episodesUrls[i]; + MChapter ep = MChapter(); + ep.name = title; + ep.url = url; + episodesList.add(ep); + } + } else { + List seasonTitles = []; + final episodeTitles = xpath(res, + '//*[contains(@style, "center") or contains(@class, "maxbutton")]/parent::p//preceding-sibling::p[contains(@style, "center") and not(text()^="Episode")]/text()'); + List titles = []; + for (var title in episodeTitles) { + if (title.isNotEmpty) { + titles.add(title.split('[').first.trim()); + } + } + int number = 0; + for (var i = 0; i < episodesTitles.length; i++) { + final episode = episodesTitles[i]; + final episodeUrl = episodesUrls[i]; + if (!episode.contains("Zip") || !episode.contains("Pack")) { + if (episode == "Episode 1" && seasonTitles.contains("Episode 1")) { + number++; + } else if (episode == "Episode 1") { + seasonTitles.add(episode); + } + final season = + RegExp(r'S(\d{2})').firstMatch(titles[number]).group(1); + final quality = + RegExp(r'\d{3,4}p').firstMatch(titles[number]).group(0); + MChapter ep = MChapter(); + ep.name = "Season $season $episode $quality"; + ep.url = episodeUrl; + episodesList.add(ep); + } + } + } + anime.chapters = episodesList.reversed.toList(); + return anime; + } + + @override + Future> getVideoList(MSource source, String url) async { + final res = await getMediaUrl(url); + return await extractVideos(res); + } + + @override + List getSourcePreferences(MSource source) { + return [ + EditTextPreference( + key: "pref_domain", + title: "Currently used domain", + summary: "", + value: "https://uhdmovies.zip", + dialogTitle: "Currently used domain", + dialogMessage: "", + text: "https://uhdmovies.zip"), + ]; + } + + String preferenceBaseUrl(int sourceId) { + return getPreferenceValue(sourceId, "pref_domain"); + } + + Future> extractVideos(String url) async { + List videos = []; + for (int type = 1; type < 3; type++) { + url = url.replaceAll("/file/", "/wfile/") + "?type=$type"; + final res = await http('GET', json.encode({"url": url})); + final links = xpath(res, '//div[@class="mb-4"]/a/@href'); + for (int i = 0; i < links.length; i++) { + final link = links[i]; + String decodedLink = link; + if (!link.contains("workers.dev")) { + decodedLink = utf8 + .decode(base64Url.decode(substringAfter(link, "download?url="))); + } + MVideo video = MVideo(); + video + ..url = decodedLink + ..originalUrl = decodedLink + ..quality = "CF $type Worker ${i + 1}"; + videos.add(video); + } + } + return videos; + } + + Future getMediaUrl(String url) async { + String res = ""; + String host = ""; + if (url.contains("?sid=")) { + final finalUrl = await redirectorBypasser(url); + host = Uri.parse(finalUrl).host; + res = await http('GET', json.encode({"url": finalUrl})); + } else if (url.contains("r?key=")) { + res = await http('GET', json.encode({"url": url})); + host = Uri.parse(url).host; + } else { + return ""; + } + final path = substringBefore(substringAfter(res, "replace(\""), "\""); + if (path == "/404") return ""; + return "https://$host$path"; + } + + Future redirectorBypasser(String url) async { + final res = await http('GET', json.encode({"url": url})); + String lastDoc = await recursiveDoc(url, res); + final js = xpath(lastDoc, '//script[contains(text(), "/?go=")]/text()'); + if (js.isEmpty) return ""; + String script = js.first; + String nextUrl = + substringBefore(substringAfter(script, "\"href\",\""), '"'); + if (!nextUrl.contains("http")) return ""; + String cookieName = substringAfter(nextUrl, "go="); + String cookieValue = + substringBefore(substringAfter(script, "'$cookieName', '"), "'"); + final response = await http( + 'GET', + json.encode({ + "url": nextUrl, + "headers": {"referer": url, "Cookie": "$cookieName=$cookieValue"} + })); + final lastRes = querySelectorAll(response, + selector: "meta[http-equiv]", + typeElement: 3, + attributes: "content", + typeRegExp: 0) + .first; + return substringAfter(lastRes, "url="); + } + + MPages animeFromElement(String res) { + List animeList = []; + final urls = xpath(res, '//*[@class="entry-image"]/a/@href'); + final names = xpath(res, '//*[@class="entry-image"]/a/@title'); + final images = xpath(res, '//*[@class="entry-image"]/a/img/@src'); + + for (var i = 0; i < names.length; i++) { + MManga anime = MManga(); + anime.name = names[i].replaceAll("Download", ""); + anime.imageUrl = images[i]; + anime.link = urls[i]; + animeList.add(anime); + } + final nextPage = xpath(res, '//a[@class="next page-numbers"]/@href'); + return MPages(animeList, nextPage.isNotEmpty); + } + + Future recursiveDoc(String url, String html) async { + final urlR = xpath(html, '//form[@id="landing"]/@action'); + if (urlR.isEmpty) return html; + final name = xpath(html, '//input/@name').first; + final value = xpath(html, '//input/@value').first; + final body = {"$name": value}; + final response = await http( + 'POST', + json.encode({ + "useFormBuilder": true, + "body": body, + "url": urlR.first, + "headers": {"referer": url} + })); + return recursiveDoc(url, response); + } +} + +UHDMovies main() { + return UHDMovies(); +} diff --git a/anime/src/fr/otakufr/otakufr-v0.0.5.dart b/anime/src/fr/otakufr/otakufr-v0.0.55.dart similarity index 99% rename from anime/src/fr/otakufr/otakufr-v0.0.5.dart rename to anime/src/fr/otakufr/otakufr-v0.0.55.dart index 29b40b13..86fca4d9 100644 --- a/anime/src/fr/otakufr/otakufr-v0.0.5.dart +++ b/anime/src/fr/otakufr/otakufr-v0.0.55.dart @@ -6,11 +6,8 @@ class OtakuFr extends MProvider { @override Future getPopular(MSource source, int page) async { - final data = { - "url": "${source.baseUrl}/toute-la-liste-affiches/page/$page/?q=." - }; + final data = {"url": "${source.baseUrl}/en-cours/page/$page"}; final res = await http('GET', json.encode(data)); - List animeList = []; final urls = xpath(res, '//*[@class="list"]/article/div/div/figure/a/@href'); @@ -285,7 +282,7 @@ class OtakuFr extends MProvider { return [ ListPreference( key: "preferred_quality", - title: "Preferred Quality", + title: "Qualité préférée", summary: "", valueIndex: 1, entries: ["1080p", "720p", "480p", "360p"], diff --git a/anime/src/fr/otakufr/source.dart b/anime/src/fr/otakufr/source.dart index 07c2e23d..29067005 100644 --- a/anime/src/fr/otakufr/source.dart +++ b/anime/src/fr/otakufr/source.dart @@ -1,7 +1,7 @@ import '../../../../model/source.dart'; Source get otakufr => _otakufr; -const otakufrVersion = "0.0.5"; +const otakufrVersion = "0.0.55"; const otakufrCodeUrl = "https://raw.githubusercontent.com/kodjodevf/mangayomi-extensions/main/anime/src/fr/otakufr/otakufr-v$otakufrVersion.dart"; Source _otakufr = Source(