Beispiel #1
0
def SubtitleShiftModMenu(unit=None, **kwargs):
    if unit not in POSSIBLE_UNITS_D:
        raise NotImplementedError

    kwargs.pop("randomize")

    oc = SubFolderObjectContainer(title2=kwargs["title"], replace_parent=True)

    oc.add(DirectoryObject(
        key=Callback(SubtitleShiftModUnitMenu, randomize=timestamp(), **kwargs),
        title="< Back to unit selection"
    ))

    rng = []
    if unit == "h":
        rng = range(-10, 11)
    elif unit in ("m", "s"):
        rng = range(-15, 15)
    elif unit == "ms":
        rng = range(-900, 1000, 100)

    for i in rng:
        if i == 0:
            continue

        mod_ident = SubtitleModifications.get_mod_signature("shift_offset", **{unit: i})
        oc.add(DirectoryObject(
            key=Callback(SubtitleSetMods, mods=mod_ident, mode="add", randomize=timestamp(), **kwargs),
            title="%s %s" % (("%s" if i < 0 else "+%s") % i, unit)
        ))

    return oc
Beispiel #2
0
def SubtitleColorModMenu(**kwargs):
    kwargs.pop("randomize")

    color_mod = SubtitleModifications.get_mod_class("color")

    oc = SubFolderObjectContainer(title2=kwargs["title"], replace_parent=True)

    oc.add(
        DirectoryObject(key=Callback(SubtitleModificationsMenu,
                                     randomize=timestamp(),
                                     **kwargs),
                        title="< Back to subtitle modification menu"))

    for color, code in color_mod.colors.iteritems():
        mod_ident = SubtitleModifications.get_mod_signature(
            "color", **{"name": color})
        oc.add(
            DirectoryObject(key=Callback(SubtitleSetMods,
                                         mods=mod_ident,
                                         mode="add",
                                         randomize=timestamp(),
                                         **kwargs),
                            title="%s (%s)" % (color, code)))

    return oc
Beispiel #3
0
def SubtitleShiftModMenu(unit=None, **kwargs):
    if unit not in POSSIBLE_UNITS_D:
        raise NotImplementedError

    kwargs.pop("randomize")

    oc = SubFolderObjectContainer(title2=kwargs["title"], replace_parent=True)

    oc.add(DirectoryObject(
        key=Callback(SubtitleShiftModUnitMenu, randomize=timestamp(), **kwargs),
        title=_("< Back to unit selection")
    ))

    rng = []
    if unit == "h":
        rng = list(reversed(range(-10, 0))) + list(reversed(range(1, 11)))
    elif unit in ("m", "s"):
        rng = list(reversed(range(-15, 0))) + list(reversed(range(1, 16)))
    elif unit == "ms":
        rng = list(reversed(range(-900, 0, 100))) + list(reversed(range(100, 1000, 100)))

    for i in rng:
        if i == 0:
            continue

        mod_ident = SubtitleModifications.get_mod_signature("shift_offset", **{unit: i})
        oc.add(DirectoryObject(
            key=Callback(SubtitleSetMods, mods=mod_ident, mode="add", randomize=timestamp(), **kwargs),
            title="%s %s" % (("%s" if i < 0 else "+%s") % i, unit)
        ))

    return oc
Beispiel #4
0
def SubtitleFPSModMenu(**kwargs):
    rating_key = kwargs["rating_key"]
    part_id = kwargs["part_id"]
    item_type = kwargs["item_type"]

    kwargs.pop("randomize")

    oc = SubFolderObjectContainer(title2=kwargs["title"], replace_parent=True)

    oc.add(
        DirectoryObject(key=Callback(SubtitleModificationsMenu,
                                     randomize=timestamp(),
                                     **kwargs),
                        title="< Back to subtitle modification menu"))

    metadata = get_plex_metadata(rating_key, part_id, item_type)
    scanned_parts = scan_videos(
        [metadata],
        kind="series" if item_type == "episode" else "movie",
        ignore_all=True)
    video, plex_part = scanned_parts.items()[0]

    target_fps = plex_part.fps

    for fps in [
            "23.976", "24.000", "25.000", "29.970", "30.000", "50.000",
            "59.940", "60.000"
    ]:
        if float(fps) == float(target_fps):
            continue

        if float(fps) > float(target_fps):
            indicator = "subs constantly getting faster"
        else:
            indicator = "subs constantly getting slower"

        mod_ident = SubtitleModifications.get_mod_signature(
            "change_FPS", **{
                "from": fps,
                "to": target_fps
            })
        oc.add(
            DirectoryObject(key=Callback(SubtitleSetMods,
                                         mods=mod_ident,
                                         mode="add",
                                         randomize=timestamp(),
                                         **kwargs),
                            title="%s fps -> %s fps (%s)" %
                            (fps, target_fps, indicator)))

    return oc
Beispiel #5
0
def SubtitleColorModMenu(**kwargs):
    kwargs.pop("randomize")

    color_mod = SubtitleModifications.get_mod_class("color")

    oc = SubFolderObjectContainer(title2=kwargs["title"], replace_parent=True)

    oc.add(DirectoryObject(
        key=Callback(SubtitleModificationsMenu, randomize=timestamp(), **kwargs),
        title=_("< Back to subtitle modification menu")
    ))

    for color, code in color_mod.colors.iteritems():
        mod_ident = SubtitleModifications.get_mod_signature("color", **{"name": color})
        oc.add(DirectoryObject(
            key=Callback(SubtitleSetMods, mods=mod_ident, mode="add", randomize=timestamp(), **kwargs),
            title="%s (%s)" % (color, code)
        ))

    return oc
Beispiel #6
0
def SubtitleFPSModMenu(**kwargs):
    rating_key = kwargs["rating_key"]
    part_id = kwargs["part_id"]
    item_type = kwargs["item_type"]

    kwargs.pop("randomize")

    oc = SubFolderObjectContainer(title2=kwargs["title"], replace_parent=True)

    oc.add(DirectoryObject(
        key=Callback(SubtitleModificationsMenu, randomize=timestamp(), **kwargs),
        title=_("< Back to subtitle modification menu")
    ))

    metadata = get_plex_metadata(rating_key, part_id, item_type)
    scanned_parts = scan_videos([metadata], ignore_all=True, skip_hashing=True)
    video, plex_part = scanned_parts.items()[0]

    target_fps = plex_part.fps

    for fps in ["23.980", "23.976", "24.000", "25.000", "29.970", "30.000", "50.000", "59.940", "60.000"]:
        if float(fps) == float(target_fps):
            continue

        if float(fps) > float(target_fps):
            indicator = _("subs constantly getting faster")
        else:
            indicator = _("subs constantly getting slower")

        mod_ident = SubtitleModifications.get_mod_signature("change_FPS", **{"from": fps, "to": target_fps})
        oc.add(DirectoryObject(
            key=Callback(SubtitleSetMods, mods=mod_ident, mode="add", randomize=timestamp(), **kwargs),
            title=_("%(from_fps)s fps -> %(to_fps)s fps (%(slower_or_faster_indicator)s)",
                    from_fps=fps,
                    to_fps=target_fps,
                    slower_or_faster_indicator=indicator)
        ))

    return oc