88from comicfn2dict import comicfn2dict
99from typer import Argument , Context , Exit , Option , Typer
1010
11- from perdoo import __version__ , setup_logging
11+ from perdoo import __version__ , get_cache_root , setup_logging
1212from perdoo .archives import CBRArchive , get_archive
1313from perdoo .cli import archive_app , settings_app
1414from perdoo .console import CONSOLE
2222)
2323from perdoo .metadata import ComicInfo , MetronInfo , get_metadata
2424from perdoo .metadata .metron_info import InformationSource
25- from perdoo .services import BaseService , Comicvine , League , Marvel , Metron
25+ from perdoo .services import BaseService , Comicvine , Marvel , Metron
2626from perdoo .settings import Service , Services , Settings
27- from perdoo .utils import IssueSearch , Search , SeriesSearch , delete_empty_folders , list_files
27+ from perdoo .utils import (
28+ IssueSearch ,
29+ Search ,
30+ SeriesSearch ,
31+ delete_empty_folders ,
32+ list_files ,
33+ recursive_delete ,
34+ )
2835
2936app = Typer (help = "CLI tool for managing comic collections and settings." )
3037app .add_typer (archive_app , name = "archive" )
@@ -66,8 +73,6 @@ def get_services(settings: Services) -> dict[Service, BaseService]:
6673 output = {}
6774 if settings .comicvine .api_key :
6875 output [Service .COMICVINE ] = Comicvine (settings .comicvine )
69- if settings .league_of_comic_geeks .client_id and settings .league_of_comic_geeks .client_secret :
70- output [Service .LEAGUE_OF_COMIC_GEEKS ] = League (settings .league_of_comic_geeks )
7176 if settings .marvel .public_key and settings .marvel .private_key :
7277 output [Service .MARVEL ] = Marvel (settings .marvel )
7378 if settings .metron .username and settings .metron .password :
@@ -89,7 +94,6 @@ def get_search_details(
8994 volume = metron_info .series .volume ,
9095 year = metron_info .series .start_year ,
9196 comicvine = series_id if source == InformationSource .COMIC_VINE else None ,
92- league = series_id if source == InformationSource .LEAGUE_OF_COMIC_GEEKS else None ,
9397 marvel = series_id if source == InformationSource .MARVEL else None ,
9498 metron = series_id if source == InformationSource .METRON else None ,
9599 ),
@@ -101,14 +105,6 @@ def get_search_details(
101105 ),
102106 None ,
103107 ),
104- league = next (
105- iter (
106- x .value
107- for x in metron_info .ids
108- if x .source == InformationSource .LEAGUE_OF_COMIC_GEEKS
109- ),
110- None ,
111- ),
112108 marvel = next (
113109 iter (x .value for x in metron_info .ids if x .source == InformationSource .MARVEL ),
114110 None ,
@@ -169,6 +165,16 @@ def run(
169165 bool ,
170166 Option ("--skip-organize" , help = "Skip organize/moving comics to appropriate directories." ),
171167 ] = False ,
168+ clean_cache : Annotated [
169+ bool ,
170+ Option (
171+ "--clean" ,
172+ "-c" ,
173+ show_default = False ,
174+ help = "Clean the cache before starting the synchronization process. "
175+ "Removes all cached files." ,
176+ ),
177+ ] = False ,
172178 debug : Annotated [
173179 bool , Option ("--debug" , help = "Enable debug mode to show extra information." )
174180 ] = False ,
@@ -188,8 +194,12 @@ def run(
188194 "flags.skip-clean" : skip_clean ,
189195 "flags.skip-rename" : skip_rename ,
190196 "flags.skip-organize" : skip_organize ,
197+ "flags.clean-cache" : clean_cache ,
191198 }
192199 )
200+ if clean_cache :
201+ LOGGER .info ("Cleaning Cache" )
202+ recursive_delete (path = get_cache_root ())
193203 services = get_services (settings = settings .services )
194204 if not services and sync != SyncOption .SKIP :
195205 LOGGER .warning ("No external services configured" )
0 commit comments