Esempio n. 1
0
        def movies_iterator():
            for row in self._tuple_iterator(query):
                id, guid, tag, movie = self._parse(fields, row, offset=3)

                # Parse `guid` (if enabled, and not already parsed)
                if parse_guid:
                    if id not in guids:
                        if tag:
                            guids[id] = Guid.parse(tag, strict=True)
                        else:
                            guids[id] = Guid.parse(guid, strict=True)
                    guid = guids[id]

                # Return item
                yield id, guid, movie
Esempio n. 2
0
    def item_map(cls, table, item):
        metadata = Metadata.get(item.rating_key)

        if not metadata:
            log.warn('Unable to map item "%s" - unable to retrieve metadata', item.rating_key)
            return False

        # Update with extended information
        item.guid = metadata.guid

        # Parse guid
        guid = Guid.parse(item.guid, strict=True)

        if not guid or not guid.valid:
            log.warn('Unable to map item "%s" - invalid/missing "guid" property (guid: %r)', item.rating_key, item.guid)
            return False

        # Build key
        key = (guid.agent, guid.sid)

        # Map item into table
        if key not in table:
            table[key] = []

        table[key].append(item)
        return True
Esempio n. 3
0
        def episodes_iterator():
            for sh_id, se_id, ep_id, ep_index, episode in episodes:
                # Retrieve parents
                if sh_id not in shows:
                    log.debug('Unable to find show by id: %r', sh_id)
                    continue

                guid, show = shows[sh_id]

                if se_id not in seasons:
                    log.debug('Unable to find season by id: %r', se_id)
                    continue

                season = seasons[se_id]

                # Parse `guid` (if enabled, and not already parsed)
                if parse_guid:
                    if id not in guids:
                        guids[sh_id] = Guid.parse(guid)

                    guid = guids[sh_id]

                # Use primed `Matcher` buffer
                with context:
                    # Run `Matcher` on episode
                    season_num, episode_nums = self.matcher.process_episode(
                        ep_id, (season['index'], ep_index),
                        episode['part']['file'])

                for episode_num in episode_nums:
                    ids = {'show': sh_id, 'season': se_id, 'episode': ep_id}

                    yield ids, guid, (season_num,
                                      episode_num), show, season, episode
Esempio n. 4
0
    def item_map(cls, table, item):
        metadata = Metadata.get(item.rating_key)

        if not metadata:
            log.warn('Unable to map item "%s" - unable to retrieve metadata',
                     item.rating_key)
            return False

        # Update with extended information
        item.guid = metadata.guid

        # Parse guid
        guid = Guid.parse(item.guid)

        if not guid:
            log.warn(
                'Unable to map item "%s" - invalid/missing "guid" property (guid: %r)',
                item.rating_key, item.guid)
            return False

        # Build key
        key = (guid.agent, guid.sid)

        # Map item into table
        if key not in table:
            table[key] = []

        table[key].append(item)
        return True
Esempio n. 5
0
        def shows_iterator():
            for sh_id, (guid, show) in shows.items():
                # Parse `guid` (if enabled, and not already parsed)
                if parse_guid:
                    if id not in guids:
                        guids[sh_id] = Guid.parse(guid, strict=True)

                    guid = guids[sh_id]

                yield sh_id, guid, show
Esempio n. 6
0
        def shows_iterator():
            for sh_id, (guid, show) in shows.items():
                # Parse `guid` (if enabled, and not already parsed)
                if parse_guid:
                    if id not in guids:
                        guids[sh_id] = Guid.parse(guid)

                    guid = guids[sh_id]

                yield sh_id, guid, show
Esempio n. 7
0
        def movies_iterator():
            for id, guid, movie in movies:
                # Parse `guid` (if enabled, and not already parsed)
                if parse_guid:
                    if id not in guids:
                        guids[id] = Guid.parse(guid)

                    guid = guids[id]

                # Return item
                yield id, guid, movie
Esempio n. 8
0
        def movies_iterator():
            for id, guid, movie in movies:
                # Parse `guid` (if enabled, and not already parsed)
                if parse_guid:
                    if id not in guids:
                        guids[id] = Guid.parse(guid)

                    guid = guids[id]

                # Return item
                yield id, guid, movie
Esempio n. 9
0
        def movies_iterator():
            for row in self._tuple_iterator(query):
                id, guid, movie = self._parse(fields, row, offset=2)

                # Parse `guid` (if enabled, and not already parsed)
                if parse_guid:
                    if id not in guids:
                        guids[id] = Guid.parse(guid, strict=True)

                    guid = guids[id]

                # Return item
                yield id, guid, movie
Esempio n. 10
0
        def episodes_iterator():
            for sh_id, se_id, ep_id, ep_index, episode in episodes:
                # Retrieve parents
                if sh_id not in shows:
                    log.debug('Unable to find show by id: %r', sh_id)
                    continue

                guid, show = shows[sh_id]

                if se_id not in seasons:
                    log.debug('Unable to find season by id: %r', se_id)
                    continue

                season = seasons[se_id]

                # Parse `guid` (if enabled, and not already parsed)
                if parse_guid:
                    if id not in guids:
                        guids[sh_id] = Guid.parse(guid, strict=True)

                    guid = guids[sh_id]

                # Retrieve episode identifier
                season_num, episode_nums = season['index'], [ep_index]

                # Run `Matcher` on episode (if available)
                if self.matcher is not None:
                    with context:
                        season_num, episode_nums = self.matcher.process_episode(
                            ep_id,
                            (season['index'], ep_index),
                            episode['part']['file']
                        )

                for episode_num in episode_nums:
                    ids = {
                        'show': sh_id,
                        'season': se_id,
                        'episode': ep_id
                    }

                    yield ids, guid, (season_num, episode_num), show, season, episode