diff --git a/.assets/screencasts/intro.webm b/.assets/screencasts/intro.webm new file mode 100644 index 0000000..abc26d3 Binary files /dev/null and b/.assets/screencasts/intro.webm differ diff --git a/fastanime/libs/anime_provider/allanime/normalizer.py b/fastanime/libs/anime_provider/allanime/normalizer.py new file mode 100644 index 0000000..eefb846 --- /dev/null +++ b/fastanime/libs/anime_provider/allanime/normalizer.py @@ -0,0 +1,36 @@ +from .types import AllAnimeSearchResults, AllAnimeShow +from ..types import SearchResults, Anime, EpisodesDetail + + +def normalize_search_results(search_results: AllAnimeSearchResults) -> SearchResults: + page_info = search_results["shows"]["pageInfo"] + results = [] + for result in search_results["shows"]["edges"]: + normalized_result = { + "id": result["_id"], + "title": result["name"], + "type": result["__typename"], + "availableEpisodes": result["availableEpisodes"], + } + results.append(normalized_result) + + normalized_search_results: SearchResults = { + "pageInfo": page_info, + "results": results, + } + + return normalized_search_results + + +def normalize_anime(anime: AllAnimeShow) -> Anime: + id: str = anime["_id"] + title: str = anime["name"] + availableEpisodesDetail: EpisodesDetail = anime["availableEpisodesDetail"] + type: str = anime["__typename"] + normalized_anime: Anime = { + "id": id, + "title": title, + "availableEpisodesDetail": availableEpisodesDetail, + "type": type, + } + return normalized_anime diff --git a/fastanime/libs/anime_provider/allanime/types.py b/fastanime/libs/anime_provider/allanime/types.py new file mode 100644 index 0000000..e986952 --- /dev/null +++ b/fastanime/libs/anime_provider/allanime/types.py @@ -0,0 +1,59 @@ +from typing import Literal, TypedDict + + +class AllAnimeEpisodesInfo(TypedDict): + dub: int + sub: int + raw: int + + +class AllAnimePageInfo(TypedDict): + total: int + + +class AllAnimeShow(TypedDict): + _id: str + name: str + availableEpisodesDetail: AllAnimeEpisodesInfo + __typename: str + + +class AllAnimeSearchResult(TypedDict): + _id: str + name: str + availableEpisodes: list[str] + __typename: str + + +class AllAnimeShows(TypedDict): + pageInfo: AllAnimePageInfo + edges: list[AllAnimeSearchResult] + + +class AllAnimeSearchResults(TypedDict): + shows: AllAnimeShows + + +class AllAnimeSourcesDownloads(TypedDict): + sourceName: str + dowloadUrl: str + + +class AllAnimeSources(TypedDict): + sourceUrl: str + priority: float + sandbox: str + sourceName: str + type: str + className: str + streamerId: str + downloads: AllAnimeSourcesDownloads + + +Server = Literal["gogoanime", "dropbox", "wetransfer", "sharepoint"] + + +class AllAnimeEpisode(TypedDict): + episodeString: str + sourceUrls: list[AllAnimeSources] + notes: str | None diff --git a/fastanime/libs/anime_provider/types.py b/fastanime/libs/anime_provider/types.py new file mode 100644 index 0000000..0abbe7b --- /dev/null +++ b/fastanime/libs/anime_provider/types.py @@ -0,0 +1,32 @@ +from typing import TypedDict + + +class PageInfo(TypedDict): + total: int + + +# search data +class SearchResult(TypedDict): + id: str + title: str + availableEpisodes: list[str] + type: str + + +class SearchResults(TypedDict): + pageInfo: PageInfo + results: list[SearchResult] + + +# anime data +class EpisodesDetail(TypedDict): + dub: int + sub: int + raw: int + + +class Anime(TypedDict): + id: str + title: str + availableEpisodesDetail: EpisodesDetail + type: str