Add --sync={all|tv|movies} option
MODIFY
plex_trakt_sync/commands/sync.py
plex_trakt_sync/commands/sync.py
from plex_trakt_sync.logging import logging
-def sync_all():
+def sync_all(movies=True, tv=True):
with requests_cache.disabled():
server = get_plex_server()
listutil = TraktListUtil()
@@ -36,10 +36,12 @@ def sync_all():
logging.info("Server version {} updated at: {}".format(server.version, server.updatedAt))
logging.info("Recently added: {}".format(server.library.recentlyAdded()[:5]))
+ if movies:
for section in plex.movie_sections:
with measure_time("Processing section %s" % section.title):
process_movie_section(section, trakt_watched_movies, listutil, trakt_movie_collection, trakt, plex)
+ if tv:
for section in plex.show_sections:
with measure_time("Processing section %s" % section.title):
process_show_section(section, trakt_watched_shows, listutil)
@@ -49,12 +51,25 @@ def sync_all():
@click.command()
-def sync():
+@click.option(
+ "--sync", "sync_option",
+ type=click.Choice(["all", "movies", "tv"], case_sensitive=False),
+ default="all",
+ show_default=True, help="Specify what to sync"
+)
+def sync(sync_option: str):
"""
Perform sync between Plex and Trakt
"""
- logging.info("Starting sync Plex {} and Trakt {}".format(CONFIG['PLEX_USERNAME'], CONFIG['TRAKT_USERNAME']))
+ movies = sync_option in ["all", "movies"]
+ tv = sync_option in ["all", "tv"]
+ if not movies and not tv:
+ click.echo("Nothing to sync!")
+ return
+
+ logging.info(f"Syncing with Plex {CONFIG['PLEX_USERNAME']} and Trakt {CONFIG['PLEX_USERNAME']}")
+ logging.info(f"Syncing TV={tv}, Movies={movies}")
with measure_time("Completed full sync"):
- sync_all()
+ sync_all(movies=movies, tv=tv)

Add --sync={all|tv|movies} option