Example #1
0
def save_subtitles_to_file(subtitles):
    fld_custom = Prefs["subtitles.save.subFolder.Custom"].strip() \
        if Prefs["subtitles.save.subFolder.Custom"] else None

    for video, video_subtitles in subtitles.items():
        if not video_subtitles:
            continue

        fld = None
        if fld_custom or Prefs["subtitles.save.subFolder"] != "current folder":
            # specific subFolder requested, create it if it doesn't exist
            fld_base = os.path.split(video.name)[0]
            if fld_custom:
                if fld_custom.startswith("/"):
                    # absolute folder
                    fld = fld_custom
                else:
                    fld = os.path.join(fld_base, fld_custom)
            else:
                fld = os.path.join(fld_base, Prefs["subtitles.save.subFolder"])
            fld = force_unicode(fld)
            if not os.path.exists(fld):
                os.makedirs(fld)
        subliminal.api.save_subtitles(
            video,
            video_subtitles,
            directory=fld,
            single=cast_bool(Prefs['subtitles.only_one']),
            encode_with=force_utf8 if config.enforce_encoding else None,
            chmod=config.chmod,
            forced_tag=config.forced_only,
            path_decoder=force_unicode)
    return True
Example #2
0
def get_target_folder(file_path):
    fld = None
    fld_custom = Prefs["subtitles.save.subFolder.Custom"].strip() \
        if Prefs["subtitles.save.subFolder.Custom"] else None

    if fld_custom or Prefs["subtitles.save.subFolder"] != "current folder":
        # specific subFolder requested, create it if it doesn't exist
        fld_base = os.path.split(file_path)[0]
        if fld_custom:
            if fld_custom.startswith("/"):
                # absolute folder
                fld = fld_custom
            else:
                fld = os.path.join(fld_base, fld_custom)
        else:
            fld = os.path.join(fld_base, Prefs["subtitles.save.subFolder"])
        fld = force_unicode(fld)
        if not os.path.exists(fld):
            os.makedirs(fld)
    return fld
Example #3
0
def get_target_folder(file_path):
    fld = None
    fld_custom = Prefs["subtitles.save.subFolder.Custom"].strip() \
        if Prefs["subtitles.save.subFolder.Custom"] else None

    if fld_custom or Prefs["subtitles.save.subFolder"] != "current folder":
        # specific subFolder requested, create it if it doesn't exist
        fld_base = os.path.split(file_path)[0]
        if fld_custom:
            if fld_custom.startswith("/"):
                # absolute folder
                fld = fld_custom
            else:
                fld = os.path.join(fld_base, fld_custom)
        else:
            fld = os.path.join(fld_base, Prefs["subtitles.save.subFolder"])
        fld = force_unicode(fld)
        if not os.path.exists(fld):
            os.makedirs(fld)
    return fld