mirror of
https://github.com/Benexl/FastAnime.git
synced 2026-01-05 17:27:27 -08:00
chore: remove redundant commands
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import click
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from fastanime.core.config import AppConfig
|
||||
|
||||
|
||||
@click.command(help="View anime you completed")
|
||||
@click.option(
|
||||
"--dump-json",
|
||||
"-d",
|
||||
is_flag=True,
|
||||
help="Only print out the results dont open anilist menu",
|
||||
)
|
||||
@click.pass_obj
|
||||
def completed(config: "AppConfig", dump_json: bool):
|
||||
from ..helpers import handle_user_list_command
|
||||
|
||||
handle_user_list_command(
|
||||
config=config,
|
||||
dump_json=dump_json,
|
||||
status="COMPLETED",
|
||||
list_name="completed"
|
||||
)
|
||||
@@ -1,53 +0,0 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import click
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from fastanime.core.config import AppConfig
|
||||
|
||||
|
||||
@click.command(help="View anime you dropped")
|
||||
@click.option(
|
||||
"--dump-json",
|
||||
"-d",
|
||||
is_flag=True,
|
||||
help="Only print out the results dont open anilist menu",
|
||||
)
|
||||
@click.pass_obj
|
||||
def dropped(config: "AppConfig", dump_json: bool):
|
||||
from ..helpers import handle_user_list_command
|
||||
|
||||
handle_user_list_command(
|
||||
config=config,
|
||||
dump_json=dump_json,
|
||||
status="DROPPED",
|
||||
list_name="dropped"
|
||||
)
|
||||
anime_list = AniList.get_anime_list("DROPPED")
|
||||
if not anime_list:
|
||||
exit(1)
|
||||
if not anime_list[0] or not anime_list[1]:
|
||||
exit(1)
|
||||
media = [
|
||||
mediaListItem["media"]
|
||||
for mediaListItem in anime_list[1]["data"]["Page"]["mediaList"]
|
||||
] # pyright:ignore
|
||||
anime_list[1]["data"]["Page"]["media"] = media # pyright:ignore
|
||||
if dump_json:
|
||||
import json
|
||||
|
||||
print(json.dumps(anime_list[1]))
|
||||
else:
|
||||
from ...interfaces import anilist_interfaces
|
||||
from ...utils.tools import FastAnimeRuntimeState
|
||||
|
||||
fastanime_runtime_state = FastAnimeRuntimeState()
|
||||
|
||||
fastanime_runtime_state.current_page = 1
|
||||
fastanime_runtime_state.current_data_loader = (
|
||||
lambda config, **kwargs: anilist_interfaces._handle_animelist(
|
||||
config, fastanime_runtime_state, "Dropped", **kwargs
|
||||
)
|
||||
)
|
||||
fastanime_runtime_state.anilist_results_data = anime_list[1]
|
||||
anilist_interfaces.anilist_results_menu(config, fastanime_runtime_state)
|
||||
@@ -1,38 +0,0 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import click
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from fastanime.core.config import AppConfig
|
||||
|
||||
|
||||
@click.command(
|
||||
help="Fetch the top 15 most favourited anime from anilist",
|
||||
short_help="View most favourited anime",
|
||||
)
|
||||
@click.option(
|
||||
"--dump-json",
|
||||
"-d",
|
||||
is_flag=True,
|
||||
help="Only print out the results dont open anilist menu",
|
||||
)
|
||||
@click.pass_obj
|
||||
def favourites(config: "AppConfig", dump_json: bool):
|
||||
from fastanime.libs.api.params import MediaSearchParams
|
||||
from ..helpers import handle_media_search_command
|
||||
|
||||
def create_search_params(config):
|
||||
return MediaSearchParams(
|
||||
per_page=config.anilist.per_page or 15,
|
||||
sort=["FAVOURITES_DESC"]
|
||||
)
|
||||
|
||||
handle_media_search_command(
|
||||
config=config,
|
||||
dump_json=dump_json,
|
||||
task_name="Fetching most favourited anime...",
|
||||
search_params_factory=create_search_params,
|
||||
empty_message="No favourited anime found"
|
||||
)
|
||||
|
||||
exit(1)
|
||||
@@ -1,76 +0,0 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import click
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from fastanime.core.config import AppConfig
|
||||
|
||||
|
||||
@click.command(help="View anime you paused")
|
||||
@click.option(
|
||||
"--dump-json",
|
||||
"-d",
|
||||
is_flag=True,
|
||||
help="Only print out the results dont open anilist menu",
|
||||
)
|
||||
@click.pass_obj
|
||||
def paused(config: "AppConfig", dump_json: bool):
|
||||
from ..helpers import handle_user_list_command
|
||||
|
||||
handle_user_list_command(
|
||||
config=config,
|
||||
dump_json=dump_json,
|
||||
status="PAUSED",
|
||||
list_name="paused"
|
||||
)t TYPE_CHECKING
|
||||
|
||||
import click
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ...config import Config
|
||||
|
||||
|
||||
@click.command(help="View anime you paused on watching")
|
||||
@click.option(
|
||||
"--dump-json",
|
||||
"-d",
|
||||
is_flag=True,
|
||||
help="Only print out the results dont open anilist menu",
|
||||
)
|
||||
@click.pass_obj
|
||||
def paused(config: "Config", dump_json):
|
||||
from sys import exit
|
||||
|
||||
from ....anilist import AniList
|
||||
|
||||
if not config.user:
|
||||
print("Not authenticated")
|
||||
print("Please run: fastanime anilist loggin")
|
||||
exit(1)
|
||||
anime_list = AniList.get_anime_list("PAUSED")
|
||||
if not anime_list:
|
||||
exit(1)
|
||||
if not anime_list[0] or not anime_list[1]:
|
||||
exit(1)
|
||||
media = [
|
||||
mediaListItem["media"]
|
||||
for mediaListItem in anime_list[1]["data"]["Page"]["mediaList"]
|
||||
] # pyright:ignore
|
||||
anime_list[1]["data"]["Page"]["media"] = media # pyright:ignore
|
||||
if dump_json:
|
||||
import json
|
||||
|
||||
print(json.dumps(anime_list[1]))
|
||||
else:
|
||||
from ...interfaces import anilist_interfaces
|
||||
from ...utils.tools import FastAnimeRuntimeState
|
||||
|
||||
fastanime_runtime_state = FastAnimeRuntimeState()
|
||||
fastanime_runtime_state.current_page = 1
|
||||
fastanime_runtime_state.current_data_loader = (
|
||||
lambda config, **kwargs: anilist_interfaces._handle_animelist(
|
||||
config, fastanime_runtime_state, "Paused", **kwargs
|
||||
)
|
||||
)
|
||||
fastanime_runtime_state.anilist_results_data = anime_list[1]
|
||||
anilist_interfaces.anilist_results_menu(config, fastanime_runtime_state)
|
||||
@@ -1,25 +0,0 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import click
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from fastanime.core.config import AppConfig
|
||||
|
||||
|
||||
@click.command(help="View anime you are planning on watching")
|
||||
@click.option(
|
||||
"--dump-json",
|
||||
"-d",
|
||||
is_flag=True,
|
||||
help="Only print out the results dont open anilist menu",
|
||||
)
|
||||
@click.pass_obj
|
||||
def planning(config: "AppConfig", dump_json: bool):
|
||||
from ..helpers import handle_user_list_command
|
||||
|
||||
handle_user_list_command(
|
||||
config=config,
|
||||
dump_json=dump_json,
|
||||
status="PLANNING",
|
||||
list_name="planning"
|
||||
)
|
||||
@@ -1,38 +0,0 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import click
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from fastanime.core.config import AppConfig
|
||||
|
||||
|
||||
@click.command(
|
||||
help="Fetch the top 15 most popular anime",
|
||||
short_help="View most popular anime"
|
||||
)
|
||||
@click.option(
|
||||
"--dump-json",
|
||||
"-d",
|
||||
is_flag=True,
|
||||
help="Only print out the results dont open anilist menu",
|
||||
)
|
||||
@click.pass_obj
|
||||
def popular(config: "AppConfig", dump_json: bool):
|
||||
from fastanime.libs.api.params import MediaSearchParams
|
||||
from ..helpers import handle_media_search_command
|
||||
|
||||
def create_search_params(config):
|
||||
return MediaSearchParams(
|
||||
per_page=config.anilist.per_page or 15,
|
||||
sort=["POPULARITY_DESC"]
|
||||
)
|
||||
|
||||
handle_media_search_command(
|
||||
config=config,
|
||||
dump_json=dump_json,
|
||||
task_name="Fetching popular anime...",
|
||||
search_params_factory=create_search_params,
|
||||
empty_message="No popular anime found"
|
||||
)
|
||||
|
||||
exit(1)
|
||||
@@ -1,66 +0,0 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import click
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from fastanime.core.config import AppConfig
|
||||
|
||||
|
||||
@click.command(
|
||||
help="Get random anime from anilist based on a range of anilist anime ids that are selected at random",
|
||||
short_help="View random anime",
|
||||
)
|
||||
@click.option(
|
||||
"--dump-json",
|
||||
"-d",
|
||||
is_flag=True,
|
||||
help="Only print out the results dont open anilist menu",
|
||||
)
|
||||
@click.pass_obj
|
||||
def random_anime(config: "AppConfig", dump_json: bool):
|
||||
import json
|
||||
import random
|
||||
|
||||
from fastanime.cli.utils.feedback import create_feedback_manager
|
||||
from fastanime.core.exceptions import FastAnimeError
|
||||
from fastanime.libs.api.factory import create_api_client
|
||||
from fastanime.libs.api.params import MediaSearchParams
|
||||
from rich.progress import Progress
|
||||
|
||||
feedback = create_feedback_manager(config.general.icons)
|
||||
|
||||
try:
|
||||
# Create API client
|
||||
api_client = create_api_client(config.general.media_api, config)
|
||||
|
||||
# Generate random IDs
|
||||
random_ids = random.sample(range(1, 100000), k=50)
|
||||
|
||||
# Search for random anime
|
||||
with Progress() as progress:
|
||||
progress.add_task("Fetching random anime...", total=None)
|
||||
search_params = MediaSearchParams(id_in=random_ids, per_page=50)
|
||||
search_result = api_client.search_media(search_params)
|
||||
|
||||
if not search_result or not search_result.media:
|
||||
raise FastAnimeError("No random anime found")
|
||||
|
||||
if dump_json:
|
||||
# Use Pydantic's built-in serialization
|
||||
print(json.dumps(search_result.model_dump(), indent=2))
|
||||
else:
|
||||
# Launch interactive session for browsing results
|
||||
from fastanime.cli.interactive.session import session
|
||||
|
||||
feedback.info(
|
||||
f"Found {len(search_result.media)} random anime. Launching interactive mode..."
|
||||
)
|
||||
session.load_menus_from_folder()
|
||||
session.run(config)
|
||||
|
||||
except FastAnimeError as e:
|
||||
feedback.error("Failed to fetch random anime", str(e))
|
||||
raise click.Abort()
|
||||
except Exception as e:
|
||||
feedback.error("Unexpected error occurred", str(e))
|
||||
raise click.Abort()
|
||||
@@ -1,41 +0,0 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import click
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from fastanime.core.config import AppConfig
|
||||
|
||||
|
||||
@click.command(
|
||||
help="Fetch the 15 most recently updated anime from anilist that are currently releasing",
|
||||
short_help="View recently updated anime",
|
||||
)
|
||||
@click.option(
|
||||
"--dump-json",
|
||||
"-d",
|
||||
is_flag=True,
|
||||
help="Only print out the results dont open anilist menu",
|
||||
)
|
||||
@click.pass_obj
|
||||
def recent(config: "AppConfig", dump_json: bool):
|
||||
from fastanime.libs.api.params import MediaSearchParams
|
||||
from ..helpers import handle_media_search_command
|
||||
|
||||
def create_search_params(config):
|
||||
return MediaSearchParams(
|
||||
per_page=config.anilist.per_page or 15,
|
||||
sort=["UPDATED_AT_DESC"],
|
||||
status_in=["RELEASING"]
|
||||
)
|
||||
|
||||
handle_media_search_command(
|
||||
config=config,
|
||||
dump_json=dump_json,
|
||||
task_name="Fetching recently updated anime...",
|
||||
search_params_factory=create_search_params,
|
||||
empty_message="No recently updated anime found"
|
||||
)
|
||||
else:
|
||||
from sys import exit
|
||||
|
||||
exit(1)
|
||||
@@ -1,61 +0,0 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import click
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from fastanime.core.config import AppConfig
|
||||
|
||||
|
||||
@click.command(help="View anime you are rewatching")
|
||||
@click.option(
|
||||
"--dump-json",
|
||||
"-d",
|
||||
is_flag=True,
|
||||
help="Only print out the results dont open anilist menu",
|
||||
)
|
||||
@click.pass_obj
|
||||
def rewatching(config: "AppConfig", dump_json: bool):
|
||||
from ..helpers import handle_user_list_command
|
||||
|
||||
handle_user_list_command(
|
||||
config=config,
|
||||
dump_json=dump_json,
|
||||
status="REPEATING",
|
||||
list_name="rewatching"
|
||||
)
|
||||
from sys import exit
|
||||
|
||||
from ....anilist import AniList
|
||||
|
||||
if not config.user:
|
||||
print("Not authenticated")
|
||||
print("Please run: fastanime anilist loggin")
|
||||
exit(1)
|
||||
anime_list = AniList.get_anime_list("REPEATING")
|
||||
if not anime_list:
|
||||
exit(1)
|
||||
if not anime_list[0] or not anime_list[1]:
|
||||
exit(1)
|
||||
media = [
|
||||
mediaListItem["media"]
|
||||
for mediaListItem in anime_list[1]["data"]["Page"]["mediaList"]
|
||||
] # pyright:ignore
|
||||
anime_list[1]["data"]["Page"]["media"] = media # pyright:ignore
|
||||
if dump_json:
|
||||
import json
|
||||
|
||||
print(json.dumps(anime_list[1]))
|
||||
else:
|
||||
from ...interfaces import anilist_interfaces
|
||||
from ...utils.tools import FastAnimeRuntimeState
|
||||
|
||||
fastanime_runtime_state = FastAnimeRuntimeState()
|
||||
|
||||
fastanime_runtime_state.current_page = 1
|
||||
fastanime_runtime_state.current_data_loader = (
|
||||
lambda config, **kwargs: anilist_interfaces._handle_animelist(
|
||||
config, fastanime_runtime_state, "Rewatching", **kwargs
|
||||
)
|
||||
)
|
||||
fastanime_runtime_state.anilist_results_data = anime_list[1]
|
||||
anilist_interfaces.anilist_results_menu(config, fastanime_runtime_state)
|
||||
@@ -1,38 +0,0 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import click
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from fastanime.core.config import AppConfig
|
||||
|
||||
|
||||
@click.command(
|
||||
help="Fetch the 15 most scored anime",
|
||||
short_help="View most scored anime"
|
||||
)
|
||||
@click.option(
|
||||
"--dump-json",
|
||||
"-d",
|
||||
is_flag=True,
|
||||
help="Only print out the results dont open anilist menu",
|
||||
)
|
||||
@click.pass_obj
|
||||
def scores(config: "AppConfig", dump_json: bool):
|
||||
from fastanime.libs.api.params import MediaSearchParams
|
||||
from ..helpers import handle_media_search_command
|
||||
|
||||
def create_search_params(config):
|
||||
return MediaSearchParams(
|
||||
per_page=config.anilist.per_page or 15,
|
||||
sort=["SCORE_DESC"]
|
||||
)
|
||||
|
||||
handle_media_search_command(
|
||||
config=config,
|
||||
dump_json=dump_json,
|
||||
task_name="Fetching highest scored anime...",
|
||||
search_params_factory=create_search_params,
|
||||
empty_message="No scored anime found"
|
||||
)
|
||||
|
||||
exit(1)
|
||||
@@ -1,36 +0,0 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import click
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from fastanime.core.config import AppConfig
|
||||
|
||||
|
||||
@click.command(
|
||||
help="Fetch the top 15 anime that are currently trending",
|
||||
short_help="Trending anime 🔥🔥🔥",
|
||||
)
|
||||
@click.option(
|
||||
"--dump-json",
|
||||
"-d",
|
||||
is_flag=True,
|
||||
help="Only print out the results dont open anilist menu",
|
||||
)
|
||||
@click.pass_obj
|
||||
def trending(config: "AppConfig", dump_json: bool):
|
||||
from fastanime.libs.api.params import MediaSearchParams
|
||||
|
||||
from ..helpers import handle_media_search_command
|
||||
|
||||
def create_search_params(config):
|
||||
return MediaSearchParams(
|
||||
per_page=config.anilist.per_page or 15, sort=["TRENDING_DESC"]
|
||||
)
|
||||
|
||||
handle_media_search_command(
|
||||
config=config,
|
||||
dump_json=dump_json,
|
||||
task_name="Fetching trending anime...",
|
||||
search_params_factory=create_search_params,
|
||||
empty_message="No trending anime found",
|
||||
)
|
||||
@@ -1,39 +0,0 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import click
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from fastanime.core.config import AppConfig
|
||||
|
||||
|
||||
@click.command(
|
||||
help="Fetch the 15 most anticipated anime",
|
||||
short_help="View upcoming anime"
|
||||
)
|
||||
@click.option(
|
||||
"--dump-json",
|
||||
"-d",
|
||||
is_flag=True,
|
||||
help="Only print out the results dont open anilist menu",
|
||||
)
|
||||
@click.pass_obj
|
||||
def upcoming(config: "AppConfig", dump_json: bool):
|
||||
from fastanime.libs.api.params import MediaSearchParams
|
||||
from ..helpers import handle_media_search_command
|
||||
|
||||
def create_search_params(config):
|
||||
return MediaSearchParams(
|
||||
per_page=config.anilist.per_page or 15,
|
||||
sort=["POPULARITY_DESC"],
|
||||
status_in=["NOT_YET_RELEASED"]
|
||||
)
|
||||
|
||||
handle_media_search_command(
|
||||
config=config,
|
||||
dump_json=dump_json,
|
||||
task_name="Fetching upcoming anime...",
|
||||
search_params_factory=create_search_params,
|
||||
empty_message="No upcoming anime found"
|
||||
)
|
||||
|
||||
exit(1)
|
||||
@@ -1,25 +0,0 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import click
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from fastanime.core.config import AppConfig
|
||||
|
||||
|
||||
@click.command(help="View anime you are watching")
|
||||
@click.option(
|
||||
"--dump-json",
|
||||
"-d",
|
||||
is_flag=True,
|
||||
help="Only print out the results dont open anilist menu",
|
||||
)
|
||||
@click.pass_obj
|
||||
def watching(config: "AppConfig", dump_json: bool):
|
||||
from ..helpers import handle_user_list_command
|
||||
|
||||
handle_user_list_command(
|
||||
config=config,
|
||||
dump_json=dump_json,
|
||||
status="CURRENT",
|
||||
list_name="watching"
|
||||
)
|
||||
Reference in New Issue
Block a user