Example #1
0
    def run_episodes(self):
        # Iterate over plex episodes
        for ids, guid, (season_num, episode_num), p_show, p_season, p_episode in self.p_episodes:
            # Increment one step
            self.current.progress.group(Shows, 'episodes').step()

            # Process `p_guid` (map + validate)
            match = GuidParser.parse(guid, (season_num, episode_num))

            if not match.supported:
                mark_unsupported(self.p_shows_unsupported, ids['show'], guid)
                continue

            if not match.found:
                log.info('Unable to find identifier for: %s/%s (rating_key: %r)', guid.service, guid.id, ids['show'])
                continue

            # Process episode
            self.run_episode(ids, match, p_show, p_episode)

            # Task checkpoint
            self.checkpoint()

        # Stop progress group
        self.current.progress.group(Shows, 'episodes').stop()
Example #2
0
    def run(self):
        for mo_id, guid, p_item in self.p_movies:
            # Increment one step
            self.current.progress.group(Movies, 'matched:movies').step()

            # Parse guid
            match = GuidParser.parse(guid)

            if not match.supported:
                mark_unsupported(self.p_unsupported, mo_id, guid)
                continue

            if not match.found:
                log.info('Unable to find identifier for: %s/%s (rating_key: %r)', guid.service, guid.id, mo_id)
                continue

            # Retrieve primary key for item
            pk = self.trakt.table('movies').get((match.guid.service, match.guid.id))

            # Process movie (execute handlers)
            self.execute_movie(mo_id, pk, match.guid, p_item)

            # Remove movie from pending items collection
            self.current.pending['movies'].remove(pk)

            # Task checkpoint
            self.checkpoint()

        # Stop progress group
        self.current.progress.group(Movies, 'matched:movies').stop()

        # Report unsupported movies (unsupported guid)
        log_unsupported(log, 'Found %d unsupported movie(s)', self.p_unsupported)
Example #3
0
    def run_shows(self):
        # Iterate over plex shows
        for sh_id, guid, p_show in self.p_shows:
            # Increment one step
            self.current.progress.group(Shows, 'matched:shows').step()

            # Process `p_guid` (map + validate)
            match = GuidParser.parse(guid)

            if not match.supported:
                mark_unsupported(self.p_shows_unsupported, sh_id, guid)
                continue

            if not match.found:
                log.info(
                    'Unable to find identifier for: %s/%s (rating_key: %r)',
                    guid.service, guid.id, sh_id)
                continue

            # Process show
            self.run_show(sh_id, match, p_show)

            # Task checkpoint
            self.checkpoint()

        # Stop progress group
        self.current.progress.group(Shows, 'matched:shows').stop()
Example #4
0
    def run_episodes(self):
        # Iterate over plex episodes
        for ids, guid, (
                season_num,
                episode_num), p_show, p_season, p_episode in self.p_episodes:
            # Increment one step
            self.current.progress.group(Shows, 'matched:episodes').step()

            # Parse guid
            match = GuidParser.parse(guid, (season_num, episode_num))

            if not match.supported:
                mark_unsupported(self.p_shows_unsupported, ids['show'], guid)
                continue

            if not match.found:
                log.info(
                    'Unable to find identifier for: %s/%s (rating_key: %r)',
                    guid.service, guid.id, ids['show'])
                continue

            # Process episode
            self.run_episode(ids, match, p_show, p_season, p_episode)

            # Task checkpoint
            self.checkpoint()

        # Stop progress group
        self.current.progress.group(Shows, 'matched:episodes').stop()
Example #5
0
    def run(self):
        for mo_id, guid, p_item in self.p_movies:
            # Increment one step
            self.current.progress.group(Movies, 'matched:movies').step()

            # Parse guid
            match = GuidParser.parse(guid)

            if not match.supported:
                mark_unsupported(self.p_unsupported, mo_id, guid)
                continue

            if not match.found:
                log.info('Unable to find identifier for: %s/%s (rating_key: %r)', guid.service, guid.id, mo_id)
                continue

            # Retrieve primary key for item
            pk = self.trakt.table('movies').get((match.guid.service, match.guid.id))

            # Process movie (execute handlers)
            self.execute_movie(mo_id, pk, match.guid, p_item)

            # Remove movie from pending items collection
            self.current.pending['movies'].remove(pk)

            # Task checkpoint
            self.checkpoint()

        # Stop progress group
        self.current.progress.group(Movies, 'matched:movies').stop()

        # Report unsupported movies (unsupported guid)
        log_unsupported(log, 'Found %d unsupported movie(s)', self.p_unsupported)
Example #6
0
    def run_shows(self):
        # Iterate over plex shows
        for sh_id, guid, p_show in self.p_shows:
            # Increment one step
            self.current.progress.group(Shows, 'matched:shows').step()

            # Process `p_guid` (map + validate)
            match = GuidParser.parse(guid)

            if not match.supported:
                mark_unsupported(self.p_shows_unsupported, sh_id, guid)
                continue

            if not match.found:
                log.info('Unable to find identifier for: %s/%s (rating_key: %r)', guid.service, guid.id, sh_id)
                continue

            # Process show
            self.run_show(sh_id, match, p_show)

            # Task checkpoint
            self.checkpoint()

        # Stop progress group
        self.current.progress.group(Shows, 'matched:shows').stop()
Example #7
0
    def run(self):
        for mo_id, guid, p_movie in self.p_movies:
            # Parse guid
            match = GuidParser.parse(guid)

            if not match.supported:
                mark_unsupported(self.p_unsupported, mo_id, guid)
                continue

            if not match.found:
                log.info(
                    'Unable to find identifier for: %s/%s (rating_key: %r)',
                    guid.service, guid.id, mo_id)
                continue

            key = (match.guid.service, match.guid.id)

            # Try retrieve `pk` for `key`
            pk = self.trakt.table('movies').get(key)

            # Store in item map
            self.current.map.add(p_movie.get('library_section'), mo_id,
                                 [key, pk])

            if pk is None:
                # No `pk` found
                continue

            # Execute data handlers
            for data in self.get_data(SyncMedia.Movies):
                t_movie = self.trakt[(SyncMedia.Movies, data)].get(pk)

                self.execute_handlers(self.mode,
                                      SyncMedia.Movies,
                                      data,
                                      key=mo_id,
                                      p_item=p_movie,
                                      t_item=t_movie)

                # Increment one step
                self.step(self.p_pending, data, pk)

            # Task checkpoint
            self.checkpoint()

        # Log details
        log_unsupported(log, 'Found %d unsupported movie(s)',
                        self.p_unsupported)
        log.debug('Pending: %r', self.p_pending)
Example #8
0
    def run(self):
        for mo_id, guid, p_movie in self.p_movies:
            # Parse guid
            match = GuidParser.parse(guid)

            if not match.supported:
                mark_unsupported(self.p_unsupported, mo_id, guid)
                continue

            if not match.found:
                log.info('Unable to find identifier for: %s/%s (rating_key: %r)', guid.service, guid.id, mo_id)
                continue

            key = (match.guid.service, match.guid.id)

            # Try retrieve `pk` for `key`
            pk = self.trakt.table('movies').get(key)

            # Store in item map
            self.current.map.add(p_movie.get('library_section'), mo_id, [key, pk])

            if pk is None:
                # No `pk` found
                continue

            # Execute data handlers
            for data in self.get_data(SyncMedia.Movies):
                t_movie = self.trakt[(SyncMedia.Movies, data)].get(pk)

                self.execute_handlers(
                    self.mode, SyncMedia.Movies, data,
                    key=mo_id,

                    p_item=p_movie,
                    t_item=t_movie
                )

                # Increment one step
                self.step(self.p_pending, data, pk)

            # Task checkpoint
            self.checkpoint()

        # Log details
        log_unsupported(log, 'Found %d unsupported movie(s)', self.p_unsupported)
        log.debug('Pending: %r', self.p_pending)
Example #9
0
    def run_episodes(self):
        for ids, guid, (season_num, episode_num), p_show, p_season, p_episode in self.p_episodes:
            # Process `p_guid` (map + validate)
            match = GuidParser.parse(guid, (season_num, episode_num))

            if not match.supported:
                mark_unsupported(self.p_shows_unsupported, ids['show'], guid)
                continue

            if not match.found:
                log.info('Unable to find identifier for: %s/%s (rating_key: %r)', guid.service, guid.id, ids['show'])
                continue

            # Process episode
            self.run_episode(ids, match, p_show, p_episode)

            # Task checkpoint
            self.checkpoint()
Example #10
0
    def run_shows(self):
        for sh_id, guid, p_show in self.p_shows:
            # Parse guid
            match = GuidParser.parse(guid)

            if not match.supported:
                mark_unsupported(self.p_shows_unsupported, sh_id, guid)
                continue

            if not match.found:
                log.info(
                    'Unable to find identifier for: %s/%s (rating_key: %r)',
                    guid.service, guid.id, sh_id)
                continue

            key = (match.guid.service, match.guid.id)

            # Try retrieve `pk` for `key`
            pk = self.trakt.table('shows').get(key)

            # Store in item map
            self.current.map.add(p_show.get('library_section'), sh_id,
                                 [key, pk])

            if pk is None:
                # No `pk` found
                continue

            # Execute handlers
            for data in self.get_data(SyncMedia.Shows):
                t_show = self.trakt[(SyncMedia.Shows, data)].get(pk)

                # Execute show handlers
                self.execute_handlers(self.mode,
                                      SyncMedia.Shows,
                                      data,
                                      key=sh_id,
                                      p_item=p_show,
                                      t_item=t_show)
Example #11
0
    def run_episodes(self):
        for ids, guid, (
                season_num,
                episode_num), p_show, p_season, p_episode in self.p_episodes:
            # Process `p_guid` (map + validate)
            match = GuidParser.parse(guid, (season_num, episode_num))

            if not match.supported:
                mark_unsupported(self.p_shows_unsupported, ids['show'], guid)
                continue

            if not match.found:
                log.info(
                    'Unable to find identifier for: %s/%s (rating_key: %r)',
                    guid.service, guid.id, ids['show'])
                continue

            # Process episode
            self.run_episode(ids, match, p_show, p_episode)

            # Task checkpoint
            self.checkpoint()
Example #12
0
    def run_shows(self):
        for sh_id, guid, p_show in self.p_shows:
            # Parse guid
            match = GuidParser.parse(guid)

            if not match.supported:
                mark_unsupported(self.p_shows_unsupported, sh_id, guid)
                continue

            if not match.found:
                log.info('Unable to find identifier for: %s/%s (rating_key: %r)', guid.service, guid.id, sh_id)
                continue

            key = (match.guid.service, match.guid.id)

            # Try retrieve `pk` for `key`
            pk = self.trakt.table('shows').get(key)

            # Store in item map
            self.current.map.add(p_show.get('library_section'), sh_id, [key, pk])

            if pk is None:
                # No `pk` found
                continue

            # Execute handlers
            for data in self.get_data(SyncMedia.Shows):
                t_show = self.trakt[(SyncMedia.Shows, data)].get(pk)

                # Execute show handlers
                self.execute_handlers(
                    self.mode, SyncMedia.Shows, data,
                    key=sh_id,

                    p_item=p_show,
                    t_item=t_show
                )
Example #13
0
    def run(self):
        # Process movies
        for mo_id, guid, p_movie in self.p_movies:
            # Increment one step
            self.current.progress.group(Movies).step()

            # Parse guid
            match = GuidParser.parse(guid)

            if not match.supported:
                mark_unsupported(self.p_unsupported, mo_id, guid)
                continue

            if not match.found:
                log.info(
                    'Unable to find identifier for: %s/%s (rating_key: %r)',
                    guid.service, guid.id, mo_id)
                continue

            key = (match.guid.service, match.guid.id)

            # Try retrieve `pk` for `key`
            pk = self.trakt.table('movies').get(key)

            # Store in item map
            self.current.map.add(p_movie.get('library_section'), mo_id,
                                 [key, pk])

            if pk is None:
                # No `pk` found
                continue

            # Run pull handlers if the item has been added recently
            if self.should_pull(mo_id, p_movie.get('added_at')):
                log.info(
                    'Movie %r has been added recently, running pull sync instead',
                    mo_id)

                # Execute handlers
                for data in self.get_data(SyncMedia.Movies):
                    t_movie = self.trakt[(SyncMedia.Movies, data)].get(pk)

                    self.execute_handlers(SyncMode.Pull,
                                          SyncMedia.Movies,
                                          data,
                                          key=mo_id,
                                          p_item=p_movie,
                                          t_item=t_movie)
            else:
                # Execute handlers for changed data
                for data, action, t_movie in self.iter_changes(
                        SyncMedia.Movies, pk):
                    self.execute_handlers(self.mode,
                                          SyncMedia.Movies,
                                          data,
                                          action=action,
                                          key=mo_id,
                                          p_item=p_movie,
                                          t_item=t_movie)

            # Task checkpoint
            self.checkpoint()

        # Stop progress group
        self.current.progress.group(Movies).stop()

        # Log details
        log_unsupported(log, 'Found %d unsupported movie(s)',
                        self.p_unsupported)
Example #14
0
    def run(self):
        # Process movies
        for mo_id, guid, p_movie in self.p_movies:
            # Increment one step
            self.current.progress.group(Movies).step()

            # Parse guid
            match = GuidParser.parse(guid)

            if not match.supported:
                mark_unsupported(self.p_unsupported, mo_id, guid)
                continue

            if not match.found:
                log.info('Unable to find identifier for: %s/%s (rating_key: %r)', guid.service, guid.id, mo_id)
                continue

            key = (match.guid.service, match.guid.id)

            # Try retrieve `pk` for `key`
            pk = self.trakt.table('movies').get(key)

            # Store in item map
            self.current.map.add(p_movie.get('library_section'), mo_id, [key, pk])

            if pk is None:
                # No `pk` found
                continue

            # Run pull handlers if the item has been added recently
            if self.should_pull(mo_id, p_movie.get('added_at')):
                log.info('Movie %r has been added recently, running pull sync instead', mo_id)

                # Execute handlers
                for data in self.get_data(SyncMedia.Movies):
                    t_movie = self.trakt[(SyncMedia.Movies, data)].get(pk)

                    self.execute_handlers(
                        SyncMode.Pull, SyncMedia.Movies, data,
                        key=mo_id,

                        p_item=p_movie,
                        t_item=t_movie
                    )
            else:
                # Execute handlers for changed data
                for data, action, t_movie in self.iter_changes(SyncMedia.Movies, pk):
                    self.execute_handlers(
                        self.mode, SyncMedia.Movies, data,
                        action=action,
                        key=mo_id,

                        p_item=p_movie,
                        t_item=t_movie
                    )

            # Task checkpoint
            self.checkpoint()

        # Stop progress group
        self.current.progress.group(Movies).stop()

        # Log details
        log_unsupported(log, 'Found %d unsupported movie(s)', self.p_unsupported)