Add --dry-run option
MODIFY
plextraktsync/cli.py
plextraktsync/cli.py
@@ -266,6 +266,7 @@ def bug_report():
@command()
@click.argument("input")
+@click.option("--dry-run", is_flag=True, help="Do not perform actions that change data")
def imdb_import():
"""
Import IMDB ratings from CSV file.

MODIFY
plextraktsync/commands/imdb_import.py
plextraktsync/commands/imdb_import.py
@@ -58,12 +58,13 @@ def from_csv(row):
return Ratings(**data)
-def imdb_import(input: PathLike):
+def imdb_import(input: PathLike, dry_run: bool):
trakt = factory.trakt_api()
for r in read_csv(input):
print(f"Importing [blue]{r.media_type} {r.imdb}[/]: {r.title} ({r.year}), rated at {r.rate_date}")
m = trakt.search_by_id(r.imdb, "imdb", r.media_type)
rating = trakt.rating(m)
- print(f"Rating {m} with {r.rating} (was {rating})")
+ print(f"{'Would rate' if dry_run else 'Rating'} {m} with {r.rating} (was {rating})")
+ if not dry_run:
trakt.rate(m, r.rating)

Add --dry-run option