示例#1
0
def fatality(
    randomize=None,
    force_title=None,
    header=None,
    message=None,
    only_refresh=False,
    no_history=False,
    replace_parent=False,
):
    """
    subzero main menu
    """
    title = force_title if force_title is not None else config.full_version
    oc = ObjectContainer(
        title1=title,
        title2=None,
        header=unicode(header) if header else header,
        message=message,
        no_history=no_history,
        replace_parent=replace_parent,
    )

    if not config.plex_api_working:
        oc.add(
            DirectoryObject(
                key=Callback(fatality, randomize=timestamp()),
                title=pad_title("PMS API ERROR"),
                summary=lib_unaccessible_error,
            )
        )
        return oc

    if not only_refresh:
        oc.add(
            DirectoryObject(
                key=Callback(OnDeckMenu),
                title=pad_title("On Deck items"),
                summary="Shows the current on deck items and allows you to individually (force-) refresh their metadata/subtitles.",
            )
        )
        oc.add(
            DirectoryObject(
                key=Callback(RecentlyAddedMenu),
                title="Items with missing subtitles",
                summary="Shows the items honoring the configured 'Item age to be considered recent'-setting (%s)"
                " and allowing you to individually (force-) refresh their metadata/subtitles. "
                % Prefs["scheduler.item_is_recent_age"],
            )
        )
        oc.add(
            DirectoryObject(
                key=Callback(SectionsMenu),
                title="Browse all items",
                summary="Go through your whole library and manage your ignore list. You can also "
                "(force-) refresh the metadata/subtitles of individual items.",
            )
        )

        task_name = "searchAllRecentlyAddedMissing"
        task = scheduler.task(task_name)

        if task.ready_for_display:
            task_state = "Running: %s/%s (%s%%)" % (len(task.items_done), len(task.items_searching), task.percentage)
        else:
            task_state = "Last scheduler run: %s; Next scheduled run: %s; Last runtime: %s" % (
                scheduler.last_run(task_name) or "never",
                scheduler.next_run(task_name) or "never",
                str(task.last_run_time).split(".")[0],
            )

        oc.add(
            DirectoryObject(
                key=Callback(RefreshMissing),
                title="Search for missing subtitles (in recently-added items, max-age: %s)"
                % Prefs["scheduler.item_is_recent_age"],
                summary="Automatically run periodically by the scheduler, if configured. %s" % task_state,
            )
        )

        oc.add(
            DirectoryObject(
                key=Callback(IgnoreListMenu),
                title="Display ignore list (%d)" % len(ignore_list),
                summary="Show the current ignore list (mainly used for the automatic tasks)",
            )
        )

    oc.add(
        DirectoryObject(
            key=Callback(fatality, force_title=" ", randomize=timestamp()),
            title=pad_title("Refresh"),
            summary="Current state: %s; Last state: %s"
            % (
                (Dict["current_refresh_state"] or "Idle") if "current_refresh_state" in Dict else "Idle",
                (Dict["last_refresh_state"] or "None") if "last_refresh_state" in Dict else "None",
            ),
        )
    )

    if not only_refresh:
        oc.add(
            DirectoryObject(
                key=Callback(AdvancedMenu), title=pad_title("Advanced functions"), summary="Use at your own risk"
            )
        )

    return oc
示例#2
0
def fatality(randomize=None,
             force_title=None,
             header=None,
             message=None,
             only_refresh=False,
             no_history=False,
             replace_parent=False):
    """
    subzero main menu
    """
    title = config.full_version  #force_title if force_title is not None else config.full_version
    oc = ObjectContainer(title1=title,
                         title2=title,
                         header=unicode(header) if header else title,
                         message=message,
                         no_history=no_history,
                         replace_parent=replace_parent,
                         no_cache=True)

    # always re-check permissions
    config.refresh_permissions_status()

    # always re-check enabled sections
    config.refresh_enabled_sections()

    if config.lock_menu and not config.pin_correct:
        oc.add(
            DirectoryObject(
                key=Callback(PinMenu, randomize=timestamp()),
                title=pad_title("Enter PIN"),
                summary=
                "The owner has restricted the access to this menu. Please enter the correct pin",
            ))
        return oc

    if not config.permissions_ok and config.missing_permissions:
        for title, path in config.missing_permissions:
            oc.add(
                DirectoryObject(
                    key=Callback(fatality, randomize=timestamp()),
                    title=pad_title("Insufficient permissions"),
                    summary="Insufficient permissions on library %s, folder: %s"
                    % (title, path),
                ))
        return oc

    if not config.enabled_sections:
        oc.add(
            DirectoryObject(
                key=Callback(fatality, randomize=timestamp()),
                title=pad_title("I'm not enabled!"),
                summary=
                "Please enable me for some of your libraries in your server settings; currently I do nothing",
            ))
        return oc

    if not only_refresh:
        if Dict["current_refresh_state"]:
            oc.add(
                DirectoryObject(key=Callback(fatality,
                                             force_title=" ",
                                             randomize=timestamp()),
                                title=pad_title("Working ... refresh here"),
                                summary="Current state: %s; Last state: %s" %
                                ((Dict["current_refresh_state"] or "Idle") if
                                 "current_refresh_state" in Dict else "Idle",
                                 (Dict["last_refresh_state"] or "None")
                                 if "last_refresh_state" in Dict else "None")))

        oc.add(
            DirectoryObject(
                key=Callback(OnDeckMenu),
                title="On Deck items",
                summary=
                "Shows the current on deck items and allows you to individually (force-) refresh their metadata/"
                "subtitles."))
        oc.add(
            DirectoryObject(
                key=Callback(RecentlyAddedMenu),
                title="Recently Added items",
                summary="Shows the recently added items per section."))
        oc.add(
            DirectoryObject(
                key=Callback(RecentMissingSubtitlesMenu,
                             randomize=timestamp()),
                title="Items with missing subtitles",
                summary=
                "Shows the items honoring the configured 'Item age to be considered recent'-setting (%s)"
                " and allowing you to individually (force-) refresh their metadata/subtitles. "
                % Prefs["scheduler.item_is_recent_age"]))
        oc.add(
            DirectoryObject(
                key=Callback(SectionsMenu),
                title="Browse all items",
                summary=
                "Go through your whole library and manage your ignore list. You can also "
                "(force-) refresh the metadata/subtitles of individual items.")
        )

        task_name = "SearchAllRecentlyAddedMissing"
        task = scheduler.task(task_name)

        if task.ready_for_display:
            task_state = "Running: %s/%s (%s%%)" % (len(
                task.items_done), len(task.items_searching), task.percentage)
        else:
            task_state = "Last scheduler run: %s; Next scheduled run: %s; Last runtime: %s" % (
                df(scheduler.last_run(task_name))
                or "never", df(scheduler.next_run(task_name)) or "never",
                str(task.last_run_time).split(".")[0])

        oc.add(
            DirectoryObject(
                key=Callback(RefreshMissing, randomize=timestamp()),
                title=
                "Search for missing subtitles (in recently-added items, max-age: %s)"
                % Prefs["scheduler.item_is_recent_age"],
                summary=
                "Automatically run periodically by the scheduler, if configured. %s"
                % task_state))

        oc.add(
            DirectoryObject(
                key=Callback(IgnoreListMenu),
                title="Display ignore list (%d)" % len(ignore_list),
                summary=
                "Show the current ignore list (mainly used for the automatic tasks)"
            ))

        oc.add(
            DirectoryObject(key=Callback(HistoryMenu),
                            title="History",
                            summary="Show the last %i downloaded subtitles" %
                            int(Prefs["history_size"])))

    oc.add(
        DirectoryObject(key=Callback(fatality,
                                     force_title=" ",
                                     randomize=timestamp()),
                        title=pad_title("Refresh"),
                        summary="Current state: %s; Last state: %s" %
                        ((Dict["current_refresh_state"] or "Idle")
                         if "current_refresh_state" in Dict else "Idle",
                         (Dict["last_refresh_state"] or "None")
                         if "last_refresh_state" in Dict else "None")))

    # add re-lock after pin unlock
    if config.pin:
        oc.add(
            DirectoryObject(key=Callback(ClearPin, randomize=timestamp()),
                            title=pad_title("Re-lock menu(s)"),
                            summary="Enabled the PIN again for menu(s)"))

    if not only_refresh:
        oc.add(
            DirectoryObject(key=Callback(AdvancedMenu),
                            title=pad_title("Advanced functions"),
                            summary="Use at your own risk"))

    return oc
示例#3
0
def fatality(randomize=None, force_title=None, header=None, message=None, only_refresh=False, no_history=False, replace_parent=False):
    """
    subzero main menu
    """
    title = force_title if force_title is not None else config.full_version
    oc = ObjectContainer(title1=title, title2=None, header=unicode(header) if header else header, message=message, no_history=no_history,
                         replace_parent=replace_parent)

    if not config.plex_api_working:
        oc.add(DirectoryObject(
            key=Callback(fatality, randomize=timestamp()),
            title=pad_title("PMS API ERROR"),
            summary=lib_unaccessible_error
        ))
        return oc

    if not only_refresh:
        oc.add(DirectoryObject(
            key=Callback(OnDeckMenu),
            title=pad_title("On Deck items"),
            summary="Shows the current on deck items and allows you to individually (force-) refresh their metadata/subtitles."
        ))
        oc.add(DirectoryObject(
            key=Callback(RecentlyAddedMenu),
            title="Items with missing subtitles",
            summary="Shows the items honoring the configured 'Item age to be considered recent'-setting (%s)"
                    " and allowing you to individually (force-) refresh their metadata/subtitles. " % Prefs["scheduler.item_is_recent_age"]
        ))
        oc.add(DirectoryObject(
            key=Callback(SectionsMenu),
            title="Browse all items",
            summary="Go through your whole library and manage your ignore list. You can also "
                    "(force-) refresh the metadata/subtitles of individual items."
        ))

        task_name = "searchAllRecentlyAddedMissing"
        task = scheduler.task(task_name)

        if task.ready_for_display:
            task_state = "Running: %s/%s (%s%%)" % (len(task.items_done), len(task.items_searching), task.percentage)
        else:
            task_state = "Last scheduler run: %s; Next scheduled run: %s; Last runtime: %s" % (scheduler.last_run(task_name) or "never",
                                                                                               scheduler.next_run(task_name) or "never",
                                                                                               str(task.last_run_time).split(".")[0])

        oc.add(DirectoryObject(
            key=Callback(RefreshMissing),
            title="Search for missing subtitles (in recently-added items, max-age: %s)" % Prefs["scheduler.item_is_recent_age"],
            summary="Automatically run periodically by the scheduler, if configured. %s" % task_state
        ))

        oc.add(DirectoryObject(
            key=Callback(IgnoreListMenu),
            title="Display ignore list (%d)" % len(ignore_list),
            summary="Show the current ignore list (mainly used for the automatic tasks)"
        ))

    oc.add(DirectoryObject(
        key=Callback(fatality, force_title=" ", randomize=timestamp()),
        title=pad_title("Refresh"),
        summary="Current state: %s; Last state: %s" % (
            (Dict["current_refresh_state"] or "Idle") if "current_refresh_state" in Dict else "Idle",
            (Dict["last_refresh_state"] or "None") if "last_refresh_state" in Dict else "None"
        )
    ))

    if not only_refresh:
        oc.add(DirectoryObject(
            key=Callback(AdvancedMenu),
            title=pad_title("Advanced functions"),
            summary="Use at your own risk"
        ))

    return oc
示例#4
0
def fatality(randomize=None, header=None, message=None, only_refresh=False):
    """
    subzero main menu
    """
    oc = ObjectContainer(header=header, message=message, no_cache=True, no_history=True)

    if not config.plex_api_working:
        oc.add(DirectoryObject(
            key=Callback(fatality, randomize=timestamp()),
            title=pad_title("PMS API ERROR"),
            summary=lib_unaccessible_error
        ))
        return oc

    if not only_refresh:
        oc.add(DirectoryObject(
            key=Callback(OnDeckMenu),
            title=pad_title("Subtitles for 'On Deck' items"),
            summary="Shows the current on deck items and allows you to individually (force-) refresh their metadata/subtitles."
        ))
        oc.add(DirectoryObject(
            key=Callback(RecentlyAddedMenu),
            title="Subtitles for 'Recently Added' items (max-age: %s)" % Prefs["scheduler.item_is_recent_age"],
            summary="Shows the recently added items, honoring the configured 'Item age to be considered recent'-setting (%s) and allowing you to individually (force-) refresh their metadata/subtitles." %
                    Prefs["scheduler.item_is_recent_age"]
        ))

        task_name = "searchAllRecentlyAddedMissing"
        task = scheduler.task(task_name)

        if task.ready_for_display:
            task_state = "Running: %s/%s (%s%%)" % (len(task.items_done), len(task.items_searching), task.percentage)
        else:
            task_state = "Last scheduler run: %s; Next scheduled run: %s; Last runtime: %s" % (scheduler.last_run(task_name) or "never",
                                                                                               scheduler.next_run(task_name) or "never",
                                                                                               str(task.last_run_time).split(".")[0])

        oc.add(DirectoryObject(
            key=Callback(RefreshMissing, randomize=timestamp()),
            title="Search for missing subtitles (in recently-added items, max-age: %s)" % Prefs["scheduler.item_is_recent_age"],
            summary="Automatically run periodically by the scheduler, if configured. %s" % task_state
        ))

    oc.add(DirectoryObject(
        key=Callback(fatality, randomize=timestamp()),
        title=pad_title("Refresh"),
        summary="Refreshes the current view"
    ))

    if not only_refresh:
        oc.add(DirectoryObject(
            key=Callback(AdvancedMenu, randomize=timestamp()),
            title=pad_title("Advanced functions"),
            summary="Use at your own risk"
        ))

    return oc
示例#5
0
文件: menu.py 项目: utajum/Sub-Zero
def fatality(randomize=None, header=None, message=None, only_refresh=False):
    """
    subzero main menu
    """
    oc = ObjectContainer(header=header,
                         message=message,
                         no_cache=True,
                         no_history=True)

    if not config.plex_api_working:
        oc.add(
            DirectoryObject(key=Callback(fatality, randomize=timestamp()),
                            title=pad_title("PMS API ERROR"),
                            summary=lib_unaccessible_error))
        return oc

    if not only_refresh:
        oc.add(
            DirectoryObject(
                key=Callback(OnDeckMenu),
                title=pad_title("Subtitles for 'On Deck' items"),
                summary=
                "Shows the current on deck items and allows you to individually (force-) refresh their metadata/subtitles."
            ))
        oc.add(
            DirectoryObject(
                key=Callback(RecentlyAddedMenu),
                title="Subtitles for 'Recently Added' items (max-age: %s)" %
                Prefs["scheduler.item_is_recent_age"],
                summary=
                "Shows the recently added items, honoring the configured 'Item age to be considered recent'-setting (%s) and allowing you to individually (force-) refresh their metadata/subtitles."
                % Prefs["scheduler.item_is_recent_age"]))

        task_name = "searchAllRecentlyAddedMissing"
        task = scheduler.task(task_name)

        if task.ready_for_display:
            task_state = "Running: %s/%s (%s%%)" % (len(
                task.items_done), len(task.items_searching), task.percentage)
        else:
            task_state = "Last scheduler run: %s; Next scheduled run: %s; Last runtime: %s" % (
                scheduler.last_run(task_name)
                or "never", scheduler.next_run(task_name) or "never",
                str(task.last_run_time).split(".")[0])

        oc.add(
            DirectoryObject(
                key=Callback(RefreshMissing, randomize=timestamp()),
                title=
                "Search for missing subtitles (in recently-added items, max-age: %s)"
                % Prefs["scheduler.item_is_recent_age"],
                summary=
                "Automatically run periodically by the scheduler, if configured. %s"
                % task_state))

    oc.add(
        DirectoryObject(key=Callback(fatality, randomize=timestamp()),
                        title=pad_title("Refresh"),
                        summary="Refreshes the current view"))

    if not only_refresh:
        oc.add(
            DirectoryObject(key=Callback(AdvancedMenu, randomize=timestamp()),
                            title=pad_title("Advanced functions"),
                            summary="Use at your own risk"))

    return oc