<commit_before># coding=utf-8
import logging

import logger
from menu_helpers import add_ignore_options, dig_tree, set_refresh_menu_state, should_display_ignore, enable_channel_wrapper
from subzero.constants import TITLE, ART, ICON, PREFIX, PLUGIN_IDENTIFIER, DEPENDENCY_MODULE_NAMES
from support.auth import refresh_plex_token
from support.background import scheduler
from support.config import config
from support.helpers import pad_title, timestamp
from support.ignore import ignore_list
from support.items import getOnDeckItems, refreshItem, getAllItems
from support.items import getRecentItems, get_items_info
from support.lib import Plex, lib_unaccessible_error
from support.missing_subtitles import getAllMissing
from support.storage import resetStorage, logStorage

# init GUI
ObjectContainer.art = R(ART)
ObjectContainer.no_cache = True

# noinspection PyUnboundLocalVariable
route = enable_channel_wrapper(route)
# noinspection PyUnboundLocalVariable
handler = enable_channel_wrapper(handler)


@handler(PREFIX, TITLE, art=ART, thumb=ICON)
@route(PREFIX)
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)<commit_msg>add top menu item for refreshing the current state<commit_after># coding=utf-8
import logging

import logger
from menu_helpers import add_ignore_options, dig_tree, set_refresh_menu_state, should_display_ignore, enable_channel_wrapper
from subzero.constants import TITLE, ART, ICON, PREFIX, PLUGIN_IDENTIFIER, DEPENDENCY_MODULE_NAMES
from support.auth import refresh_plex_token
from support.background import scheduler
from support.config import config
from support.helpers import pad_title, timestamp
from support.ignore import ignore_list
from support.items import getOnDeckItems, refreshItem, getAllItems
from support.items import getRecentItems, get_items_info
from support.lib import Plex, lib_unaccessible_error
from support.missing_subtitles import getAllMissing
from support.storage import resetStorage, logStorage

# init GUI
ObjectContainer.art = R(ART)
ObjectContainer.no_cache = True

# noinspection PyUnboundLocalVariable
route = enable_channel_wrapper(route)
# noinspection PyUnboundLocalVariable
handler = enable_channel_wrapper(handler)


@handler(PREFIX, TITLE, art=ART, thumb=ICON)
@route(PREFIX)
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:
        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=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)
{'fraction_non_alphanumeric': 0.07828323420671918, 'fraction_numerical': 0.0009644751647645073, 'mean_word_length': 3.492418772563177, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '338913', 'n_tokens_mistral': 1695, 'n_tokens_neox': 1647, 'n_words': 464}