diff --git a/fastanime/Utility/data.py b/fastanime/Utility/data.py index ccef0ab..bfe2a85 100644 --- a/fastanime/Utility/data.py +++ b/fastanime/Utility/data.py @@ -12,11 +12,11 @@ anime_normalizer_raw = { "Re:Zero kara Hajimeru Isekai Seikatsu Season 3": "Re:Zero kara Hajimeru Isekai Seikatsu 3rd Season", }, "hianime": {"My Star": "Oshi no Ko"}, - "animepahe": { + "animepahe": { "Azumanga Daiou The Animation": "Azumanga Daioh", "Mairimashita! Iruma-kun 2nd Season": "Mairimashita! Iruma-kun 2", - "Mairimashita! Iruma-kun 3rd Season": "Mairimashita! Iruma-kun 3" - }, + "Mairimashita! Iruma-kun 3rd Season": "Mairimashita! Iruma-kun 3", + }, "nyaa": {}, "yugen": {}, } diff --git a/fastanime/Utility/downloader/downloader.py b/fastanime/Utility/downloader/downloader.py index 20f5bb5..7d5b951 100644 --- a/fastanime/Utility/downloader/downloader.py +++ b/fastanime/Utility/downloader/downloader.py @@ -97,9 +97,7 @@ class YtDLPDownloader: if i == 0: if force_ffmpeg: options = options | { - "external_downloader": { - 'default': 'ffmpeg' - }, + "external_downloader": {"default": "ffmpeg"}, "external_downloader_args": { "ffmpeg_i1": ["-v", "error", "-stats"], }, diff --git a/fastanime/libs/anime_provider/__init__.py b/fastanime/libs/anime_provider/__init__.py index d637896..6c3155a 100644 --- a/fastanime/libs/anime_provider/__init__.py +++ b/fastanime/libs/anime_provider/__init__.py @@ -7,6 +7,6 @@ anime_sources = { "animepahe": "api.AnimePahe", "hianime": "api.HiAnime", "nyaa": "api.Nyaa", - "yugen": "api.Yugen" + "yugen": "api.Yugen", } SERVERS_AVAILABLE = [*ALLANIME_SERVERS, *ANIMEPAHE_SERVERS, *HIANIME_SERVERS] diff --git a/fastanime/libs/anime_provider/allanime/api.py b/fastanime/libs/anime_provider/allanime/api.py index 9d25a3f..86b6a4c 100644 --- a/fastanime/libs/anime_provider/allanime/api.py +++ b/fastanime/libs/anime_provider/allanime/api.py @@ -13,7 +13,7 @@ from .constants import ( DEFAULT_NSFW, DEFAULT_PAGE, DEFAULT_UNKNOWN, - MP4_SERVER_JUICY_STREAM_REGEX + MP4_SERVER_JUICY_STREAM_REGEX, ) from .gql_queries import EPISODES_GQL, SEARCH_GQL, SHOW_GQL @@ -248,10 +248,10 @@ class AllAnime(AnimeProvider): response = self.session.get( url, timeout=10, - ) + ) response.raise_for_status() - embed_html=response.text.replace(" ","").replace("\n","") - vid=MP4_SERVER_JUICY_STREAM_REGEX.search(embed_html) + embed_html = response.text.replace(" ", "").replace("\n", "") + vid = MP4_SERVER_JUICY_STREAM_REGEX.search(embed_html) if not vid: return return { @@ -260,7 +260,7 @@ class AllAnime(AnimeProvider): "subtitles": [], "episode_title": (allanime_episode["notes"] or f"{anime_title}") + f"; Episode {episode_number}", - "links": [{"link":vid.group(1),"quality":"1080"}], + "links": [{"link": vid.group(1), "quality": "1080"}], } case "Fm-Hls": # TODO: requires decoding obsfucated js (filemoon) @@ -268,10 +268,10 @@ class AllAnime(AnimeProvider): response = self.session.get( url, timeout=10, - ) + ) response.raise_for_status() - embed_html=response.text.replace(" ", "").replace("\n","") - vid=MP4_SERVER_JUICY_STREAM_REGEX.search(embed_html) + embed_html = response.text.replace(" ", "").replace("\n", "") + vid = MP4_SERVER_JUICY_STREAM_REGEX.search(embed_html) if not vid: return return { @@ -280,17 +280,17 @@ class AllAnime(AnimeProvider): "subtitles": [], "episode_title": (allanime_episode["notes"] or f"{anime_title}") + f"; Episode {episode_number}", - "links": [{"link":vid.group(1),"quality":"1080"}], + "links": [{"link": vid.group(1), "quality": "1080"}], } case "Ok": # TODO: requires decoding the obsfucated js (filemoon) response = self.session.get( url, timeout=10, - ) + ) response.raise_for_status() - embed_html=response.text.replace(" ","").replace("\n","") - vid=MP4_SERVER_JUICY_STREAM_REGEX.search(embed_html) + embed_html = response.text.replace(" ", "").replace("\n", "") + vid = MP4_SERVER_JUICY_STREAM_REGEX.search(embed_html) logger.debug("Found streams from Ok") return { "server": "filemoon", @@ -305,9 +305,9 @@ class AllAnime(AnimeProvider): response = self.session.get( url, timeout=10, - ) + ) response.raise_for_status() - embed_html=response.text.replace(" ","").replace("\n","") + embed_html = response.text.replace(" ", "").replace("\n", "") logger.debug("Found streams from vid-mp4") return { "server": "Vid-mp4", @@ -322,9 +322,9 @@ class AllAnime(AnimeProvider): response = self.session.get( url, timeout=10, - ) + ) response.raise_for_status() - embed_html=response.text.replace(" ","").replace("\n","") + embed_html = response.text.replace(" ", "").replace("\n", "") logger.debug("Found streams from Ss-Hls") return { "server": "StreamSb", @@ -405,6 +405,7 @@ class AllAnime(AnimeProvider): + f"; Episode {episode_number}", "links": give_random_quality(response.json()["links"]), } + for embed in allanime_episode["sourceUrls"]: # filter the working streams no need to get all since the others are mostly hsl # TODO: should i just get all the servers and handle the hsl?? @@ -483,7 +484,7 @@ if __name__ == "__main__": selected_stream = streams[server_choice] stream_link = selected_stream["links"][0]["link"] - mpv_args=["mpv", stream_link] + mpv_args = ["mpv", stream_link] headers = selected_stream["headers"] if headers: mpv_headers = "--http-header-fields=" diff --git a/fastanime/libs/anime_provider/allanime/constants.py b/fastanime/libs/anime_provider/allanime/constants.py index ed65eb1..9b6a063 100644 --- a/fastanime/libs/anime_provider/allanime/constants.py +++ b/fastanime/libs/anime_provider/allanime/constants.py @@ -1,4 +1,12 @@ -SERVERS_AVAILABLE = ["sharepoint", "dropbox", "gogoanime", "weTransfer", "wixmp", "Yt","mp4-upload"] +SERVERS_AVAILABLE = [ + "sharepoint", + "dropbox", + "gogoanime", + "weTransfer", + "wixmp", + "Yt", + "mp4-upload", +] API_BASE_URL = "allanime.day" API_REFERER = "https://allanime.to/" API_ENDPOINT = f"https://api.{API_BASE_URL}/api/" @@ -13,4 +21,6 @@ DEFAULT_PAGE = 1 # regex stuff import re -MP4_SERVER_JUICY_STREAM_REGEX = re.compile(r"video/mp4\",src:\"(https?://.*/video\.mp4)\"") \ No newline at end of file +MP4_SERVER_JUICY_STREAM_REGEX = re.compile( + r"video/mp4\",src:\"(https?://.*/video\.mp4)\"" +) diff --git a/fastanime/libs/anime_provider/base_provider.py b/fastanime/libs/anime_provider/base_provider.py index 254340e..693068d 100644 --- a/fastanime/libs/anime_provider/base_provider.py +++ b/fastanime/libs/anime_provider/base_provider.py @@ -6,6 +6,7 @@ from yt_dlp.utils.networking import random_user_agent from ...constants import APP_CACHE_DIR from .providers_store import ProviderStore + class AnimeProvider: session: requests.Session diff --git a/fastanime/libs/anime_provider/nyaa/api.py b/fastanime/libs/anime_provider/nyaa/api.py index 2643b3e..077fd21 100644 --- a/fastanime/libs/anime_provider/nyaa/api.py +++ b/fastanime/libs/anime_provider/nyaa/api.py @@ -32,9 +32,7 @@ class Nyaa(AnimeProvider): @debug_provider def search_for_anime(self, user_query: str, *args, **_): - self.search_results = search_for_anime_with_anilist( - user_query, True - ) # pyright: ignore + self.search_results = search_for_anime_with_anilist(user_query, True) # pyright: ignore self.user_query = user_query return self.search_results diff --git a/fastanime/libs/anime_provider/yugen/api.py b/fastanime/libs/anime_provider/yugen/api.py index 63932ac..08a0cd3 100644 --- a/fastanime/libs/anime_provider/yugen/api.py +++ b/fastanime/libs/anime_provider/yugen/api.py @@ -117,7 +117,9 @@ class Yugen(AnimeProvider): if sub_match: eps = int(sub_match.group(1)) - data_map["availableEpisodesDetail"]["sub"] = list(map(str,range(1, eps + 1))) + data_map["availableEpisodesDetail"]["sub"] = list( + map(str, range(1, eps + 1)) + ) dub_match = re.search( r'