Beispiel #1
0
    def perform(self, query):
        log.info('EpisodeTagger tagging episode: %s', u(query.find_one(Media).filename))
        filenameMetadata = SolvingChain(EpisodeFilename()).solve(query)

        log.info('EpisodeTagger found info: %s', u(filenameMetadata.find_one(Episode)))
        result = SolvingChain(EpisodeTVDB(), SimpleSolver(Episode)).solve(filenameMetadata)

        media = result.find_one(Media)

        # if we didn't find a valid episode but we still have a series, let's create a syntactically
        # valid episode anyway so it can be imported
        if not media.metadata.get('episodeNumber'):
            media.metadata.episodeNumber = -1

        # import subtitles correctly
        if media.type() == 'subtitle':
            subs = []
            for language in utils.guessCountryCodes(media.filename):
                log.info('Found %s sub in file %s' % (language.english_name, u(media.filename)))
                subs += [ result.Subtitle(metadata = media.metadata,
                                          language = language.alpha2) ]

            media.metadata = subs


        self.cleanup(result)

        log.debug('Finished tagging: %s', u(media.filename))
        return result
Beispiel #2
0
    def perform(self, query):
        filename = u(query.find_one(Media).filename)
        log.info('MovieTagger tagging movie: %s' % filename)
        filenameMetadata = MovieFilename().perform(query)
        filenameMovie = filenameMetadata.find_one(Movie)
        log.info('MovieTagger found info: %s' % u(filenameMovie))
        result = MovieTMDB().perform(filenameMetadata)

        media = result.find_one(Media)
        if not media.metadata:
            log.warning('Could not find any tag for: %s' % u(media))

        # import the info we got from the filename if nothing better came in with MovieTMDB
        for prop in filenameMovie.keys():
            if prop not in media.metadata and prop not in media:
                media[prop] = filenameMovie[prop]

        # import subtitles correctly
        if media.type() == 'subtitle':
            # FIXME: problem for vobsubs: as a media points to a single metadata object, we cannot
            # represent a .sub for 3 different languages...
            subs = []
            for language in utils.guessCountryCodes(media.filename):
                subs += [ result.Subtitle(metadata = media.metadata,
                                          language = language.alpha2) ]

            media.metadata = subs


        self.cleanup(result)

        log.debug('Finished tagging: %s' % u(media))
        return result
Beispiel #3
0
    def perform(self, query):
        filename = u(query.find_one(Media).filename)
        log.info('MovieTagger tagging movie: %s' % filename)
        filenameMetadata = MovieFilename().perform(query)
        filenameMovie = filenameMetadata.find_one(Movie)
        log.info('MovieTagger found info: %s' % u(filenameMovie))
        result = MovieTMDB().perform(filenameMetadata)

        media = result.find_one(Media)
        if not media.metadata:
            log.warning('Could not find any tag for: %s' % u(media))

        # import the info we got from the filename if nothing better came in with MovieTMDB
        for prop in filenameMovie.keys():
            if prop not in media.metadata and prop not in media:
                media[prop] = filenameMovie[prop]

        # import subtitles correctly
        if media.type() == 'subtitle':
            # FIXME: problem for vobsubs: as a media points to a single metadata object, we cannot
            # represent a .sub for 3 different languages...
            subs = []
            for language in utils.guessCountryCodes(media.filename):
                subs += [
                    result.Subtitle(metadata=media.metadata,
                                    language=language.alpha2)
                ]

            media.metadata = subs

        self.cleanup(result)

        log.debug('Finished tagging: %s' % u(media))
        return result