Skip to content

Commit

Permalink
Make plugin submethods async
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc committed Apr 30, 2024
1 parent 147dec7 commit ff1727e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions plextraktsync/sync/AddCollectionPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ def factory(cls, sync):

@hookimpl
async def walk_movie(self, movie: Media, dry_run: bool):
self.sync_collection(movie, dry_run=dry_run)
await self.sync_collection(movie, dry_run=dry_run)

@hookimpl
async def walk_episode(self, episode: Media, dry_run: bool):
self.sync_collection(episode, dry_run=dry_run)
await self.sync_collection(episode, dry_run=dry_run)

def sync_collection(self, m: Media, dry_run: bool):
async def sync_collection(self, m: Media, dry_run: bool):
if m.is_collected:
return

Expand Down
8 changes: 4 additions & 4 deletions plextraktsync/sync/SyncRatingsPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ def init(self):
@hookimpl
async def fini(self, walker: Walker, dry_run: bool):
async for show in walker.walk_shows(self.shows, title="Syncing show ratings"):
self.sync_ratings(show, dry_run=dry_run)
await self.sync_ratings(show, dry_run=dry_run)

@hookimpl
async def walk_movie(self, movie: Media, dry_run: bool):
self.sync_ratings(movie, dry_run=dry_run)
await self.sync_ratings(movie, dry_run=dry_run)

@hookimpl
async def walk_episode(self, episode: Media, dry_run: bool):
self.sync_ratings(episode, dry_run=dry_run)
await self.sync_ratings(episode, dry_run=dry_run)

if episode.show:
self.shows.add(episode.show)

def sync_ratings(self, m: Media, dry_run: bool):
async def sync_ratings(self, m: Media, dry_run: bool):
if m.plex_rating == m.trakt_rating:
return

Expand Down
6 changes: 3 additions & 3 deletions plextraktsync/sync/SyncWatchedPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ def factory(cls, sync: Sync):

@hookimpl
async def walk_movie(self, movie: Media, dry_run: bool):
self.sync_watched(movie, dry_run=dry_run)
await self.sync_watched(movie, dry_run=dry_run)

@hookimpl
async def walk_episode(self, episode: Media, dry_run: bool):
self.sync_watched(episode, dry_run=dry_run)
await self.sync_watched(episode, dry_run=dry_run)

def sync_watched(self, m: Media, dry_run: bool):
async def sync_watched(self, m: Media, dry_run: bool):
if m.watched_on_plex is m.watched_on_trakt:
return

Expand Down
6 changes: 3 additions & 3 deletions plextraktsync/sync/WatchProgressPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ def factory(cls, sync: Sync):

@hookimpl
async def walk_movie(self, movie: Media, dry_run: bool):
self.sync_progress(movie, dry_run=dry_run)
await self.sync_progress(movie, dry_run=dry_run)

@hookimpl
async def walk_episode(self, episode: Media, dry_run: bool):
self.sync_progress(episode, dry_run=dry_run)
await self.sync_progress(episode, dry_run=dry_run)

def sync_progress(self, m: Media, dry_run=False):
async def sync_progress(self, m: Media, dry_run=False):
p = self.trakt.watch_progress.match(m)
if not p:
return
Expand Down

0 comments on commit ff1727e

Please sign in to comment.