diff --git a/fastanime/cli/commands/anilist/__init__.py b/fastanime/cli/commands/anilist/__init__.py index fc6e0f1..520719d 100644 --- a/fastanime/cli/commands/anilist/__init__.py +++ b/fastanime/cli/commands/anilist/__init__.py @@ -1 +1,3 @@ from .cmd import anilist + +__all__ = ["anilist"] diff --git a/fastanime/cli/commands/anilist/commands/stats.py b/fastanime/cli/commands/anilist/commands/stats.py index b39cdca..4ddef7d 100644 --- a/fastanime/cli/commands/anilist/commands/stats.py +++ b/fastanime/cli/commands/anilist/commands/stats.py @@ -19,15 +19,11 @@ def stats(config: "AppConfig"): from .....libs.media_api.api import create_api_client from ....service.auth import AuthService from ....service.feedback import FeedbackService - from ....service.registry import MediaRegistryService console = Console() feedback = FeedbackService(config) auth = AuthService(config.general.media_api) - registry_service = MediaRegistryService( - config.general.media_api, config.media_registry - ) media_api_client = create_api_client(config.general.media_api, config) diff --git a/fastanime/cli/commands/download.py b/fastanime/cli/commands/download.py index 74666f6..51e93e4 100644 --- a/fastanime/cli/commands/download.py +++ b/fastanime/cli/commands/download.py @@ -204,7 +204,6 @@ def download_anime( anime_title: str, episode: str, ): - from ...core.downloader import DownloadParams, create_downloader from ...libs.provider.anime.params import EpisodeStreamsParams diff --git a/fastanime/cli/commands/registry/commands/clean.py b/fastanime/cli/commands/registry/commands/clean.py index 7cc5958..b35ccde 100644 --- a/fastanime/cli/commands/registry/commands/clean.py +++ b/fastanime/cli/commands/registry/commands/clean.py @@ -197,7 +197,6 @@ def _find_old_format_entries(registry_service: MediaRegistryService) -> list: old_format = [] index = registry_service._load_index() - current_version = index.version if index.version != REGISTRY_VERSION: old_format.append( { diff --git a/fastanime/cli/commands/registry/commands/stats.py b/fastanime/cli/commands/registry/commands/stats.py index 57d8c07..0d4517e 100644 --- a/fastanime/cli/commands/registry/commands/stats.py +++ b/fastanime/cli/commands/registry/commands/stats.py @@ -208,7 +208,9 @@ def _create_breakdown_table( total = sum(data.values()) # Determine sorting method - sort_key = lambda item: item[0] if sort_by_key else item[1] + def sort_key(item): + return item[0] if sort_by_key else item[1] + sorted_data = sorted(data.items(), key=sort_key, reverse=reverse_sort) # Apply limit if specified diff --git a/fastanime/cli/interactive/menu/media/play_downloads.py b/fastanime/cli/interactive/menu/media/play_downloads.py index bfa2b40..e03d474 100644 --- a/fastanime/cli/interactive/menu/media/play_downloads.py +++ b/fastanime/cli/interactive/menu/media/play_downloads.py @@ -197,8 +197,6 @@ def _next_episode(ctx: Context, state: State) -> MenuAction: feedback = ctx.feedback - config = ctx.config - media_item = state.media_api.media_item current_episode_num = state.provider.episode @@ -248,8 +246,6 @@ def _previous_episode(ctx: Context, state: State) -> MenuAction: feedback = ctx.feedback - config = ctx.config - media_item = state.media_api.media_item current_episode_num = state.provider.episode diff --git a/fastanime/cli/service/watch_history/service.py b/fastanime/cli/service/watch_history/service.py index 7652378..af9dc3b 100644 --- a/fastanime/cli/service/watch_history/service.py +++ b/fastanime/cli/service/watch_history/service.py @@ -92,7 +92,7 @@ class WatchHistoryService: start_time = None try: current_local_episode = str(int(current_local_episode) + 1) - except: + except Exception: # incase its a float pass else: diff --git a/fastanime/cli/utils/preview_workers.py b/fastanime/cli/utils/preview_workers.py index 9f6f888..7967ab5 100644 --- a/fastanime/cli/utils/preview_workers.py +++ b/fastanime/cli/utils/preview_workers.py @@ -117,7 +117,6 @@ class PreviewCacheWorker(ManagedBackgroundWorker): # Submit info generation task if needed if config.general.preview in ("full", "text"): - info_path = self.info_cache_dir / hash_id info_text = self._generate_info_text(media_item, config) self.submit_function(self._save_info_text, info_text, hash_id) @@ -434,7 +433,6 @@ class ReviewCacheWorker(ManagedBackgroundWorker): for choice_str, review in choice_map.items(): hash_id = self._get_cache_hash(choice_str) - info_path = self.reviews_cache_dir / hash_id preview_content = self._generate_review_preview_content(review, config) self.submit_function(self._save_preview_content, preview_content, hash_id) @@ -522,7 +520,6 @@ class CharacterCacheWorker(ManagedBackgroundWorker): for choice_str, character in choice_map.items(): hash_id = self._get_cache_hash(choice_str) - info_path = self.characters_cache_dir / hash_id preview_content = self._generate_character_preview_content( character, config @@ -645,7 +642,6 @@ class AiringScheduleCacheWorker(ManagedBackgroundWorker): raise RuntimeError("AiringScheduleCacheWorker is not running") hash_id = self._get_cache_hash(anime_title) - info_path = self.airing_schedule_cache_dir / hash_id preview_content = self._generate_airing_schedule_preview_content( anime_title, schedule_result, config diff --git a/fastanime/core/config/defaults.py b/fastanime/core/config/defaults.py index 814ede2..89937d3 100644 --- a/fastanime/core/config/defaults.py +++ b/fastanime/core/config/defaults.py @@ -7,15 +7,28 @@ GENERAL_PREFERRED_SPINNER = "smiley" GENERAL_API_CLIENT = "anilist" GENERAL_PREFERRED_TRACKER = "local" GENERAL_PROVIDER = "allanime" -GENERAL_SELECTOR = lambda: "fzf" if detect.has_fzf() else "default" + + +def GENERAL_SELECTOR(): + return "fzf" if detect.has_fzf() else "default" + + GENERAL_AUTO_SELECT_ANIME_RESULT = True GENERAL_ICONS = True -GENERAL_PREVIEW = lambda: "full" if detect.is_running_kitty_terminal() else "none" + + +def GENERAL_PREVIEW(): + return "full" if detect.is_running_kitty_terminal() else "none" + + GENERAL_SCALE_PREVIEW = True GENERAL_SCALE_PREVIEW = False -GENERAL_IMAGE_RENDERER = ( - lambda: "icat" if detect.is_running_kitty_terminal() else "chafa" -) + + +def GENERAL_IMAGE_RENDERER(): + return "icat" if detect.is_running_kitty_terminal() else "chafa" + + GENERAL_MANGA_VIEWER = "feh" GENERAL_CHECK_FOR_UPDATES = True GENERAL_CACHE_REQUESTS = True @@ -38,9 +51,11 @@ STREAM_YTDLP_FORMAT = "best[height<=1080]/bestvideo[height<=1080]+bestaudio/best STREAM_FORCE_FORWARD_TRACKING = True STREAM_DEFAULT_MEDIA_LIST_TRACKING = "prompt" STREAM_SUB_LANG = "eng" -STREAM_USE_IPC = ( - lambda: True if PLATFORM != "win32" and not detect.is_running_in_termux() else False -) + + +def STREAM_USE_IPC(): + return True if PLATFORM != "win32" and not detect.is_running_in_termux() else False + # WorkerConfig WORKER_ENABLED = True diff --git a/fastanime/core/config/descriptions.py b/fastanime/core/config/descriptions.py index 47ef94d..8ef348b 100644 --- a/fastanime/core/config/descriptions.py +++ b/fastanime/core/config/descriptions.py @@ -1,5 +1,4 @@ # GeneralConfig -from .defaults import SESSIONS_DIR GENERAL_PYGMENT_STYLE = "The pygment style to use" GENERAL_PREFERRED_SPINNER = "The spinner to use" diff --git a/fastanime/core/downloader/default.py b/fastanime/core/downloader/default.py index 0f9999f..f6d6594 100644 --- a/fastanime/core/downloader/default.py +++ b/fastanime/core/downloader/default.py @@ -367,7 +367,7 @@ class DefaultDownloader(BaseDownloader): try: # Run ffmpeg - use silent flag to control ffmpeg output, not progress - process = subprocess.run( + subprocess.run( args, capture_output=params.silent, # Only suppress ffmpeg output if silent text=True, diff --git a/fastanime/core/downloader/downloader.py b/fastanime/core/downloader/downloader.py index ca397a9..c9220e6 100644 --- a/fastanime/core/downloader/downloader.py +++ b/fastanime/core/downloader/downloader.py @@ -28,7 +28,6 @@ class DownloadFactory: elif downloader_name == "auto": # Auto mode: prefer yt-dlp if available, fallback to default try: - import yt_dlp from .yt_dlp import YtDLPDownloader return YtDLPDownloader(config) diff --git a/fastanime/core/downloader/yt_dlp.py b/fastanime/core/downloader/yt_dlp.py index fa460d4..b6f5421 100644 --- a/fastanime/core/downloader/yt_dlp.py +++ b/fastanime/core/downloader/yt_dlp.py @@ -219,7 +219,7 @@ class YtDLPDownloader(BaseDownloader): # Run the ffmpeg command try: - process = subprocess.run(args) + subprocess.run(args) final_output_path = video_path.parent / merged_filename if final_output_path.exists(): diff --git a/fastanime/core/utils/file.py b/fastanime/core/utils/file.py index 10ec4aa..a7b8f62 100644 --- a/fastanime/core/utils/file.py +++ b/fastanime/core/utils/file.py @@ -308,7 +308,6 @@ class FileLock: with self.lock_file_path.open("r") as f: lines = f.readlines() if len(lines) >= 2: - locked_pid = int(lines[0].strip()) locked_timestamp = float(lines[1].strip()) current_time = time.time() if current_time - locked_timestamp > self.stale_timeout: diff --git a/fastanime/libs/provider/anime/allanime/extractors/filemoon.py b/fastanime/libs/provider/anime/allanime/extractors/filemoon.py index a575583..11eb735 100644 --- a/fastanime/libs/provider/anime/allanime/extractors/filemoon.py +++ b/fastanime/libs/provider/anime/allanime/extractors/filemoon.py @@ -20,7 +20,6 @@ class FmHlsExtractor(BaseExtractor): timeout=10, ) response.raise_for_status() - streams = response.json() embed_html = response.text.replace(" ", "").replace("\n", "") vid = MP4_SERVER_JUICY_STREAM_REGEX.search(embed_html) @@ -50,7 +49,6 @@ class OkExtractor(BaseExtractor): timeout=10, ) response.raise_for_status() - streams = response.json() embed_html = response.text.replace(" ", "").replace("\n", "") vid = MP4_SERVER_JUICY_STREAM_REGEX.search(embed_html) diff --git a/fastanime/libs/provider/anime/allanime/extractors/streamsb.py b/fastanime/libs/provider/anime/allanime/extractors/streamsb.py index faf5780..56670c6 100644 --- a/fastanime/libs/provider/anime/allanime/extractors/streamsb.py +++ b/fastanime/libs/provider/anime/allanime/extractors/streamsb.py @@ -20,7 +20,6 @@ class SsHlsExtractor(BaseExtractor): timeout=10, ) response.raise_for_status() - embed_html = response.text.replace(" ", "").replace("\n", "") streams = response.json()["links"] return Server( diff --git a/fastanime/libs/provider/anime/allanime/extractors/vid_mp4.py b/fastanime/libs/provider/anime/allanime/extractors/vid_mp4.py index a51aeaf..6f9b51c 100644 --- a/fastanime/libs/provider/anime/allanime/extractors/vid_mp4.py +++ b/fastanime/libs/provider/anime/allanime/extractors/vid_mp4.py @@ -19,7 +19,6 @@ class VidMp4Extractor(BaseExtractor): f"https://{API_BASE_URL}{url.replace('clock', 'clock.json')}", timeout=10, ) - embed_html = response.text.replace(" ", "").replace("\n", "") response.raise_for_status() streams = response.json() diff --git a/fastanime/libs/provider/anime/allanime/types.py b/fastanime/libs/provider/anime/allanime/types.py index 96b06c6..8b8eed3 100644 --- a/fastanime/libs/provider/anime/allanime/types.py +++ b/fastanime/libs/provider/anime/allanime/types.py @@ -91,9 +91,6 @@ class AllAnimeEpisodeStreams(TypedDict): links: [AllAnimeEpisodeStream] -Server = Literal["gogoanime", "dropbox", "wetransfer", "sharepoint"] - - class AllAnimeEpisode(TypedDict): episodeString: str sourceUrls: list[AllAnimeSource] diff --git a/fastanime/libs/provider/anime/allanime/utils.py b/fastanime/libs/provider/anime/allanime/utils.py index 26478e6..857b6f2 100644 --- a/fastanime/libs/provider/anime/allanime/utils.py +++ b/fastanime/libs/provider/anime/allanime/utils.py @@ -51,7 +51,7 @@ def debug_extractor(extractor_function): f"[AllAnime@Server={args[3].get('sourceName', 'UNKNOWN')}]: {e}" ) else: - return extractor_function(*args, **kwargs) + return extractor_function(*args) return _provider_function_wrapper diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index a6f1249..0000000 --- a/pytest.ini +++ /dev/null @@ -1,47 +0,0 @@ -[tool.pytest.ini_options] -minversion = "6.0" -addopts = [ - "-ra", - "--strict-markers", - "--strict-config", - "--cov=fastanime.cli.interactive", - "--cov-report=term-missing", - "--cov-report=html:htmlcov", - "--cov-report=xml", - "-v", -] -testpaths = [ - "tests", -] -python_files = [ - "test_*.py", - "*_test.py", -] -python_classes = [ - "Test*", -] -python_functions = [ - "test_*", -] -markers = [ - "unit: Unit tests", - "integration: Integration tests", - "slow: Slow running tests", - "network: Tests requiring network access", - "auth: Tests requiring authentication", -] -filterwarnings = [ - "ignore::DeprecationWarning", - "ignore::PendingDeprecationWarning", -] - -# Test discovery patterns -collect_ignore = [ - "setup.py", -] - -# Pytest plugins -required_plugins = [ - "pytest-cov", - "pytest-mock", -]