• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python subliminal.scan_video函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中subliminal.scan_video函数的典型用法代码示例。如果您正苦于以下问题:Python scan_video函数的具体用法?Python scan_video怎么用?Python scan_video使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了scan_video函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get_video

def get_video(video_path, subtitles_path=None):
    if not subtitles_path:
        subtitles_path = get_subtitles_path(video_path)

    try:
        # Encode paths to UTF-8 to ensure subliminal support.
        video_path = video_path.encode('utf-8')
        subtitles_path = subtitles_path.encode('utf-8')
    except UnicodeEncodeError:
        # Fallback to system encoding. This should never happen.
        video_path = video_path.encode(sickbeard.SYS_ENCODING)
        subtitles_path = subtitles_path.encode(sickbeard.SYS_ENCODING)

    try:
        if not sickbeard.EMBEDDED_SUBTITLES_ALL and video_path.endswith('.mkv'):
            video = subliminal.scan_video(video_path, subtitles=True, embedded_subtitles=True,
                                          subtitles_dir=subtitles_path)
        else:
            video = subliminal.scan_video(video_path, subtitles=True, embedded_subtitles=False,
                                          subtitles_dir=subtitles_path)
    except Exception as error:
        logger.log(u'Exception: {}'.format(error), logger.DEBUG)
        return None

    return video
开发者ID:pedro2d10,项目名称:SickRage-FR,代码行数:25,代码来源:subtitles.py


示例2: get_video

def get_video(video_path, subtitles_path=None):
    if not subtitles_path:
        subtitles_path = get_subtitles_path(video_path).encode(sickbeard.SYS_ENCODING)

    try:
        if not sickbeard.EMBEDDED_SUBTITLES_ALL and video_path.endswith('.mkv'):
            video = subliminal.scan_video(video_path, subtitles=True, embedded_subtitles=True,
                                          subtitles_dir=subtitles_path)
        else:
            video = subliminal.scan_video(video_path, subtitles=True, embedded_subtitles=False,
                                          subtitles_dir=subtitles_path)
    except Exception:
        return None

    return video
开发者ID:madtrix74,项目名称:SickRage,代码行数:15,代码来源:subtitles.py


示例3: import_subs

def import_subs(filename):
    if not core.GETSUBS:
        return
    try:
        subliminal.cache_region.configure('dogpile.cache.memory')
    except:
        pass   

    languages = set()
    for item in core.SLANGUAGES:
        try:
            languages.add(Language(item))
        except:
            pass
    if not languages:
        return

    logger.debug("Attempting to download subtitles for %s" %(filename), 'SUBTITLES')
    try:
        # subliminal.logger = subliminal.logging.getLogger('subliminal')
        # subliminal.logger.setLevel(subliminal.logging.DEBUG)
        # ch = subliminal.logging.StreamHandler()
        # ch.setLevel(subliminal.logging.DEBUG)
        # formatter = subliminal.logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
        # ch.setFormatter(formatter)
        # subliminal.logger.addHandler(ch)

        video = subliminal.scan_video(filename, subtitles=True, embedded_subtitles=True)
        subtitles = subliminal.download_best_subtitles([video], languages, hearing_impaired=False)
        saved_subtitles = subliminal.save_subtitles(video, subtitles[video])
        logger.debug("Saved subtitles:%s" %(saved_subtitles), 'SUBTITLES')
    except Exception as e:
        logger.error("Failed to download subtitles for %s due to: %s" %(filename, e), 'SUBTITLES') 
开发者ID:diglam,项目名称:nzbToMedia,代码行数:33,代码来源:nzbToMediaUtil.py


示例4: subtitlesLanguages

def subtitlesLanguages(video_path):
    """Return a list detected subtitles for the given video file"""
    resultList = []

    # Serch for embedded subtitles
    embedded_languages = subliminal.scan_video(video_path, subtitles=False, embedded_subtitles=not sickbeard.EMBEDDED_SUBTITLES_ALL)

    # Search subtitles in the absolute path
    if sickbeard.SUBTITLES_DIR and ek(os.path.exists, sickbeard.SUBTITLES_DIR):
        video_path = ek(os.path.join, sickbeard.SUBTITLES_DIR, ek(os.path.basename, video_path))
    # Search subtitles in the relative path
    elif sickbeard.SUBTITLES_DIR:
        video_path = ek(os.path.join, ek(os.path.dirname, video_path), sickbeard.SUBTITLES_DIR, ek(os.path.basename, video_path))

    languages = subliminal.video.scan_subtitle_languages(video_path)

    for language in languages.union(embedded_languages.subtitle_languages):
        if hasattr(language, 'opensubtitles') and language.opensubtitles:
            resultList.append(language.opensubtitles)
        elif hasattr(language, 'alpha3') and language.alpha3:
            resultList.append(language.alpha3)
        elif hasattr(language, 'alpha2') and language.alpha2:
            resultList.append(language.alpha2)

    defaultLang = wantedLanguages()

    if ('pob' in defaultLang or 'pb' in defaultLang) and ('pt' not in defaultLang and 'por' not in defaultLang):
            resultList = [x if not x in ['por', 'pt'] else u'pob' for x in resultList]

    return sorted(resultList)
开发者ID:fbossy,项目名称:SickRage,代码行数:30,代码来源:subtitles.py


示例5: get_subtitles

    def get_subtitles(self, entry):
        if (
            entry.get('subtitles', eval_lazy=False)
            or not ('location' in entry)
            or ('$RECYCLE.BIN' in entry['location'])
            or not os.path.exists(entry['location'])
        ):
            return
        from subliminal import scan_video
        from subliminal.core import search_external_subtitles, refine

        try:
            video = scan_video(entry['location'])
            # grab external and internal subtitles
            subtitles = video.subtitle_languages
            refiner = ('metadata',)
            refine(video, episode_refiners=refiner, movie_refiners=refiner)
            subtitles |= set(search_external_subtitles(entry['location']).values())
            if subtitles:
                # convert to human-readable strings
                subtitles = [str(l) for l in subtitles]
                entry['subtitles'] = subtitles
                log.debug('Found subtitles %s for %s', '/'.join(subtitles), entry['title'])
        except Exception as e:
            log.error('Error checking local subtitles for %s: %s', entry['title'], e)
开发者ID:Flexget,项目名称:Flexget,代码行数:25,代码来源:subtitles_check.py


示例6: get_video

def get_video(video_path, subtitles_path=None, subtitles=True, embedded_subtitles=None, episode=None):
    if not subtitles_path:
        subtitles_path = get_subtitles_path(video_path)

    try:
        video = subliminal.scan_video(video_path)
    except Exception as error:
        sickrage.app.log.debug('Exception: {}'.format(error))
    else:
        if video.size > 10485760:
            video.hashes['itasa'] = hash_itasa(video_path)

        # external subtitles
        if subtitles:
            video.subtitle_languages |= \
                set(subliminal.core.search_external_subtitles(video_path, directory=subtitles_path).values())

        if embedded_subtitles is None:
            embedded_subtitles = bool(
                not sickrage.app.config.embedded_subtitles_all and video_path.endswith('.mkv'))

        subliminal.refine(video, episode_refiners=episode_refiners, embedded_subtitles=embedded_subtitles,
                          release_name=episode.name, tv_episode=episode)

        video.alternative_series = list(get_scene_exceptions(episode.show.indexerid))

        # remove format metadata
        video.format = ""

        return video
开发者ID:SiCKRAGETV,项目名称:SiCKRAGE,代码行数:30,代码来源:__init__.py


示例7: getSubtitle

 def getSubtitle(self):
     if not "sub" in self.config or not os.path.isfile(self.config['sub']):
         self.config['sub'] = {}
         name = os.path.splitext(self.config['file']['name'])[0]
         file = os.path.join(self.config['file']['path'], name + ".srt")
         if os.path.isfile(file):
             print "found file. copying to temp"
             shutil.copy(file, self.config['temp']['path'])
             self.config['sub']['file'] = os.path.join(self.config['temp']['path'], name + ".srt")
             self.config['sub']['lang'] = self.config['language']['subtitle'][0]
         else:
             print "trying to download subtitle"
             file = self.config['file']['name']
             lang = self.config['language']['subtitle']
             languages = set();
             for l in lang:
                 languages.add(Language(l))
             print languages
             videoPath = os.path.join(self.config['temp']['path'], file)
             video = set([subliminal.scan_video(videoPath)])
             print video
             cache = self.config['temp']['path'] if "temp" in self.config else self.config['file']['path']
             sub = subliminal.download_best_subtitles(video, languages)
             print sub.items()
             if not sub.items():
                 self.config['sub'] = False
             for item in sub.items():
                 subLang = item[1][0].language.alpha3
                 self.config['sub'][subLang] = {}
                 self.config['sub'][subLang]['lang'] = subLang
                 self.config['sub'][subLang]['file'] = subliminal.subtitle.get_subtitle_path(videoPath, Language(subLang))
             
             print self.config['sub']
     return self.config['sub']
开发者ID:olyckne,项目名称:tvshow_parser,代码行数:34,代码来源:subtitle.py


示例8: match_episodes

def match_episodes(episodes, show_list):
    """Match episodes using subliminal."""
    episode_matching = {'matched': [],
                        'notmatched': []}
    for episode_path in episodes:
        try:
            episode = subliminal.scan_video(episode_path)
        except ValueError:
            tv_data = re_tv.match(os.path.basename(episode_path))
            episode = None
            if tv_data:
                episode = subliminal.video.Episode(episode_path,
                                                   tv_data.group(1).replace(".", " "),
                                                   tv_data.group(2),
                                                   tv_data.group(3))
        if not episode:
            episode_matching['notmatched'].append((episode_path, 'id'))
            continue
        series = None
        for show in show_list:
            if isinstance(episode, subliminal.Movie):
                # It's a show detected as a movie
                episod = EpisodePlaceholder()
                episod.series = episode.title
                episod.season = 1
                episod.name = episode.name
                episode = episod
            if show.lower() == SHOW_CONVERSIONS.get(episode.series, episode.series.lower()):
                series = show
                episode.series = show
        if not series:
            episode_matching['notmatched'].append((episode_path, 'showlist'))
            continue
        episode_matching['matched'].append(episode)
    return episode_matching['matched'], episode_matching['notmatched']
开发者ID:apuignav,项目名称:raspi-config,代码行数:35,代码来源:move_episodes.py


示例9: download

 def download(self, model):
     """Download subtitles using subliminal"""
     video = subliminal.scan_video(model.series_path)
     subtitles = subliminal.download_best_subtitles(
         {video}, {Language('eng')},
     )
     save_subtitles(subtitles, True, config.download_path)
开发者ID:diannt,项目名称:series_list,代码行数:7,代码来源:subliminal_loader.py


示例10: test_scan_video_subtitles_languages

 def test_scan_video_subtitles_languages(self):
     video = EPISODES[0]
     open(os.path.join(TEST_DIR, os.path.splitext(os.path.split(video.name)[1])[0]) + '.en.srt', 'w').close()
     open(os.path.join(TEST_DIR, os.path.splitext(os.path.split(video.name)[1])[0]) + '.fr.srt', 'w').close()
     open(os.path.join(TEST_DIR, os.path.splitext(os.path.split(video.name)[1])[0]) + '.srt', 'w').close()
     scanned_video = scan_video(os.path.join(TEST_DIR, os.path.split(video.name)[1]))
     self.assertEqual(scanned_video.subtitle_languages, {Language('eng'), Language('fra'), Language('und')})
开发者ID:Amelandbor,项目名称:nzbToMedia,代码行数:7,代码来源:test_subliminal.py


示例11: _scan_wanted_item_for_video

def _scan_wanted_item_for_video(wanted_item, is_manual=False):
    video_path = wanted_item.videopath
    log.info('Scanning video')

    try:
        # Scan the video
        video = subliminal.scan_video(video_path)

        # Use our manual refiner only for manual search if enabled
        # Always keep this first because you may completely override the video with this!
        if is_manual and autosubliminal.MANUALREFINEVIDEO:
            refiners = ('manual',)  # don't remove the , -> needs to be a tuple
            subliminal.refine(video, episode_refiners=refiners, movie_refiners=refiners, wanted_item=wanted_item)

        # Use build-in refiners
        if autosubliminal.REFINEVIDEO:
            subliminal.refine(video)

        # Use our namemapping refiner (always enabled to enable our name mappings)
        # This should always be at the end since we want to enrich the result after the build-in refiners
        refiners = ('namemapping',)  # don't remove the , -> needs to be a tuple
        subliminal.refine(video, episode_refiners=refiners, movie_refiners=refiners)
    except Exception:
        log.exception('Error while scanning video, skipping %s', video_path)
        return

    # Add video to wanted item
    wanted_item.video = video

    return video
开发者ID:h3llrais3r,项目名称:Auto-Subliminal,代码行数:30,代码来源:subchecker.py


示例12: get_video

def get_video(video_path, subtitles_path=None, subtitles=True, embedded_subtitles=None):
    if not subtitles_path:
        subtitles_path = get_subtitles_path(video_path)

    try:
        # Encode paths to UTF-8 to ensure subliminal support.
        video_path = video_path.encode('utf-8')
        subtitles_path = subtitles_path.encode('utf-8')
    except UnicodeEncodeError:
        # Fallback to system encoding. This should never happen.
        video_path = video_path.encode(sickbeard.SYS_ENCODING)
        subtitles_path = subtitles_path.encode(sickbeard.SYS_ENCODING)

    try:
        video = subliminal.scan_video(video_path)

        # external subtitles
        if subtitles:
            video.subtitle_languages |= \
                set(subliminal.core.search_external_subtitles(video_path, directory=subtitles_path).values())

        if embedded_subtitles is None:
            embedded_subtitles = bool(not sickbeard.EMBEDDED_SUBTITLES_ALL and video_path.endswith('.mkv'))

        subliminal.refine(video, embedded_subtitles=embedded_subtitles)
    except Exception as error:
        logger.log(u'Exception: {0}'.format(error), logger.DEBUG)
        return None

    return video
开发者ID:guilhermebruzzi,项目名称:SickRage,代码行数:30,代码来源:subtitles.py


示例13: downloadSubtitles

def downloadSubtitles(subtitles_info):
    existing_subtitles = subtitles_info[b'subtitles']
    # First of all, check if we need subtitles
    languages = getNeededLanguages(existing_subtitles)
    if not languages:
        sickrage.LOGGER.debug('%s: No missing subtitles for S%02dE%02d' % (
            subtitles_info[b'show.indexerid'], subtitles_info[b'season'], subtitles_info[b'episode']))
        return existing_subtitles, None

    subtitles_path = getSubtitlesPath(subtitles_info[b'location']).encode(sickrage.SYS_ENCODING)
    video_path = subtitles_info[b'location'].encode(sickrage.SYS_ENCODING)
    providers = getEnabledServiceList()

    try:
        video = subliminal.scan_video(video_path, subtitles=False, embedded_subtitles=False)
    except Exception:
        sickrage.LOGGER.debug('%s: Exception caught in subliminal.scan_video for S%02dE%02d' %
                      (subtitles_info[b'show.indexerid'], subtitles_info[b'season'], subtitles_info[b'episode']))
        return existing_subtitles, None

    provider_configs = {'addic7ed': {'username': sickrage.ADDIC7ED_USER, 'password': sickrage.ADDIC7ED_PASS},
                        'legendastv': {'username': sickrage.LEGENDASTV_USER, 'password': sickrage.LEGENDASTV_PASS},
                        'opensubtitles': {'username': sickrage.OPENSUBTITLES_USER,
                                          'password': sickrage.OPENSUBTITLES_PASS}}

    pool = subliminal.api.ProviderPool(providers=providers, provider_configs=provider_configs)

    try:
        subtitles_list = pool.list_subtitles(video, languages)
        if not subtitles_list:
            sickrage.LOGGER.debug('%s: No subtitles found for S%02dE%02d on any provider' % (
                subtitles_info[b'show.indexerid'], subtitles_info[b'season'], subtitles_info[b'episode']))
            return existing_subtitles, None

        found_subtitles = pool.download_best_subtitles(subtitles_list, video, languages=languages,
                                                       hearing_impaired=sickrage.SUBTITLES_HEARING_IMPAIRED,
                                                       only_one=not sickrage.SUBTITLES_MULTI)

        save_subtitles(video, found_subtitles, directory=subtitles_path, single=not sickrage.SUBTITLES_MULTI)

        if not sickrage.EMBEDDED_SUBTITLES_ALL and sickrage.SUBTITLES_EXTRA_SCRIPTS and video_path.endswith(
                ('.mkv', '.mp4')):
            run_subs_extra_scripts(subtitles_info, found_subtitles, video, single=not sickrage.SUBTITLES_MULTI)

        current_subtitles = subtitlesLanguages(video_path)[0]
        new_subtitles = frozenset(current_subtitles).difference(existing_subtitles)

    except Exception:
        sickrage.LOGGER.info("Error occurred when downloading subtitles for: %s" % video_path)
        sickrage.LOGGER.error(traceback.format_exc())
        return existing_subtitles, None

    if sickrage.SUBTITLES_HISTORY:
        for subtitle in found_subtitles:
            sickrage.LOGGER.debug('history.logSubtitle %s, %s' % (subtitle.provider_name, subtitle.language.opensubtitles))
            History.logSubtitle(subtitles_info[b'show.indexerid'], subtitles_info[b'season'],
                                subtitles_info[b'episode'],
                                subtitles_info[b'status'], subtitle)

    return current_subtitles, new_subtitles
开发者ID:TATUMTOT,项目名称:SickRage,代码行数:60,代码来源:subtitle_searcher.py


示例14: downloadSubtitles

def downloadSubtitles(subtitles_info):
    existing_subtitles = subtitles_info['subtitles']
    # First of all, check if we need subtitles
    languages = getNeededLanguages(existing_subtitles)
    if not languages:
        logger.log(u'%s: No missing subtitles for S%02dE%02d' % (subtitles_info['show.indexerid'], subtitles_info['season'], subtitles_info['episode']), logger.DEBUG)
        return (existing_subtitles, None)

    subtitles_path = getSubtitlesPath(subtitles_info['location']).encode(sickbeard.SYS_ENCODING)
    video_path = subtitles_info['location'].encode(sickbeard.SYS_ENCODING)
    providers = getEnabledServiceList()

    try:
        video = subliminal.scan_video(video_path, subtitles=False, embedded_subtitles=False)
    except Exception:
        logger.log(u'%s: Exception caught in subliminal.scan_video for S%02dE%02d' %
        (subtitles_info['show.indexerid'], subtitles_info['season'], subtitles_info['episode']), logger.DEBUG)
        return (existing_subtitles, None)

    try:
        # TODO: Add gui option for hearing_impaired parameter ?
        found_subtitles = subliminal.download_best_subtitles([video], languages=languages, hearing_impaired=False, only_one=not sickbeard.SUBTITLES_MULTI, providers=providers)
        if not found_subtitles:
            logger.log(u'%s: No subtitles found for S%02dE%02d on any provider' % (subtitles_info['show.indexerid'], subtitles_info['season'], subtitles_info['episode']), logger.DEBUG)
            return (existing_subtitles, None)

        for index, subtitle in enumerate(found_subtitles[video]):
            encoding = subliminal.subtitle.Subtitle.guess_encoding(subtitle)
            found_subtitles[video][index].encoding = encoding

        subliminal.save_subtitles(video, found_subtitles[video], directory=subtitles_path, single=not sickbeard.SUBTITLES_MULTI)

        for video, subtitles in found_subtitles.iteritems():
            for subtitle in subtitles:
                new_video_path = subtitles_path + "/" + video.name.rsplit("/", 1)[-1]
                new_subtitles_path = subliminal.subtitle.get_subtitle_path(new_video_path, subtitle.language if sickbeard.SUBTITLES_MULTI else None)
                sickbeard.helpers.chmodAsParent(new_subtitles_path)
                sickbeard.helpers.fixSetGroupID(new_subtitles_path)

        if not sickbeard.EMBEDDED_SUBTITLES_ALL and sickbeard.SUBTITLES_EXTRA_SCRIPTS and video_path.endswith(('.mkv','.mp4')):
            run_subs_extra_scripts(subtitles_info, found_subtitles)

        current_subtitles = subtitlesLanguages(video_path)[0]
        new_subtitles = frozenset(current_subtitles).difference(existing_subtitles)

    except Exception as e:
                logger.log("Error occurred when downloading subtitles for: %s" % video_path)
                logger.log(traceback.format_exc(), logger.ERROR)
                return (existing_subtitles, None)

    if sickbeard.SUBTITLES_HISTORY:
        for video, subtitles in found_subtitles.iteritems():
            for subtitle in subtitles:
                logger.log(u'history.logSubtitle %s, %s' % (subtitle.provider_name, subtitle.language.opensubtitles), logger.DEBUG)
                history.logSubtitle(subtitles_info['show.indexerid'], subtitles_info['season'], subtitles_info['episode'], subtitles_info['status'], subtitle)

    return (current_subtitles, new_subtitles)
开发者ID:mexicanamerican,项目名称:SickRage,代码行数:57,代码来源:subtitles.py


示例15: download_sub

 def download_sub(self, language):
     l = Language(language)
     v = scan_video(self.path)
     sub_path = get_subtitle_path(v.name, l)
     if not os.path.isfile(sub_path):
         sub = download_best_subtitles((v,), {l})
         # TODO Save in tmp folder if regular is not available
         save_subtitles(sub)
     return sub_path
开发者ID:gileri,项目名称:cli_theatre,代码行数:9,代码来源:library.py


示例16: moveVideosAndSubtitles

def moveVideosAndSubtitles(sourceDirPath_, destDirPath_) :
	"""Move videos and subtitles (if exist)

	:param String sourceDirPath_
	:param String destDirPath_
	"""

	LOGGER.info('*** START MOVING VIDEOS AND SUBTITLES ***')
	
	if (os.path.isdir(sourceDirPath_)) :
		for dir, dirs, files in os.walk(sourceDirPath_) :
			localDir = dir[len(sourceDirPath_):]
			for fileName in files :
				fileExtension = os.path.splitext(fileName)[1]
				filePath = os.path.join(dir, fileName)

				if (fileExtension in VIDEO_EXTENSIONS) :
					# Scan video
					LOGGER.debug('Scanning video \'%s\'', filePath)
					video = subliminal.scan_video(filePath, False, True)
						
					# TEMP: if no embedded subtitles have been found, try to find associated sub files
					# This should be done in 'subliminal.scan_video', but... NO.
					# TODO: fork subliminal to fix the method 'scan_subtitle_languages'
					subFileLanguages = subtitles.scanSubtitleLanguages(filePath, SUB_EXTENSIONS)
					
					# If subs found, then move video
					hasSubFiles = babelfish.Language('eng') in subFileLanguages
					hasEmbeddedSub = babelfish.Language('eng') in video.subtitle_languages or babelfish.Language('und') in video.subtitle_languages
					if (hasEmbeddedSub or hasSubFiles) :
						fileTools.transferFile(filePath, sourceDirPath_, destDirPath_)
						
						# Embedded subtitles?
						if (hasEmbeddedSub) :
							LOGGER.debug('Embedded subtitles found for %s', video.name)
					
						# If subtitles files have been found, then move
						if (hasSubFiles) :
							LOGGER.debug('Subtitles files found for %s', video.name)
							# Move subtitles
							for otherFileName in files :
								otherFileExtension = os.path.splitext(otherFileName)[1]
								if (not otherFileName == fileName and otherFileExtension in SUB_EXTENSIONS) :
									# Test if the subtitles have the same name as the movie
									otherFileRoot = os.path.splitext(otherFileName)[0]
									fileRoot = os.path.splitext(fileName)[0]
									if (otherFileRoot[:len(fileRoot)] == fileRoot) :
										# Move subtitles
										otherFilePath = os.path.join(dir, otherFileName)
										fileTools.transferFile(otherFilePath, sourceDirPath_, destDirPath_)
					else :
						LOGGER.warning('No subtitles found, skipping video. (%s)', video.name)
				
	else :
		LOGGER.warning('\'%s\' does not refer to an existing path.', sourceDirPath_)
开发者ID:s0ubap,项目名称:medialib,代码行数:55,代码来源:medialib.py


示例17: get_best_match

	def get_best_match(self, widget):
		# Open a thread to find a subtitle through get_best_subtitle
		try:
			self.video = scan_video( self.movie_entry.get_text() )
		except ValueError:
			self.status_bar.pop(self.context_id)
			self.status_bar.push(self.context_id, "Error. Did you choose a video file?")
			self.progress_bar.set_fraction(0)
			return False	
		x = Thread(target=self.get_best_subtitle)
		x.start()
开发者ID:DarkNand,项目名称:subliminal-minimal-gui,代码行数:11,代码来源:subliminal-minimal-gui.py


示例18: get_embedded_subtitles

def get_embedded_subtitles(video_path):
    """Return all embedded subtitles for the given video path.

    :param video_path: video filename to be checked
    :type video_path: str
    :return:
    :rtype: set of Language
    """
    subliminal_video = scan_video(video_path)
    refine(subliminal_video, episode_refiners=('metadata',))
    return subliminal_video.subtitle_languages
开发者ID:Thraxis,项目名称:pymedusa,代码行数:11,代码来源:processTV.py


示例19: get_video

def get_video(tv_episode, video_path, subtitles_dir=None, subtitles=True, embedded_subtitles=None, release_name=None):
    """Return the subliminal video for the given path.

    The video_path is used as a key to cache the video to avoid
    scanning and parsing the video metadata all the time

    :param tv_episode:
    :type tv_episode: sickbeard.tv.TVEpisode
    :param video_path: the video path
    :type video_path: str
    :param subtitles_dir: the subtitles directory
    :type subtitles_dir: str or None
    :param subtitles: True if existing external subtitles should be taken into account
    :type subtitles: bool or None
    :param embedded_subtitles: True if embedded subtitles should be taken into account
    :type embedded_subtitles: bool or None
    :param release_name: the release name
    :type release_name: str or None
    :return: video
    :rtype: subliminal.video.Video
    """
    key = video_key.format(video_path=video_path)
    payload = {'subtitles_dir': subtitles_dir, 'subtitles': subtitles, 'embedded_subtitles': embedded_subtitles,
               'release_name': release_name}
    cached_payload = region.get(key, expiration_time=VIDEO_EXPIRATION_TIME)
    if cached_payload != NO_VALUE and {k: v for k, v in iteritems(cached_payload) if k != 'video'} == payload:
        logger.debug(u'Found cached video information under key %s', key)
        return cached_payload['video']

    try:
        video_path = _encode(video_path)
        subtitles_dir = _encode(subtitles_dir or get_subtitles_dir(video_path))

        logger.debug(u'Scanning video %s...', video_path)
        video = scan_video(video_path)

        # external subtitles
        if subtitles:
            video.subtitle_languages |= set(search_external_subtitles(video_path, directory=subtitles_dir).values())

        if embedded_subtitles is None:
            embedded_subtitles = bool(not sickbeard.EMBEDDED_SUBTITLES_ALL and video_path.endswith('.mkv'))

        refine(video, episode_refiners=episode_refiners, embedded_subtitles=embedded_subtitles,
               release_name=release_name, tv_episode=tv_episode)

        payload['video'] = video
        region.set(key, payload)
        logger.debug(u'Video information cached under key %s', key)

        return video
    except Exception as error:
        logger.info(u'Exception: %s', error)
开发者ID:Thraxis,项目名称:pymedusa,代码行数:53,代码来源:subtitles.py


示例20: get_video

def get_video(video_path, subtitles_path=None):
    if not subtitles_path:
        try:
            subtitles_path = get_subtitles_path(video_path).encode(sickbeard.SYS_ENCODING)
        except UnicodeEncodeError as error:
            logger.log(u'An error occurred while encoding \'{}\' with your current locale. '
                       'Rename the file or try a different locale. Error: {}'.format
                       (video_path, ex(error)), logger.WARNING)
            return None

    try:
        if not sickbeard.EMBEDDED_SUBTITLES_ALL and video_path.endswith('.mkv'):
            video = subliminal.scan_video(video_path, subtitles=True, embedded_subtitles=True,
                                          subtitles_dir=subtitles_path)
        else:
            video = subliminal.scan_video(video_path, subtitles=True, embedded_subtitles=False,
                                          subtitles_dir=subtitles_path)
    except Exception:
        return None

    return video
开发者ID:Hydrog3n,项目名称:SickRage,代码行数:21,代码来源:subtitles.py



注:本文中的subliminal.scan_video函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python videos.Video类代码示例发布时间:2022-05-27
下一篇:
Python subliminal.save_subtitles函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap