mirror of
https://github.com/Benexl/FastAnime.git
synced 2025-12-12 07:40:41 -08:00
style: format files
This commit is contained in:
@@ -19,11 +19,11 @@ repos:
|
|||||||
"--remove-unused-variables",
|
"--remove-unused-variables",
|
||||||
"--remove-all-unused-imports",
|
"--remove-all-unused-imports",
|
||||||
]
|
]
|
||||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
# - repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: v0.4.10
|
# rev: v0.4.10
|
||||||
hooks:
|
# hooks:
|
||||||
- id: ruff
|
# - id: ruff
|
||||||
args: [--fix]
|
# args: [--fix]
|
||||||
|
|
||||||
- repo: https://github.com/psf/black-pre-commit-mirror
|
- repo: https://github.com/psf/black-pre-commit-mirror
|
||||||
rev: 24.4.2
|
rev: 24.4.2
|
||||||
|
|||||||
@@ -253,9 +253,10 @@ def run_cli(
|
|||||||
if not is_latest:
|
if not is_latest:
|
||||||
from rich.console import Console
|
from rich.console import Console
|
||||||
from rich.markdown import Markdown
|
from rich.markdown import Markdown
|
||||||
from .app_updater import update_app
|
|
||||||
from rich.prompt import Confirm
|
from rich.prompt import Confirm
|
||||||
|
|
||||||
|
from .app_updater import update_app
|
||||||
|
|
||||||
def _print_release(release_data):
|
def _print_release(release_data):
|
||||||
console = Console()
|
console = Console()
|
||||||
body = Markdown(release_data["body"])
|
body = Markdown(release_data["body"])
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import re
|
import re
|
||||||
import shlex
|
import shlex
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import os
|
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from rich import print
|
from rich import print
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
import click
|
import click
|
||||||
|
|
||||||
|
|
||||||
from ...completion_functions import anime_titles_shell_complete
|
from ...completion_functions import anime_titles_shell_complete
|
||||||
from .data import (
|
from .data import (
|
||||||
tags_available_list,
|
|
||||||
sorts_available,
|
|
||||||
media_statuses_available,
|
|
||||||
seasons_available,
|
|
||||||
genres_available,
|
genres_available,
|
||||||
media_formats_available,
|
media_formats_available,
|
||||||
|
media_statuses_available,
|
||||||
|
seasons_available,
|
||||||
|
sorts_available,
|
||||||
|
tags_available_list,
|
||||||
years_available,
|
years_available,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -146,9 +145,10 @@ def download(
|
|||||||
hls_use_mpegts,
|
hls_use_mpegts,
|
||||||
max_results,
|
max_results,
|
||||||
):
|
):
|
||||||
from ....anilist import AniList
|
|
||||||
from rich import print
|
from rich import print
|
||||||
|
|
||||||
|
from ....anilist import AniList
|
||||||
|
|
||||||
force_ffmpeg |= hls_use_mpegts
|
force_ffmpeg |= hls_use_mpegts
|
||||||
|
|
||||||
success, anilist_search_results = AniList.search(
|
success, anilist_search_results = AniList.search(
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ import click
|
|||||||
|
|
||||||
from ...completion_functions import anime_titles_shell_complete
|
from ...completion_functions import anime_titles_shell_complete
|
||||||
from .data import (
|
from .data import (
|
||||||
tags_available_list,
|
|
||||||
sorts_available,
|
|
||||||
media_statuses_available,
|
|
||||||
seasons_available,
|
|
||||||
genres_available,
|
genres_available,
|
||||||
media_formats_available,
|
media_formats_available,
|
||||||
|
media_statuses_available,
|
||||||
|
seasons_available,
|
||||||
|
sorts_available,
|
||||||
|
tags_available_list,
|
||||||
years_available,
|
years_available,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -3,16 +3,16 @@ import logging
|
|||||||
import os
|
import os
|
||||||
from configparser import ConfigParser
|
from configparser import ConfigParser
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
from ..libs.fzf import FZF_DEFAULT_OPTS, HEADER
|
|
||||||
|
|
||||||
from ..constants import (
|
from ..constants import (
|
||||||
|
ASSETS_DIR,
|
||||||
|
S_PLATFORM,
|
||||||
USER_CONFIG_PATH,
|
USER_CONFIG_PATH,
|
||||||
USER_DATA_PATH,
|
USER_DATA_PATH,
|
||||||
USER_VIDEOS_DIR,
|
USER_VIDEOS_DIR,
|
||||||
ASSETS_DIR,
|
|
||||||
USER_WATCH_HISTORY_PATH,
|
USER_WATCH_HISTORY_PATH,
|
||||||
S_PLATFORM,
|
|
||||||
)
|
)
|
||||||
|
from ..libs.fzf import FZF_DEFAULT_OPTS, HEADER
|
||||||
from ..libs.rofi import Rofi
|
from ..libs.rofi import Rofi
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|||||||
@@ -1360,7 +1360,9 @@ def media_actions_menu(
|
|||||||
|
|
||||||
fastanime_runtime_state.anilist_results_data = {
|
fastanime_runtime_state.anilist_results_data = {
|
||||||
"data": {
|
"data": {
|
||||||
"Page": {"media": relations[1]["data"]["Media"]["relations"]["nodes"]} # pyright:ignore
|
"Page": {
|
||||||
|
"media": relations[1]["data"]["Media"]["relations"]["nodes"]
|
||||||
|
} # pyright:ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
anilist_results_menu(config, fastanime_runtime_state)
|
anilist_results_menu(config, fastanime_runtime_state)
|
||||||
@@ -1728,34 +1730,22 @@ def fastanime_main_menu(
|
|||||||
options = {
|
options = {
|
||||||
f"{'🔥 ' if icons else ''}Trending": AniList.get_trending,
|
f"{'🔥 ' if icons else ''}Trending": AniList.get_trending,
|
||||||
f"{'🎞️ ' if icons else ''}Recent": _recent,
|
f"{'🎞️ ' if icons else ''}Recent": _recent,
|
||||||
f"{'📺 ' if icons else ''}Watching": lambda config,
|
f"{'📺 ' if icons else ''}Watching": lambda config, media_list_type="Watching", page=1: _handle_animelist(
|
||||||
media_list_type="Watching",
|
|
||||||
page=1: _handle_animelist(
|
|
||||||
config, fastanime_runtime_state, media_list_type, page=page
|
config, fastanime_runtime_state, media_list_type, page=page
|
||||||
),
|
),
|
||||||
f"{'⏸ ' if icons else ''}Paused": lambda config,
|
f"{'⏸ ' if icons else ''}Paused": lambda config, media_list_type="Paused", page=1: _handle_animelist(
|
||||||
media_list_type="Paused",
|
|
||||||
page=1: _handle_animelist(
|
|
||||||
config, fastanime_runtime_state, media_list_type, page=page
|
config, fastanime_runtime_state, media_list_type, page=page
|
||||||
),
|
),
|
||||||
f"{'🚮 ' if icons else ''}Dropped": lambda config,
|
f"{'🚮 ' if icons else ''}Dropped": lambda config, media_list_type="Dropped", page=1: _handle_animelist(
|
||||||
media_list_type="Dropped",
|
|
||||||
page=1: _handle_animelist(
|
|
||||||
config, fastanime_runtime_state, media_list_type, page=page
|
config, fastanime_runtime_state, media_list_type, page=page
|
||||||
),
|
),
|
||||||
f"{'📑 ' if icons else ''}Planned": lambda config,
|
f"{'📑 ' if icons else ''}Planned": lambda config, media_list_type="Planned", page=1: _handle_animelist(
|
||||||
media_list_type="Planned",
|
|
||||||
page=1: _handle_animelist(
|
|
||||||
config, fastanime_runtime_state, media_list_type, page=page
|
config, fastanime_runtime_state, media_list_type, page=page
|
||||||
),
|
),
|
||||||
f"{'✅ ' if icons else ''}Completed": lambda config,
|
f"{'✅ ' if icons else ''}Completed": lambda config, media_list_type="Completed", page=1: _handle_animelist(
|
||||||
media_list_type="Completed",
|
|
||||||
page=1: _handle_animelist(
|
|
||||||
config, fastanime_runtime_state, media_list_type, page=page
|
config, fastanime_runtime_state, media_list_type, page=page
|
||||||
),
|
),
|
||||||
f"{'🔁 ' if icons else ''}Rewatching": lambda config,
|
f"{'🔁 ' if icons else ''}Rewatching": lambda config, media_list_type="Rewatching", page=1: _handle_animelist(
|
||||||
media_list_type="Rewatching",
|
|
||||||
page=1: _handle_animelist(
|
|
||||||
config, fastanime_runtime_state, media_list_type, page=page
|
config, fastanime_runtime_state, media_list_type, page=page
|
||||||
),
|
),
|
||||||
f"{'🔔 ' if icons else ''}Recently Updated Anime": AniList.get_most_recently_updated,
|
f"{'🔔 ' if icons else ''}Recently Updated Anime": AniList.get_most_recently_updated,
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import re
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import logging
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from ...constants import S_PLATFORM
|
from ...constants import S_PLATFORM
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Any
|
from typing import Any, Callable
|
||||||
|
|
||||||
from ...libs.anilist.types import AnilistBaseMediaDataSchema
|
from ...libs.anilist.types import AnilistBaseMediaDataSchema
|
||||||
from ...libs.anime_provider.types import Anime, EpisodeStream, SearchResult, Server
|
from ...libs.anime_provider.types import Anime, EpisodeStream, SearchResult, Server
|
||||||
from typing import Callable
|
|
||||||
|
|
||||||
|
|
||||||
class FastAnimeRuntimeState(object):
|
class FastAnimeRuntimeState(object):
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from ...anime_provider.base_provider import AnimeProvider
|
from ...anime_provider.base_provider import AnimeProvider
|
||||||
from ..decorators import debug_provider
|
from ..decorators import debug_provider
|
||||||
from ..utils import give_random_quality, one_digit_symmetric_xor
|
from ..utils import give_random_quality, one_digit_symmetric_xor
|
||||||
from .constants import (
|
from .constants import (
|
||||||
API_ENDPOINT,
|
|
||||||
API_BASE_URL,
|
API_BASE_URL,
|
||||||
|
API_ENDPOINT,
|
||||||
API_REFERER,
|
API_REFERER,
|
||||||
DEFAULT_PER_PAGE,
|
|
||||||
DEFAULT_COUNTRY_OF_ORIGIN,
|
DEFAULT_COUNTRY_OF_ORIGIN,
|
||||||
DEFAULT_NSFW,
|
DEFAULT_NSFW,
|
||||||
DEFAULT_PAGE,
|
DEFAULT_PAGE,
|
||||||
|
DEFAULT_PER_PAGE,
|
||||||
DEFAULT_UNKNOWN,
|
DEFAULT_UNKNOWN,
|
||||||
MP4_SERVER_JUICY_STREAM_REGEX,
|
MP4_SERVER_JUICY_STREAM_REGEX,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import re
|
|||||||
from html.parser import HTMLParser
|
from html.parser import HTMLParser
|
||||||
from itertools import cycle
|
from itertools import cycle
|
||||||
from urllib.parse import quote_plus
|
from urllib.parse import quote_plus
|
||||||
from .extractors import MegaCloud
|
|
||||||
|
|
||||||
from yt_dlp.utils import (
|
from yt_dlp.utils import (
|
||||||
clean_html,
|
clean_html,
|
||||||
@@ -18,6 +17,7 @@ from ..base_provider import AnimeProvider
|
|||||||
from ..decorators import debug_provider
|
from ..decorators import debug_provider
|
||||||
from ..utils import give_random_quality
|
from ..utils import give_random_quality
|
||||||
from .constants import SERVERS_AVAILABLE
|
from .constants import SERVERS_AVAILABLE
|
||||||
|
from .extractors import MegaCloud
|
||||||
from .types import HiAnimeStream
|
from .types import HiAnimeStream
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import hashlib
|
import hashlib
|
||||||
import time
|
|
||||||
import re
|
|
||||||
import json
|
import json
|
||||||
from typing import List, Dict
|
import re
|
||||||
from Crypto.Cipher import AES
|
import time
|
||||||
from base64 import b64decode
|
from base64 import b64decode
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING, Dict, List
|
||||||
|
|
||||||
|
from Crypto.Cipher import AES
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from ...common.requests_cacher import CachedRequestsSession
|
from ...common.requests_cacher import CachedRequestsSession
|
||||||
|
|||||||
@@ -32,7 +32,9 @@ class Nyaa(AnimeProvider):
|
|||||||
|
|
||||||
@debug_provider
|
@debug_provider
|
||||||
def search_for_anime(self, user_query: str, *args, **_):
|
def search_for_anime(self, user_query: str, *args, **_):
|
||||||
self.search_results = search_for_anime_with_anilist(user_query, True) # pyright: ignore
|
self.search_results = search_for_anime_with_anilist(
|
||||||
|
user_query, True
|
||||||
|
) # pyright: ignore
|
||||||
self.user_query = user_query
|
self.user_query = user_query
|
||||||
return self.search_results
|
return self.search_results
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
import base64
|
import base64
|
||||||
|
import re
|
||||||
from itertools import cycle
|
from itertools import cycle
|
||||||
|
|
||||||
from yt_dlp.utils import (
|
from yt_dlp.utils import (
|
||||||
get_element_text_and_html_by_tag,
|
|
||||||
get_elements_text_and_html_by_attribute,
|
|
||||||
extract_attributes,
|
extract_attributes,
|
||||||
get_element_by_attribute,
|
get_element_by_attribute,
|
||||||
|
get_element_text_and_html_by_tag,
|
||||||
|
get_elements_text_and_html_by_attribute,
|
||||||
)
|
)
|
||||||
import re
|
|
||||||
|
|
||||||
from yt_dlp.utils.traversal import get_element_html_by_attribute
|
from yt_dlp.utils.traversal import get_element_html_by_attribute
|
||||||
from .constants import YUGEN_ENDPOINT, SEARCH_URL
|
|
||||||
from ..decorators import debug_provider
|
|
||||||
from ..base_provider import AnimeProvider
|
from ..base_provider import AnimeProvider
|
||||||
|
from ..decorators import debug_provider
|
||||||
|
from .constants import SEARCH_URL, YUGEN_ENDPOINT
|
||||||
|
|
||||||
|
|
||||||
# ** Adapted from anipy-cli **
|
# ** Adapted from anipy-cli **
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from click.testing import CliRunner
|
from click.testing import CliRunner
|
||||||
from unittest.mock import patch
|
|
||||||
|
|
||||||
from fastanime.cli import run_cli
|
from fastanime.cli import run_cli
|
||||||
|
|
||||||
@@ -151,7 +152,7 @@ def test_anilist_watching_help(runner: CliRunner):
|
|||||||
|
|
||||||
|
|
||||||
def test_check_for_updates_not_called_on_completions(runner):
|
def test_check_for_updates_not_called_on_completions(runner):
|
||||||
with patch('fastanime.cli.app_updater.check_for_updates') as mock_check_for_updates:
|
with patch("fastanime.cli.app_updater.check_for_updates") as mock_check_for_updates:
|
||||||
result = runner.invoke(run_cli, ["completions"])
|
result = runner.invoke(run_cli, ["completions"])
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
mock_check_for_updates.assert_not_called()
|
mock_check_for_updates.assert_not_called()
|
||||||
|
|||||||
Reference in New Issue
Block a user