当前位置: 首页>>代码示例>>Python>>正文


Python subliminal.scan_video函数代码示例

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


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


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