Skip to content

Commit

Permalink
index on master: 53823f0 chore:recover lost stash changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Benex254 committed Jul 12, 2024
1 parent 53823f0 commit 73ce357
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 0 deletions.
Binary file added .assets/screencasts/intro.webm
Binary file not shown.
36 changes: 36 additions & 0 deletions fastanime/libs/anime_provider/allanime/normalizer.py
Original file line number Diff line number Diff line change
@@ -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
59 changes: 59 additions & 0 deletions fastanime/libs/anime_provider/allanime/types.py
Original file line number Diff line number Diff line change
@@ -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
32 changes: 32 additions & 0 deletions fastanime/libs/anime_provider/types.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 73ce357

Please sign in to comment.