Пример #1
0
    def get_meta(self):
        self.vid.hostname = self.db.gethostname()

        if self.rec.subtitle:  # subtitle exists, assume tv show
            self.type = 'TV'
            self.log(self.log.IMPORTANT, 'Attempting TV export.')
            if self.opts.listingonly:
                self.log(self.log.IMPORTANT, 'Forcing listing data only.')
                self.get_generic(False)
                return
            grab = VideoGrabber(self.type)
            match = grab.sortedSearch(self.rec.title, self.rec.subtitle)
        else:  # assume movie
            self.type = 'MOVIE'
            self.log(self.log.IMPORTANT, 'Attempting Movie export.')
            if self.opts.listingonly:
                self.log(self.log.IMPORTANT, 'Forcing listing data only.')
                self.get_generic(False)
                return
            grab = VideoGrabber(self.type)
            match = grab.sortedSearch(self.rec.title)

        if len(match) == 0:
            # no match found
            self.log(self.log.IMPORTANT, 'Falling back to generic export.')
            self.get_generic()
        elif (len(match) > 1) & (match[0].levenshtein > 0):
            # multiple matches found, and closest is not exact
            self.vid.delete()
            raise MythError('Multiple metadata matches found: '\
                                                   +self.rec.title)
        else:
            self.log(self.log.IMPORTANT, 'Importing content from',
                     match[0].inetref)
            self.vid.importMetadata(grab.grabInetref(match[0]))
Пример #2
0
    def get_meta(self):
        self.vid.hostname = self.db.gethostname()

        if self.rec.subtitle:  # subtitle exists, assume tv show
            self.type = 'TV'
            self.log(self.log.IMPORTANT, 'Attempting TV export.')
            if self.opts.listingonly:
                self.log(self.log.IMPORTANT, 'Forcing listing data only.')
                self.get_generic(False)
                return
            grab = VideoGrabber(self.type)
            match = grab.sortedSearch(self.rec.title, self.rec.subtitle)
        else:  # assume movie
            self.type = 'MOVIE'
            self.log(self.log.IMPORTANT, 'Attempting Movie export.')
            if self.opts.listingonly:
                self.log(self.log.IMPORTANT, 'Forcing listing data only.')
                self.get_generic(False)
                return
            grab = VideoGrabber(self.type)
            match = grab.sortedSearch(self.rec.title)

        if len(match) == 0:
            # no match found
            self.log(self.log.IMPORTANT, 'Falling back to generic export.')
            self.get_generic()
        elif (len(match) > 1) & (match[0].levenshtein > 0):
            # multiple matches found, and closest is not exact
            self.vid.delete()
            raise MythError('Multiple metadata matches found: '\
                                                   + self.rec.title)
        else:
            self.log(self.log.IMPORTANT, 'Importing content from', match[0].inetref)
            self.vid.importMetadata(grab.grabInetref(match[0]))
Пример #3
0
    def get_meta(self):
        self.vid.hostname = self.db.gethostname()
        if self.rec.inetref:
            # good data is available, use it
            if self.rec.season > 0 or self.rec.episode > 0:
                self.log(self.log.GENERAL, self.log.INFO,
                        'Performing TV export with local data.')
                self.type = 'TV'
                grab = VideoGrabber(self.type)
                metadata = grab.grabInetref(self.rec.inetref, self.rec.season, self.rec.episode)
            else:
                self.log(self.log.GENERAL, self.log.INFO,
                        'Performing Movie export with local data.')
                self.type = 'MOVIE'
                grab = VideoGrabber(self.type)
                metadata = grab.grabInetref(self.rec.inetref)
        elif self.opts.listingonly:
            # force use of local data
            if self.rec.subtitle:
                self.log(self.log.GENERAL, self.log.INFO,
                        'Forcing TV export with local data.')
                self.type = 'TV'
            else:
                self.log(self.log.GENERAL, self.log.INFO,
                        'Forcing Movie export with local data.')
                self.type = 'MOVIE'
            metadata = self.rec.exportMetadata()
        else:
            if self.rec.subtitle:
                # subtitle exists, assume tv show
                self.type = 'TV'
                self.log(self.log.GENERAL, self.log.INFO,
                        'Attempting TV export.')
                grab = VideoGrabber(self.type)
                match = grab.sortedSearch(self.rec.title, self.rec.subtitle)
            else:                   # assume movie
                self.type = 'MOVIE'
                self.log(self.log.GENERAL, self.log.INFO,
                        'Attempting Movie export.')
                grab = VideoGrabber(self.type)
                match = grab.sortedSearch(self.rec.title)

            if len(match) == 0:
                # no match found
                self.log(self.log.GENERAL, self.log.INFO,
                        'Falling back to generic export.')
                self.type = 'GENERIC'
                metadata = self.rec.exportMetadata()
            elif (len(match) > 1) & (match[0].levenshtein > 0):
                # multiple matches found, and closest is not exact
                self.vid.delete()
                raise MythError('Multiple metadata matches found: '\
                                                   +self.rec.title)
            else:
                self.log(self.log.GENERAL, self.log.INFO,
                        'Importing content from', match[0].inetref)
                metadata = grab.grabInetref(match[0])

        self.vid.importMetadata(metadata)
        self.log(self.log.GENERAL, self.log.INFO, 'Import complete')
Пример #4
0
    def get_meta(self):
        self.vid.hostname = self.db.gethostname()
        if self.rec.inetref:
            # good data is available, use it
            if self.rec.season is not None:
                self.log(self.log.GENERAL, self.log.INFO,
                         'Performing TV export with local data.')
                self.type = 'TV'
            else:
                self.log(self.log.GENERAL, self.log.INFO,
                         'Performing Movie export with local data.')
                self.type = 'MOVIE'
            metadata = self.rec.exportMetadata()
        elif self.opts.listingonly:
            # force use of local data
            if self.rec.subtitle:
                self.log(self.log.GENERAL, self.log.INFO,
                         'Forcing TV export with local data.')
                self.type = 'TV'
            else:
                self.log(self.log.GENERAL, self.log.INFO,
                         'Forcing Movie export with local data.')
                self.type = 'MOVIE'
            metadata = self.rec.exportMetadata()
        else:
            if self.rec.subtitle:
                # subtitle exists, assume tv show
                self.type = 'TV'
                self.log(self.log.GENERAL, self.log.INFO,
                         'Attempting TV export.')
                grab = VideoGrabber(self.type)
                match = grab.sortedSearch(self.rec.title, self.rec.subtitle)
            else:  # assume movie
                self.type = 'MOVIE'
                self.log(self.log.GENERAL, self.log.INFO,
                         'Attempting Movie export.')
                grab = VideoGrabber(self.type)
                match = grab.sortedSearch(self.rec.title)

            if len(match) == 0:
                # no match found
                self.log(self.log.GENERAL, self.log.INFO,
                         'Falling back to generic export.')
                self.type = 'GENERIC'
                metadata = self.rec.exportMetadata()
            elif (len(match) > 1) & (match[0].levenshtein > 0):
                # multiple matches found, and closest is not exact
                self.vid.delete()
                raise MythError('Multiple metadata matches found: '\
                                                   +self.rec.title)
            else:
                self.log(self.log.GENERAL, self.log.INFO,
                         'Importing content from', match[0].inetref)
                metadata = grab.grabInetref(match[0])

        self.vid.importMetadata(metadata)
        self.log(self.log.GENERAL, self.log.INFO, 'Import complete')
Пример #5
0
    def test_Dataheap_VideoGrabber_001_sortedSearch_01(self):
        """Test 'sortedSearch' method from MythTV.VideoGrabber
           using predefined  values.
        """
        from MythTV import MythDB, RecordedArtwork, Video, VideoGrabber

        with add_log_flags():
            self.mydb =  MythDB()

            title      = self.testenv['VIDTITLE_DE']
            cast       = self.testenv['VIDCAST_DE']
            inetrefstr = self.testenv['VIDINETREF_DE']
            lang       = self.testenv['VIDLANGUAGE_DE']

            # remove grabber from inetref:
            try:
                inetref = inetrefstr.split('_')[-1]
            except IndexError:
                inetref = inetrefstr

            grab = VideoGrabber("Movie", lang=lang, db=self.mydb)
            metadatalist = grab.sortedSearch(title, subtitle=None, tolerance=2)
            inetref_found = False
            for m in metadatalist:
                if (m.inetref == inetref):
                    inetref_found = True
                    break
            self.assertTrue(inetref_found)
Пример #6
0
    def get_meta(self):
        metadata = self.rec.exportMetadata()
        yrInfo = self.rec.getProgram()
        metadata['year'] = yrInfo.get('year')
        self.vid.importMetadata(metadata)
        if self.type == 'MOVIE':
            grab = VideoGrabber('Movie')
            results = grab.sortedSearch(self.rec.title)
            if len(results) > 0:
                for i in results:
                    if i.year == yrInfo.get(
                            'year') and i.title == self.rec.get('title'):
                        self.vid.importMetadata(i)
                        match = grab.grabInetref(i.get('inetref'))
                        length = len(match.people)
                        for p in range(length - 2):
                            self.vid.cast.add(match.people[p].get('name'))
                        self.vid.director = match.people[length -
                                                         1].get('name')
                        import_info = 'Full MetaData Import complete'
            elif len(results) == 0:
                import_info = 'Listing only MetaData import complete'
        else:
            grab = VideoGrabber('TV')
            results = grab.sortedSearch(self.rec.title, self.rec.subtitle)
            if len(results) > 0:
                for i in results:
                    if i.title == self.rec.get(
                            'title') and i.subtitle == self.rec.get(
                                'subtitle'):
                        self.vid.importMetadata(i)
                        match = grab.grabInetref(grab.grabInetref(i.get('inetref'), \
                                season=i.get('season'),episode=i.get('episode')))
                        length = len(match.people)
                        for p in range(length - 2):
                            self.vid.cast.add(match.people[p].get('name'))
                        self.vid.director = match.people[length -
                                                         1].get('name')
                        import_info = 'Full MetaData Import complete'
            elif len(results) == 0:
                import_info = 'Listing only MetaData import complete'

        self.vid.category = self.rec.get('category')

        self.log(self.log.GENERAL, self.log.INFO, import_info)
Пример #7
0
    def get_metadata(self):
        """ Get Metadata
        Get the recording metadata.
        """
        self.vid.hostname = self.db.gethostname()
        try:
            if self.rec.inetref:
                # good data is available, use it
                if self.rec.season > 0 or self.rec.episode > 0:
                    self.type = 'TV'
                    grab = VideoGrabber(self.type)
                    metadata = grab.grabInetref(self.rec.inetref, self.rec.season, self.rec.episode)
                else:
                    self.type = 'MOVIE'
                    grab = VideoGrabber(self.type)
                    metadata = grab.grabInetref(self.rec.inetref)
            else:
                if self.rec.subtitle:
                    # subtitle exists, assume tv show
                    self.type = 'TV'
                    grab = VideoGrabber(self.type)
                    match = grab.sortedSearch(self.rec.title, self.rec.subtitle)
                else: # assume movie
                    self.type = 'MOVIE'
                    grab = VideoGrabber(self.type)
                    match = grab.sortedSearch(self.rec.title)

                if len(match) == 0:
                    # no match found
                    metadata = self.rec.exportMetadata()
                elif (len(match) > 1) & (match[0].levenshtein > 0):
                    # multiple matches found, and closest is not exact
                    self.vid.delete()
                    raise ArchiveError('Multiple metadata matches found: '\
                                                       +self.rec.title)
                else:
                    metadata = grab.grabInetref(match[0])
        except (MythError, StopIteration), e:
            self.log.warning('Error Getting Metadata: %r' % e)
            metadata = self.rec.exportMetadata()
Пример #8
0
    def get_meta(self):
        import_info = 'Listing only MetaData import complete'
        metadata = self.rec.exportMetadata()
        yrInfo = self.rec.getProgram()
        metadata['year'] = yrInfo.get('year')
        self.vid.importMetadata(metadata)
        if self.type == 'MOVIE':
            grab = VideoGrabber('Movie')
            results = grab.sortedSearch(self.rec.title)
            if len(results) > 0:
                for i in results:
                    if i.year == yrInfo.get('year') and i.title == self.rec.get('title'):
                        self.vid.importMetadata(i)
                        match = grab.grabInetref(i.get('inetref'))
                        length = len(match.people)
                        for p in range(length-2):
                            self.vid.cast.add(match.people[p].get('name'))
                        self.vid.director = match.people[length - 1].get('name')
                        import_info = 'Full MetaData Import complete'
        else:
            grab = VideoGrabber('TV')
            results = grab.sortedSearch(self.rec.title, self.rec.subtitle)
            if len(results) > 0:
                for i in results:
                    if  i.title == self.rec.get('title') and i.subtitle == self.rec.get('subtitle'):
                        self.vid.importMetadata(i)
                        match = grab.grabInetref(grab.grabInetref(i.get('inetref'), \
                                season=i.get('season'),episode=i.get('episode')))
                        length = len(match.people)
                        for p in range(length-2):
                            self.vid.cast.add(match.people[p].get('name'))
                        self.vid.director = match.people[length - 1].get('name')
                        import_info = 'Full MetaData Import complete'
            
        
        self.vid.category = self.rec.get('category')

        self.log(self.log.GENERAL, self.log.INFO, import_info)
Пример #9
0
    def test_Dataheap_VideoGrabber_001_grabInetref_01(self):
        """Test 'grabInetref' and 'toXML' methods from MythTV.VideoGrabber
           using predefined  values.
        """
        from MythTV import MythDB, RecordedArtwork, Video, VideoGrabber

        with add_log_flags():
            self.mydb =  MythDB()

            title      = self.testenv['VIDTITLE_DE']
            cast       = self.testenv['VIDCAST_DE']
            inetrefstr = self.testenv['VIDINETREF_DE']
            lang       = self.testenv['VIDLANGUAGE_DE']

            # remove grabber from inetref:
            try:
                inetref = inetrefstr.split('_')[-1]
            except IndexError:
                inetref = inetrefstr

            grab = VideoGrabber("Movie", lang=lang, db=self.mydb)
            metadatalist = grab.sortedSearch(title, subtitle=None, tolerance=2)

            details = grab.grabInetref(metadatalist[0].inetref)
            # details has lists of dicts for
            #  'certifications',  'categories', 'countries', 'studios', 'people', 'images'

            names = [n.name for n in details.people]
            self.assertTrue(cast in names)

            tree  = etree.XML(u'<metadata></metadata>')
            tree.append(details.toXML())
            xml_str = etree.tostring ( tree
                                     , pretty_print    = True
                                     , xml_declaration = True
                                     , encoding        = "UTF-8"
                                     , standalone      = "yes"
                                     )
            xml_file  = open("/tmp/details.xml", "wb")
            xml_file.write(xml_str)
            xml_file.close()

            # read xml file and check for cast
            root = etree.parse(r'/tmp/details.xml').getroot()
            cast_found = False
            for name in root.findall('item/people/person'):
                if (name.attrib['name'] == cast):
                    cast_found = True
            self.assertTrue(cast_found)
Пример #10
0
    def get_Meta(item):

        metadata = item.exportMetadata()

        if not item.filename.startswith('Television'):
            grab = VideoGrabber('Movie')
            if item.get('inetref') != '00000000':
                try:
                    match = grab.grabInetref(item.inetref)
                    item.importMetadata(match)
                    item.plot = match.get('description')
                    item.title = match.get('title')
                    copy_Art(match, item)
                    item.update()
                    return

                except Exception:
                    print 'grabber failed for: ' + str(item.get('inetref'))
                    print 'trying by name instead'

            try:
                results = grab.sortedSearch(item.title)
            except Exception, e:
                print 'grabber failed for: ' + str(item.get('inetref'))
                print e
                return

            if len(results) > 0:
                if len(results) > 1:
                    menu = {}
                    list = 1
                    for each in results:
                        menu[list]= each.title + ', year: ' + str(each.get('year')) \
                                                + ', inetref: ' + str(each.get('inetref'))
                        list = list + 1
                    menu[list] = 'Skip to next video\n\n'
                    print '\n'
                    while True:
                        options = menu.keys()
                        options.sort()
                        for entry in options:
                            print entry, menu[entry]
                        try:
                            selection = input("Please Select: ")
                            if selection in range(1, len(results) + 1):
                                listing = results[selection - 1]
                                break
                            elif selection == len(results) + 1:
                                return
                            else:
                                print "Invalid Selection, try again!\n\n"
                        except Exception:
                            print "Invalid Selection, try again!\n\n"
                else:
                    listing = results[0]

                try:
                    match = grab.grabInetref(listing.get('inetref'))
                    item.importMetadata(match)
                    item.plot = match.get('description')
                    item.title = match.get('title')
                    copy_Art(match, item)
                    item.update()
                    print 'Full MetaData Import complete for: ' + item.title + '\n'

                except Exception, e:
                    print 'grabber failed for: ' + str(item.get('inetref'))
                    print e
Пример #11
0
                    item.importMetadata(match)
                    item.plot = match.get('description')
                    item.title = match.get('title')
                    copy_Art(match, item)
                    item.update()
                    print 'Full MetaData Import complete for: ' + item.title + '\n'

                except Exception, e:
                    print 'grabber failed for: ' + str(item.get('inetref'))
                    print e

            elif len(results) == 0:
                print 'No MetaData to import for: ' + item.title + '\n'
        else:
            grab = VideoGrabber('TV')
            results = grab.sortedSearch(item.title, item.subtitle)
            if len(results) > 0:
                if len(results) > 1:
                    menu = {}
                    list = 1
                    for each in results:
                        menu[list]= each.title + ' - ' + each.subtitle, \
                                        + ' year: ' + str(each.get('year')) \
                                        + ', inetref: ' + str(each.get('inetref'))
                        list = list + 1
                    menu[list] = 'Skip to next video\n\n'
                    while True:
                        options = menu.keys()
                        options.sort()
                        for entry in options:
                            print entry, menu[entry]
Пример #12
0
if len(todel) > 0:
    print '--- Deleting Old Videos ---'
    print len(todel), ' found'
    for vid in todel:
        print '      ' + format_name(vid)
#        vid.delete()

# loop through content to add
if len(toadd) > 0:
    print '--- Adding New Videos ---'
    print len(toadd), ' found'
    for vid in toadd:
        print '      ' + format_name(vid),

        if vid.subtitle:
            matches = TVgrab.sortedSearch(vid.title, vid.subtitle)
        else:
            matches = Mgrab.sortedSearch(vid.title)

        if len(matches) == 0:
            print '... no matches, skipped.'
            continue
        elif len(matches) > 1:
            if matches[0].levenshtein > 0:
                print '... multiple matches, skipped.'
                continue

        vid.create()
        vid.importMetadata(matches[0])
        print '... successful.'
Пример #13
0
if len(todel) > 0:
    print '--- Deleting Old Videos ---'
    print len(todel),' found'
    for vid in todel:
        print '      ' + format_name(vid)
#        vid.delete()

# loop through content to add
if len(toadd) > 0:
    print '--- Adding New Videos ---'
    print len(toadd),' found'
    for vid in toadd:
        print '      '+format_name(vid),

        if vid.subtitle:
            matches = TVgrab.sortedSearch(vid.title, vid.subtitle)
        else:
            matches = Mgrab.sortedSearch(vid.title)

        if len(matches) == 0:
            print '... no matches, skipped.'
            continue
        elif len(matches) > 1:
            if matches[0].levenshtein > 0:
                print '... multiple matches, skipped.'
                continue

        vid.create()
        vid.importMetadata(matches[0])
        print '... successful.'