mirror of
https://github.com/Benexl/FastAnime.git
synced 2026-01-07 02:03:49 -08:00
- Implemented `restore` command to restore the media registry from backup files, with options for verification and backup of current registry. - Created `search` command to search through the local media registry with various filtering options. - Added `stats` command to display detailed statistics about the local media registry, including breakdowns by genre, format, and year. - Developed `sync` command to synchronize the local registry with a remote media API, allowing for both download and upload of media lists. - Included example usage for the registry commands in `examples.py`. - Fixed tag filtering logic in `MediaRegistryService` to ensure correct filtering based on tags.
66 lines
2.3 KiB
Python
66 lines
2.3 KiB
Python
import click
|
|
|
|
from ...utils.lazyloader import LazyGroup
|
|
from . import examples
|
|
|
|
commands = {
|
|
"sync": "sync.sync",
|
|
"stats": "stats.stats",
|
|
"search": "search.search",
|
|
"export": "export.export",
|
|
"import": "import_.import_",
|
|
"clean": "clean.clean",
|
|
"backup": "backup.backup",
|
|
"restore": "restore.restore",
|
|
}
|
|
|
|
|
|
@click.group(
|
|
cls=LazyGroup,
|
|
name="registry",
|
|
root="fastanime.cli.commands.registry.commands",
|
|
invoke_without_command=True,
|
|
help="Manage your local media registry - sync, search, backup and maintain your anime database",
|
|
short_help="Local media registry management",
|
|
lazy_subcommands=commands,
|
|
epilog=examples.main,
|
|
)
|
|
@click.option(
|
|
"--api",
|
|
default="anilist",
|
|
help="Media API to use (default: anilist)",
|
|
type=click.Choice(["anilist"], case_sensitive=False)
|
|
)
|
|
@click.pass_context
|
|
def registry(ctx: click.Context, api: str):
|
|
"""
|
|
The entry point for the 'registry' command. If no subcommand is invoked,
|
|
it shows registry information and statistics.
|
|
"""
|
|
from ...service.registry.service import MediaRegistryService
|
|
from ...utils.feedback import create_feedback_manager
|
|
|
|
config = ctx.obj
|
|
feedback = create_feedback_manager(config.general.icons)
|
|
|
|
if ctx.invoked_subcommand is None:
|
|
# Show registry overview and statistics
|
|
try:
|
|
registry_service = MediaRegistryService(api, config.registry)
|
|
stats = registry_service.get_registry_stats()
|
|
|
|
feedback.info("Registry Overview", f"API: {api}")
|
|
feedback.info("Total Media", f"{stats.get('total_media', 0)} entries")
|
|
feedback.info("Recently Updated", f"{stats.get('recently_updated', 0)} entries in last 7 days")
|
|
feedback.info("Storage Path", str(config.registry.media_dir))
|
|
|
|
# Show status breakdown if available
|
|
status_breakdown = stats.get('status_breakdown', {})
|
|
if status_breakdown:
|
|
feedback.info("Status Breakdown:")
|
|
for status, count in status_breakdown.items():
|
|
feedback.info(f" {status.title()}", f"{count} entries")
|
|
|
|
except Exception as e:
|
|
feedback.error("Registry Error", f"Failed to load registry: {e}")
|