示例#1
0
def save_subtitle(tv_episode, subtitle_id, video_path=None):
    """Save the subtitle with the given id.

    :param tv_episode:
    :type tv_episode: medusa.tv.Episode
    :param subtitle_id:
    :type subtitle_id: text_type
    :param video_path:
    :type video_path: text_type
    :return:
    :rtype: list of str
    """
    subtitle = cache.get(subtitle_key.format(id=subtitle_id).encode('utf-8'))
    if subtitle == NO_VALUE:
        logger.error('Unable to find cached subtitle ID: %s', subtitle_id)
        return

    release_name = tv_episode.release_name
    subtitles_dir = get_subtitles_dir(video_path)
    video = get_video(tv_episode,
                      video_path,
                      subtitles_dir=subtitles_dir,
                      subtitles=False,
                      embedded_subtitles=False,
                      release_name=release_name)

    pool = get_provider_pool()
    if pool.download_subtitle(subtitle):
        return save_subs(tv_episode, video, [subtitle], video_path=video_path)
示例#2
0
def save_subtitle(tv_episode, subtitle_id, video_path=None):
    """Save the subtitle with the given id.

    :param tv_episode:
    :type tv_episode: medusa.tv.Episode
    :param subtitle_id:
    :type subtitle_id: text_type
    :param video_path:
    :type video_path: text_type
    :return:
    :rtype: list of str
    """
    subtitle = cache.get(subtitle_key.format(id=subtitle_id).encode('utf-8'))
    if subtitle == NO_VALUE:
        logger.error('Unable to find cached subtitle ID: %s', subtitle_id)
        return

    release_name = tv_episode.release_name
    subtitles_dir = get_subtitles_dir(video_path)
    video = get_video(tv_episode, video_path, subtitles_dir=subtitles_dir, subtitles=False,
                      embedded_subtitles=False, release_name=release_name)

    pool = get_provider_pool()
    if pool.download_subtitle(subtitle):
        return save_subs(tv_episode, video, [subtitle], video_path=video_path)