mirror of
https://github.com/Benexl/FastAnime.git
synced 2025-12-25 12:24:52 -08:00
add docs to AnimeProvider module
This commit is contained in:
@@ -1,13 +1,27 @@
|
||||
"""An abstraction over all providers offering added features with a simple and well typed api
|
||||
|
||||
[TODO:description]
|
||||
"""
|
||||
|
||||
import logging
|
||||
from typing import Iterator
|
||||
|
||||
from .libs.anilist.anilist_data_schema import AnilistBaseMediaDataSchema
|
||||
from .libs.anime_provider import anime_sources
|
||||
from .libs.anime_provider.types import Anime, SearchResults, Server
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class AnimeProvider:
|
||||
"""
|
||||
Class that manages all anime sources adding some extra functionality to them.
|
||||
"""Class that manages all anime sources adding some extra functionality to them.
|
||||
Attributes:
|
||||
PROVIDERS: [TODO:attribute]
|
||||
provider: [TODO:attribute]
|
||||
provider: [TODO:attribute]
|
||||
dynamic: [TODO:attribute]
|
||||
retries: [TODO:attribute]
|
||||
anime_provider: [TODO:attribute]
|
||||
"""
|
||||
|
||||
PROVIDERS = list(anime_sources.keys())
|
||||
@@ -20,6 +34,7 @@ class AnimeProvider:
|
||||
self.load_provider_obj()
|
||||
|
||||
def load_provider_obj(self):
|
||||
"""updates the current provider being used"""
|
||||
anime_provider = anime_sources[self.provider]()
|
||||
self.anime_provider = anime_provider
|
||||
|
||||
@@ -31,24 +46,45 @@ class AnimeProvider:
|
||||
nsfw=True,
|
||||
unknown=True,
|
||||
) -> SearchResults | None:
|
||||
"""core abstraction over all providers search functionality
|
||||
|
||||
Args:
|
||||
user_query ([TODO:parameter]): [TODO:description]
|
||||
translation_type ([TODO:parameter]): [TODO:description]
|
||||
nsfw ([TODO:parameter]): [TODO:description]
|
||||
unknown ([TODO:parameter]): [TODO:description]
|
||||
anilist_obj: [TODO:description]
|
||||
|
||||
Returns:
|
||||
[TODO:return]
|
||||
"""
|
||||
anime_provider = self.anime_provider
|
||||
try:
|
||||
results = anime_provider.search_for_anime(
|
||||
user_query, translation_type, nsfw, unknown
|
||||
)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
logging.error(e)
|
||||
results = None
|
||||
return results # pyright:ignore
|
||||
return results
|
||||
|
||||
def get_anime(
|
||||
self, anime_id: str, anilist_obj: AnilistBaseMediaDataSchema | None = None
|
||||
) -> Anime | None:
|
||||
"""core abstraction over getting info of an anime from all providers
|
||||
|
||||
Args:
|
||||
anime_id: [TODO:description]
|
||||
anilist_obj: [TODO:description]
|
||||
|
||||
Returns:
|
||||
[TODO:return]
|
||||
"""
|
||||
anime_provider = self.anime_provider
|
||||
try:
|
||||
results = anime_provider.get_anime(anime_id)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
logging.error(e)
|
||||
results = None
|
||||
return results
|
||||
|
||||
@@ -59,12 +95,23 @@ class AnimeProvider:
|
||||
translation_type: str,
|
||||
anilist_obj: AnilistBaseMediaDataSchema | None = None,
|
||||
) -> Iterator[Server] | None:
|
||||
"""core abstractions for getting juicy streams from all providers
|
||||
|
||||
Args:
|
||||
anime ([TODO:parameter]): [TODO:description]
|
||||
episode: [TODO:description]
|
||||
translation_type: [TODO:description]
|
||||
anilist_obj: [TODO:description]
|
||||
|
||||
Returns:
|
||||
[TODO:return]
|
||||
"""
|
||||
anime_provider = self.anime_provider
|
||||
try:
|
||||
results = anime_provider.get_episode_streams(
|
||||
anime, episode, translation_type
|
||||
)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
logging.error(e)
|
||||
results = None
|
||||
return results # pyright:ignore
|
||||
|
||||
Reference in New Issue
Block a user