Move clear_trakt_collections logic to commands/clear_collections
DELETE
plex_trakt_sync/clear_trakt_collections.py
-import trakt
-from plex_trakt_sync.path import pytrakt_file
-trakt.core.CONFIG_PATH = pytrakt_file
-import trakt.users
-
-def clear_trakt_collections():
- trakt_user = trakt.users.User('me')
- coll = trakt_user.movie_collection
- for movie in coll:
- print("Deleting", movie.title)
- movie.remove_from_library()
- coll = trakt_user.show_collection
- for show in coll:
- print("Deleting", show.title)
- show.remove_from_library()

MODIFY
plex_trakt_sync/commands/clear_collections.py
plex_trakt_sync/commands/clear_collections.py
import click
-from plex_trakt_sync.clear_trakt_collections import clear_trakt_collections
+from plex_trakt_sync.logging import logging
+from plex_trakt_sync.trakt_api import TraktApi
@click.command()
@@ -12,4 +13,13 @@ def clear_collections(confirm):
if not confirm:
click.echo('You need to pass --confirm option to proceed')
return
- clear_trakt_collections()
+
+ trakt = TraktApi()
+
+ for movie in trakt.movie_collection:
+ logging.info(f"Deleting: {movie}")
+ trakt.remove_from_library(movie)
+
+ for show in trakt.show_collection:
+ logging.info(f"Deleting: {show}")
+ trakt.remove_from_library(show)

Move clear_trakt_collections logic to commands/clear_collections