mirror of
https://github.com/Benexl/FastAnime.git
synced 2025-12-13 00:00:01 -08:00
feat: abstract provider testing
This commit is contained in:
7
fa
7
fa
@@ -1,3 +1,6 @@
|
||||
#!/usr/bin/env sh
|
||||
CLI_DIR="$(dirname "$(realpath "$0")")"
|
||||
exec uv run --directory "$CLI_DIR/../" fastanime "$@"
|
||||
provider_type=$1
|
||||
provider_name=$2
|
||||
[ -z "$provider_type" ] && echo "Please specify provider type" && exit
|
||||
[ -z "$provider_name" ] && echo "Please specify provider type" && exit
|
||||
uv run python -m fastanime.libs.providers.${provider_type}.${provider_name}.provider
|
||||
|
||||
@@ -41,14 +41,6 @@ except ModuleNotFoundError:
|
||||
FZF_DEFAULT_OPTS = DEFAULTS / "fzf-opts"
|
||||
|
||||
|
||||
APP_ASCII_ART = """\
|
||||
███████╗░█████╗░░██████╗████████╗░█████╗░███╗░░██╗██╗███╗░░░███╗███████╗
|
||||
██╔════╝██╔══██╗██╔════╝╚══██╔══╝██╔══██╗████╗░██║██║████╗░████║██╔════╝
|
||||
█████╗░░███████║╚█████╗░░░░██║░░░███████║██╔██╗██║██║██╔████╔██║█████╗░░
|
||||
██╔══╝░░██╔══██║░╚═══██╗░░░██║░░░██╔══██║██║╚████║██║██║╚██╔╝██║██╔══╝░░
|
||||
██║░░░░░██║░░██║██████╔╝░░░██║░░░██║░░██║██║░╚███║██║██║░╚═╝░██║███████╗
|
||||
╚═╝░░░░░╚═╝░░╚═╝╚═════╝░░░░╚═╝░░░╚═╝░░╚═╝╚═╝░░╚══╝╚═╝╚═╝░░░░░╚═╝╚══════╝
|
||||
"""
|
||||
USER_NAME = os.environ.get("USERNAME", "Anime Fan")
|
||||
|
||||
try:
|
||||
@@ -62,9 +54,11 @@ except ModuleNotFoundError:
|
||||
folder = Path.home()
|
||||
APP_DATA_DIR = Path(folder) / APP_NAME
|
||||
if PLATFORM == "darwin":
|
||||
APP_DATA_DIR = Path("~/Library/Application Support") / APP_NAME
|
||||
APP_DATA_DIR = Path(Path.home() / "Library" / "Application Support" / APP_NAME)
|
||||
|
||||
APP_DATA_DIR = Path(os.environ.get("XDG_CONFIG_HOME", "~/.config")) / APP_NAME
|
||||
APP_DATA_DIR = (
|
||||
Path(os.environ.get("XDG_CONFIG_HOME", Path.home() / ".config")) / APP_NAME
|
||||
)
|
||||
|
||||
if PLATFORM == "win32":
|
||||
APP_CACHE_DIR = APP_DATA_DIR / "cache"
|
||||
@@ -75,10 +69,10 @@ elif PLATFORM == "darwin":
|
||||
USER_VIDEOS_DIR = Path.home() / "Movies" / APP_NAME
|
||||
|
||||
else:
|
||||
xdg_cache_home = Path(os.environ.get("XDG_CACHE_HOME", "~/.cache"))
|
||||
xdg_cache_home = Path(os.environ.get("XDG_CACHE_HOME", Path.home() / ".cache"))
|
||||
APP_CACHE_DIR = xdg_cache_home / APP_NAME
|
||||
|
||||
xdg_videos_dir = Path(os.environ.get("XDG_VIDEOS_DIR", "~/Videos"))
|
||||
xdg_videos_dir = Path(os.environ.get("XDG_VIDEOS_DIR", Path.home() / "Videos"))
|
||||
USER_VIDEOS_DIR = xdg_videos_dir / APP_NAME
|
||||
|
||||
APP_DATA_DIR.mkdir(parents=True, exist_ok=True)
|
||||
@@ -91,3 +85,13 @@ USER_CONFIG_PATH = APP_DATA_DIR / "config.ini"
|
||||
LOG_FILE_PATH = APP_CACHE_DIR / "fastanime.log"
|
||||
|
||||
ICON_PATH = ICONS_DIR / ("logo.ico" if PLATFORM == "Win32" else "logo.png")
|
||||
|
||||
|
||||
APP_ASCII_ART = """\
|
||||
███████╗░█████╗░░██████╗████████╗░█████╗░███╗░░██╗██╗███╗░░░███╗███████╗
|
||||
██╔════╝██╔══██╗██╔════╝╚══██╔══╝██╔══██╗████╗░██║██║████╗░████║██╔════╝
|
||||
█████╗░░███████║╚█████╗░░░░██║░░░███████║██╔██╗██║██║██╔████╔██║█████╗░░
|
||||
██╔══╝░░██╔══██║░╚═══██╗░░░██║░░░██╔══██║██║╚████║██║██║╚██╔╝██║██╔══╝░░
|
||||
██║░░░░░██║░░██║██████╔╝░░░██║░░░██║░░██║██║░╚███║██║██║░╚═╝░██║███████╗
|
||||
╚═╝░░░░░╚═╝░░╚═╝╚═════╝░░░░╚═╝░░░╚═╝░░╚═╝╚═╝░░╚══╝╚═╝╚═╝░░░░░╚═╝╚══════╝
|
||||
"""
|
||||
|
||||
@@ -24,6 +24,9 @@ def debug_provider(provider_function):
|
||||
|
||||
|
||||
def test_anime_provider(AnimeProvider: Type[BaseAnimeProvider]):
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
from httpx import Client
|
||||
from yt_dlp.utils.networking import random_user_agent
|
||||
|
||||
@@ -61,4 +64,23 @@ def test_anime_provider(AnimeProvider: Type[BaseAnimeProvider]):
|
||||
|
||||
if not episode_streams:
|
||||
return
|
||||
print(list(episode_streams))
|
||||
episode_streams = list(episode_streams)
|
||||
for i, stream in enumerate(episode_streams):
|
||||
print(f"{i + 1}: {stream.name}")
|
||||
stream = episode_streams[int(input("Select your preferred server: ")) - 1]
|
||||
if executable := shutil.which("mpv"):
|
||||
cmd = executable
|
||||
elif executable := shutil.which("xdg-open"):
|
||||
cmd = executable
|
||||
elif executable := shutil.which("open"):
|
||||
cmd = executable
|
||||
else:
|
||||
return
|
||||
|
||||
print(
|
||||
"Now streaming: ",
|
||||
anime.title,
|
||||
"Episode: ",
|
||||
stream.episode_title if stream.episode_title else episode_number,
|
||||
)
|
||||
subprocess.run([cmd, stream.links[0].link])
|
||||
|
||||
Reference in New Issue
Block a user