From 1f046447bbe42b413fd70d3bfb93f04abba69107 Mon Sep 17 00:00:00 2001 From: Benex254 Date: Tue, 24 Sep 2024 10:02:49 +0300 Subject: [PATCH] chore: update all instances of aniwatch to hianime --- README.md | 20 ++++++------- fastanime/cli/commands/download.py | 2 +- fastanime/cli/config.py | 10 +++---- fastanime/libs/anime_provider/__init__.py | 7 +++-- fastanime/libs/anime_provider/hianime/api.py | 28 +++++++++---------- .../libs/anime_provider/hianime/types.py | 16 +++++------ 6 files changed, 42 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index 2a142d2..b7afcd9 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ Heavily inspired by [animdl](https://github.com/justfoolingaround/animdl), [jerr > [!IMPORTANT] > -> This project currently scrapes allanime, aniwatch and animepahe. The site is in the public domain and can be accessed by any one with a browser. +> This project currently scrapes allanime, hianime and animepahe. The site is in the public domain and can be accessed by any one with a browser. ## Installation @@ -196,7 +196,7 @@ The only required external dependency, unless you won't be streaming, is [MPV](h ## Usage The project offers a featureful command-line interface and MPV interface through the use of python-mpv. -The project also offers subs in different languages thanks to aniwatch provider. +The project also offers subs in different languages thanks to hianime provider. ### The Commandline interface :fire: @@ -240,7 +240,7 @@ Available options for the fastanime include: - `--default` use the default ui - `--preview` show a preview when using fzf - `--no-preview` dont show a preview when using fzf -- `--format ` or `-f ` set the format of anime downloaded and streamed based on [yt-dlp format](https://github.com/yt-dlp/yt-dlp#format-selection). Works when `--server gogoanime` or on providers that provide multi quality streams eg aniwatch +- `--format ` or `-f ` set the format of anime downloaded and streamed based on [yt-dlp format](https://github.com/yt-dlp/yt-dlp#format-selection). Works when `--server gogoanime` or on providers that provide multi quality streams eg hianime - `--icons/--no-icons` toggle the visibility of the icons - `--skip/--no-skip` whether to skip the opening and ending theme songs. - `--rofi` use rofi for the ui @@ -253,7 +253,7 @@ Available options for the fastanime include: - `--use-mpv-mod/--use-default-player` whether to use python-mpv - `--provider ` anime site of choice to scrape from - `--sync-play` or `-sp` use syncplay for streaming anime so you can watch with your friends -- `--sub-lang ` regex is used to determine the appropriate. Only works when provider is aniwatch. +- `--sub-lang ` regex is used to determine the appropriate. Only works when provider is hianime. - `--normalize-titles/--no-normalize-titles` whether to normalize provider titles - `--manga` toggle experimental manga mode @@ -431,7 +431,7 @@ fastanime download -t -r ':' # remember python indexing starts at 0 fastanime download -t -r ':' -# merge subtitles with ffmpeg to mkv format; aniwatch tends to give subs as separate files +# merge subtitles with ffmpeg to mkv format; hianime tends to give subs as separate files # and dont prompt for anything # eg existing file in destination instead remove # and clean @@ -717,10 +717,10 @@ quality = 1080 # this also applies to episode titles normalize_titles = True -# can be [allanime, animepahe, aniwatch] +# can be [allanime, animepahe, hianime] # allanime is the most realible # animepahe provides different links to streams of different quality so a quality can be selected reliably with --quality option -# aniwatch which is now hianime usually provides subs in different languuages and its servers are generally faster +# hianime which is now hianime usually provides subs in different languuages and its servers are generally faster provider = allanime # Display language [english, romaji] @@ -772,7 +772,7 @@ notification_duration = 2 # used when the provider gives subs of different languages # currently its the case for: -# aniwatch +# hianime # the values for this option are the short names for countries # regex is used to determine what you selected sub_lang = eng @@ -799,7 +799,7 @@ translation_type = sub # what server to use for a particular provider # allanime: [dropbox, sharepoint, wetransfer, gogoanime, wixmp] # animepahe: [kwik] -# aniwatch: [HD1, HD2, StreamSB, StreamTape] +# hianime: [HD1, HD2, StreamSB, StreamTape] # 'top' can also be used as a value for this option # 'top' will cause fastanime to auto select the first server it sees # this saves on resources and is faster since not all servers are being fetched @@ -860,7 +860,7 @@ force_window = immediate # only works for downloaded anime if: # provider=allanime, server=gogoanime # provider=allanime, server=wixmp -# provider=aniwatch +# provider=hianime # this is because they provider a m3u8 file that contans multiple quality streams format = best[height<=1080]/bestvideo[height<=1080]+bestaudio/best diff --git a/fastanime/cli/commands/download.py b/fastanime/cli/commands/download.py index d497b68..05cfd46 100644 --- a/fastanime/cli/commands/download.py +++ b/fastanime/cli/commands/download.py @@ -42,7 +42,7 @@ if TYPE_CHECKING: # remember python indexing starts at 0 fastanime download -t -r ':' \b - # merge subtitles with ffmpeg to mkv format; aniwatch tends to give subs as separate files + # merge subtitles with ffmpeg to mkv format; hianime tends to give subs as separate files # and dont prompt for anything # eg existing file in destination instead remove # and clean diff --git a/fastanime/cli/config.py b/fastanime/cli/config.py index ac419fe..f1afa85 100644 --- a/fastanime/cli/config.py +++ b/fastanime/cli/config.py @@ -295,10 +295,10 @@ quality = {self.quality} # this also applies to episode titles normalize_titles = {self.normalize_titles} -# can be [allanime, animepahe, aniwatch] +# can be [allanime, animepahe, hianime] # allanime is the most realible # animepahe provides different links to streams of different quality so a quality can be selected reliably with --quality option -# aniwatch which is now hianime usually provides subs in different languuages and its servers are generally faster +# hianime which is now hianime usually provides subs in different languuages and its servers are generally faster provider = {self.provider} # Display language [english, romaji] @@ -350,7 +350,7 @@ notification_duration = {self.notification_duration} # used when the provider gives subs of different languages # currently its the case for: -# aniwatch +# hianime # the values for this option are the short names for countries # regex is used to determine what you selected sub_lang = {self.sub_lang} @@ -388,7 +388,7 @@ translation_type = {self.translation_type} # what server to use for a particular provider # allanime: [dropbox, sharepoint, wetransfer, gogoanime, wixmp] # animepahe: [kwik] -# aniwatch: [HD1, HD2, StreamSB, StreamTape] +# hianime: [HD1, HD2, StreamSB, StreamTape] # 'top' can also be used as a value for this option # 'top' will cause fastanime to auto select the first server it sees # this saves on resources and is faster since not all servers are being fetched @@ -450,7 +450,7 @@ force_window = immediate # only works for downloaded anime if: # provider=allanime, server=gogoanime # provider=allanime, server=wixmp -# provider=aniwatch +# provider=hianime # this is because they provider a m3u8 file that contans multiple quality streams format = {self.format} diff --git a/fastanime/libs/anime_provider/__init__.py b/fastanime/libs/anime_provider/__init__.py index 04c67db..669bf14 100644 --- a/fastanime/libs/anime_provider/__init__.py +++ b/fastanime/libs/anime_provider/__init__.py @@ -1,10 +1,11 @@ from .allanime.constants import SERVERS_AVAILABLE as ALLANIME_SERVERS -from .animepahe.constants import SERVERS_AVAILABLE as ANIMEPAHESERVERS -from .hianime.constants import SERVERS_AVAILABLE as ANIWATCHSERVERS +from .animepahe.constants import SERVERS_AVAILABLE as ANIMEPAHE_SERVERS +from .hianime.constants import SERVERS_AVAILABLE as HIANIME_SERVERS anime_sources = { "allanime": "api.AllAnimeAPI", "animepahe": "api.AnimePaheApi", "hianime": "api.HiAnimeApi", + "nyaa": "api.NyaaApi", } -SERVERS_AVAILABLE = [*ALLANIME_SERVERS, *ANIMEPAHESERVERS, *ANIWATCHSERVERS] +SERVERS_AVAILABLE = [*ALLANIME_SERVERS, *ANIMEPAHE_SERVERS, *HIANIME_SERVERS] diff --git a/fastanime/libs/anime_provider/hianime/api.py b/fastanime/libs/anime_provider/hianime/api.py index 1d398d9..875340c 100644 --- a/fastanime/libs/anime_provider/hianime/api.py +++ b/fastanime/libs/anime_provider/hianime/api.py @@ -17,7 +17,7 @@ from ..base_provider import AnimeProvider from ..decorators import debug_provider from ..utils import give_random_quality from .constants import SERVERS_AVAILABLE -from .types import AniWatchStream +from .types import HiAnimeStream logger = logging.getLogger(__name__) @@ -41,7 +41,7 @@ class ParseAnchorAndImgTag(HTMLParser): class HiAnimeApi(AnimeProvider): # HEADERS = {"Referer": "https://hianime.to/home"} - @debug_provider("ANIWATCH") + @debug_provider("HIANIME") def search_for_anime(self, anime_title: str, *args): query = quote_plus(anime_title) url = f"https://hianime.to/search?keyword={query}" @@ -88,20 +88,20 @@ class HiAnimeApi(AnimeProvider): self.search_results = results return {"pageInfo": {}, "results": results} - @debug_provider("ANIWATCH") - def get_anime(self, aniwatch_id, *args): + @debug_provider("HIANIME") + def get_anime(self, hianime_id, *args): anime_result = {} for anime in self.search_results: - if anime["id"] == aniwatch_id: + if anime["id"] == hianime_id: anime_result = anime break - anime_url = f"https://hianime.to/ajax/v2/episode/list/{aniwatch_id}" + anime_url = f"https://hianime.to/ajax/v2/episode/list/{hianime_id}" response = self.session.get(anime_url, timeout=10) if response.ok: response_json = response.json() - aniwatch_anime_page = response_json["html"] + hianime_anime_page = response_json["html"] episodes_info_container_html = get_element_html_by_class( - "ss-list", aniwatch_anime_page + "ss-list", hianime_anime_page ) episodes_info_html_list = get_elements_html_by_class( "ep-item", episodes_info_container_html @@ -127,7 +127,7 @@ class HiAnimeApi(AnimeProvider): for episode in episodes_info_dicts ] return { - "id": aniwatch_id, + "id": hianime_id, "availableEpisodesDetail": { "dub": episodes, "sub": episodes, @@ -138,7 +138,7 @@ class HiAnimeApi(AnimeProvider): "episodes_info": self.episodes_info, } - @debug_provider("ANIWATCH") + @debug_provider("HIANIME") def get_episode_streams( self, anime_id, anime_title, episode, translation_type, *args ): @@ -166,7 +166,7 @@ class HiAnimeApi(AnimeProvider): "server-item", servers_containers_html[0] ) except Exception: - logger.warning("AniWatch: sub not found") + logger.warning("HiAnime: sub not found") servers_html_sub = None # dub servers @@ -175,7 +175,7 @@ class HiAnimeApi(AnimeProvider): "server-item", servers_containers_html[1] ) except Exception: - logger.warning("AniWatch: dub not found") + logger.warning("HiAnime: dub not found") servers_html_dub = None if translation_type == "dub": @@ -185,7 +185,7 @@ class HiAnimeApi(AnimeProvider): if not servers_html: return - @debug_provider("ANIWATCH") + @debug_provider("HIANIME") def _get_server(server_name, server_html): # keys: [ data-type: translation_type, data-id: embed_id, data-server-id: server_id ] servers_info = extract_attributes(server_html) @@ -205,7 +205,7 @@ class HiAnimeApi(AnimeProvider): link_to_streams = f"https://{provider_domain}/embed-{embed_type}/ajax/e-{episode_number}/getSources?id={source_id}" link_to_streams_response = self.session.get(link_to_streams) if link_to_streams_response.ok: - juicy_streams_json: "AniWatchStream" = ( + juicy_streams_json: "HiAnimeStream" = ( link_to_streams_response.json() ) return { diff --git a/fastanime/libs/anime_provider/hianime/types.py b/fastanime/libs/anime_provider/hianime/types.py index 4e1f3e5..1f0cff1 100644 --- a/fastanime/libs/anime_provider/hianime/types.py +++ b/fastanime/libs/anime_provider/hianime/types.py @@ -1,26 +1,26 @@ from typing import Literal, TypedDict -class AniWatchSkipTime(TypedDict): +class HiAnimeSkipTime(TypedDict): start: int end: int -class AniWatchSource(TypedDict): +class HiAnimeSource(TypedDict): file: str type: str -class AniWatchTrack(TypedDict): +class HiAnimeTrack(TypedDict): file: str label: str kind: Literal["captions", "thumbnails", "audio"] -class AniWatchStream(TypedDict): - sources: list[AniWatchSource] - tracks: list[AniWatchTrack] +class HiAnimeStream(TypedDict): + sources: list[HiAnimeSource] + tracks: list[HiAnimeTrack] encrypted: bool - intro: AniWatchSkipTime - outro: AniWatchSkipTime + intro: HiAnimeSkipTime + outro: HiAnimeSkipTime server: int