add option for failed entries

This commit is contained in:
2025-07-26 17:15:14 +02:00
parent 65cb94e6ef
commit db010d9134

40
main.py
View File

@@ -12,7 +12,13 @@ def tag_all(args): # type:ignore
if args.verbose:
tagger.verbose = True
tagger.tag()
with open("failed.txt", "r") as f:
items = f.readlines()
unique_items = set(item.strip() for item in items if item.strip())
print(f"Failed to tag {len(unique_items)} items.")
print("Failed items:")
for item in unique_items:
print(item.strip())
def tag_series(args): # type:ignore
if args.id:
@@ -27,6 +33,12 @@ def tag_series(args): # type:ignore
names.append(name)
tagger.tag_series(series_names=names)
def manual_parse(args): # type:ignore
name = args.name if args.name else None
series_id = int(args.id) if args.id else None
print(f"Using name: {name} and id: {series_id}")
tagger.tag_manual(series_name=name, anilist_id=series_id)
def main():
parser = argparse.ArgumentParser(description="KomTagger CLI")
@@ -57,9 +69,33 @@ def main():
"-v", "--verbose", action="store_true", help="Enable verbose output"
)
series_parser.set_defaults(func=tag_series)
manual_parsing = subparsers.add_parser("match", help="Run manual parsing operation")
manual_parsing.add_argument(
"-v", "--verbose", action="store_true", help="Enable verbose output"
)
manual_parsing.add_argument(
"--name",
type=str,
help="Series name to use",
)
manual_parsing.add_argument(
"--id",
type=str,
help="Series ID to use",
)
manual_parsing.set_defaults(func=manual_parse)
failed_parser = subparsers.add_parser(
"failed",
help="Show failed items from the last tag operation and manually tag them",
)
failed_parser.add_argument(
"-v", "--verbose", action="store_true", help="Enable verbose output"
)
failed_parser.set_defaults(func=tagger.show_failed)
args = parser.parse_args()
args.func(args)
args.func(args) # Call the function associated with the command
if __name__ == "__main__":