mirror of
https://github.com/Benexl/FastAnime.git
synced 2025-12-25 12:24:52 -08:00
feat: quick commit
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
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
|
||||
|
||||
@@ -23,7 +24,12 @@ class AnimeProvider:
|
||||
self.anime_provider = anime_provider
|
||||
|
||||
def search_for_anime(
|
||||
self, user_query, translation_type: str = "sub", nsfw=True, unknown=True
|
||||
self,
|
||||
user_query,
|
||||
translation_type,
|
||||
anilist_obj: AnilistBaseMediaDataSchema,
|
||||
nsfw=True,
|
||||
unknown=True,
|
||||
) -> SearchResults | None:
|
||||
anime_provider = self.anime_provider
|
||||
try:
|
||||
@@ -35,7 +41,9 @@ class AnimeProvider:
|
||||
results = None
|
||||
return results # pyright:ignore
|
||||
|
||||
def get_anime(self, anime_id: str) -> Anime | None:
|
||||
def get_anime(
|
||||
self, anime_id: str, anilist_obj: AnilistBaseMediaDataSchema
|
||||
) -> Anime | None:
|
||||
anime_provider = self.anime_provider
|
||||
try:
|
||||
results = anime_provider.get_anime(anime_id)
|
||||
@@ -45,7 +53,11 @@ class AnimeProvider:
|
||||
return results
|
||||
|
||||
def get_episode_streams(
|
||||
self, anime, episode: str, translation_type: str
|
||||
self,
|
||||
anime,
|
||||
episode: str,
|
||||
translation_type: str,
|
||||
anilist_obj: AnilistBaseMediaDataSchema,
|
||||
) -> Iterator[Server] | None:
|
||||
anime_provider = self.anime_provider
|
||||
try:
|
||||
|
||||
@@ -250,7 +250,10 @@ def fetch_streams(config: Config, anilist_config: QueryDict):
|
||||
with Progress() as progress:
|
||||
progress.add_task("Fetching Episode Streams...", total=None)
|
||||
episode_streams = anime_provider.get_episode_streams(
|
||||
anime, episode_number, translation_type
|
||||
anime,
|
||||
episode_number,
|
||||
translation_type,
|
||||
anilist_config.selected_anime_anilist,
|
||||
)
|
||||
if not episode_streams:
|
||||
if not config.use_rofi:
|
||||
@@ -438,7 +441,9 @@ def fetch_anime_episode(config, anilist_config: QueryDict):
|
||||
anime_provider = config.anime_provider
|
||||
with Progress() as progress:
|
||||
progress.add_task("Fetching Anime Info...", total=None)
|
||||
anilist_config.anime = anime_provider.get_anime(selected_anime["id"])
|
||||
anilist_config.anime = anime_provider.get_anime(
|
||||
selected_anime["id"], anilist_config.selected_anime_anilist
|
||||
)
|
||||
if not anilist_config.anime:
|
||||
print(
|
||||
"Sth went wrong :cry: this could mean the provider is down or your internet"
|
||||
@@ -468,7 +473,9 @@ def provide_anime(config: Config, anilist_config: QueryDict):
|
||||
with Progress() as progress:
|
||||
progress.add_task("Fetching Search Results...", total=None)
|
||||
search_results = anime_provider.search_for_anime(
|
||||
selected_anime_title, translation_type
|
||||
selected_anime_title,
|
||||
translation_type,
|
||||
anilist_config.selected_anime_anilist,
|
||||
)
|
||||
if not search_results:
|
||||
print(
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
from .allanime.api import AllAnimeAPI
|
||||
from .animepahe.api import AnimePaheApi
|
||||
from .aniwatch.api import AniWatchApi
|
||||
|
||||
anime_sources = {"allanime": AllAnimeAPI, "animepahe": AnimePaheApi}
|
||||
anime_sources = {
|
||||
"allanime": AllAnimeAPI,
|
||||
"animepahe": AnimePaheApi,
|
||||
"aniwatch": AniWatchApi,
|
||||
}
|
||||
|
||||
0
fastanime/libs/anime_provider/aniwatch/__init__.py
Normal file
0
fastanime/libs/anime_provider/aniwatch/__init__.py
Normal file
48
fastanime/libs/anime_provider/aniwatch/api.py
Normal file
48
fastanime/libs/anime_provider/aniwatch/api.py
Normal file
@@ -0,0 +1,48 @@
|
||||
from ...anilist.anilist_data_schema import AnilistBaseMediaDataSchema
|
||||
from ..base_provider import AnimeProvider
|
||||
|
||||
"""
|
||||
"Zoro": {
|
||||
"27": {
|
||||
"identifier": "27",
|
||||
"image": "https://cdn.noitatnemucod.net/thumbnail/300x400/100/ce5e539af63e42431621fc66a47fbec1.jpg",
|
||||
"malId": 1,
|
||||
"aniId": 1,
|
||||
"page": "Zoro",
|
||||
"title": "Cowboy Bebop",
|
||||
"type": "anime",
|
||||
"url": "https://hianime.to/cowboy-bebop-27"
|
||||
}
|
||||
},
|
||||
|
||||
episode info = https://hianime.to/ajax/v2/episode/list/27
|
||||
"""
|
||||
|
||||
|
||||
class AniWatchApi(AnimeProvider):
|
||||
def search_for_anime(
|
||||
self, anilist_selected_anime: AnilistBaseMediaDataSchema, *args
|
||||
):
|
||||
return {
|
||||
"pageInfo": 1,
|
||||
"results": [
|
||||
{
|
||||
"id": anilist_selected_anime["id"],
|
||||
"title": anilist_selected_anime["title"],
|
||||
"availableEpisodes": [],
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
def get_anime(self, id: int):
|
||||
url = f"https://raw.githubusercontent.com/bal-mackup/mal-backup/master/anilist/anime/{id}.json"
|
||||
response = self.session.get(url)
|
||||
if response.status_code == 200:
|
||||
data = response.json()
|
||||
data["Sites"]["Zoro"]
|
||||
return {"id": ""}
|
||||
else:
|
||||
return {}
|
||||
|
||||
def get_episode_streams(self, id: int, episode: str, translation_type: str):
|
||||
pass
|
||||
Reference in New Issue
Block a user