Skip to content

Commit

Permalink
Merge pull request #300 from glensc/walk-plan
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc authored Apr 27, 2021
2 parents 83043b5 + 34af965 commit 20cb301
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
12 changes: 6 additions & 6 deletions plex_trakt_sync/commands/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,18 @@ def sync(sync_option: str, library: str, show: str, movie: str, batch_size: int)
if library:
logger.info(f"Filtering Library: {library}")
w.add_library(library)

if show:
w.add_show(show)
logger.info(f"Syncing Show: {show}")
elif movie:
if movie:
w.add_movie(movie)
logger.info(f"Syncing Movie: {movie}")
elif not movies and not tv:
click.echo("Nothing to sync!")

if not w.is_valid():
click.echo("Nothing to sync, this is likely due conflicting options given.")
return
else:
logger.info(f"Syncing TV={tv}, Movies={movies}")

w.walk_details(print=click.echo)

with measure_time("Completed full sync"):
sync_all(walker=w, trakt=trakt, server=server)
21 changes: 21 additions & 0 deletions plex_trakt_sync/walker.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,27 @@ def add_movie(self, movie):
self.movie.append(movie)
self.walk_shows = False

def is_valid(self):
# Single item provided
if self.library or self.movie or self.show:
return True

# Full sync of movies or shows
if self.walk_movies or self.walk_shows:
return True

return False

def walk_details(self, print=print):
print(f"Sync Movies: {self.walk_movies}")
print(f"Sync Shows: {self.walk_shows}")
if self.library:
print(f"Walk libraries: {self.library}")
if self.show:
print(f"Walk Shows: {self.show}")
if self.movie:
print(f"Walk Movies: {self.movie}")

def find_movies(self):
"""
Iterate over movie sections unless specific movie is requested
Expand Down

0 comments on commit 20cb301

Please sign in to comment.