Beispiel #1
0
    def remove_from_library(self):
        """Remove show from Medusa library if it is ended/completed."""
        if not (app.TRAKT_SYNC_WATCHLIST and app.USE_TRAKT and app.TRAKT_REMOVE_SHOW_FROM_APPLICATION):
            return

        log.debug('Retrieving ended/completed shows to remove from Medusa')

        if not app.showList:
            return

        for show in app.showList:
            if show.status == 'Ended':
                trakt_id = show.externals.get('trakt_id', None)
                if not (trakt_id or show.imdb_id):
                    log.info("Unable to check Trakt progress for show '{show}' "
                             'because Trakt|IMDB ID is missing. Skipping', {'show': show.name})
                    continue

                try:
                    trakt_show = tv.TVShow(str(trakt_id or show.imdb_id))
                    progress = trakt_show.progress
                except TraktException as error:
                    log.info("Unable to check if show '{show}' is ended/completed. Error: {error!r}", {
                        'show': show.name,
                        'error': error
                    })
                    continue
                else:
                    if progress and progress.get('aired', True) == progress.get('completed', False):
                        app.show_queue_scheduler.action.removeShow(show, full=True)
                        log.info("Show '{show}' has being queued to be removed from Medusa library", {
                            'show': show.name
                        })
Beispiel #2
0
    def add_episode_to_watchlist(episode):
        """
        Add an episode to the trakt watchlist.

        :params episode: Episode Object.
        """
        show_id = None

        try:
            tv_show = tv.TVShow(show_id)
            tv_episode = tv.TVEpisode(tv_show, episode.season, episode.episode)
            tv_episode.add_to_watchlist()
        except TraktException as error:
            log.warning('Unable to add episode to watchlist: {error!r}', {'error': error})