def PinMenu(pin="", randomize=None, success_go_to="channel"): oc = ObjectContainer(title2="Enter PIN number %s" % (len(pin) + 1), no_cache=True, no_history=True, skip_pin_lock=True) if pin == config.pin: Dict["pin_correct_time"] = datetime.datetime.now() config.locked = False if success_go_to == "channel": return fatality(force_title="PIN correct", header="PIN correct", no_history=True) elif success_go_to == "advanced": return AdvancedMenu(randomize=timestamp()) for i in range(10): oc.add( DirectoryObject( key=Callback(PinMenu, randomize=timestamp(), pin=pin + str(i), success_go_to=success_go_to), title=pad_title(str(i)), )) oc.add( DirectoryObject( key=Callback(PinMenu, randomize=timestamp(), success_go_to=success_go_to), title=pad_title("Reset"), )) return oc
def PinMenu(pin="", randomize=None, success_go_to="channel"): oc = ObjectContainer( title2=_("Enter PIN number ") + str(len(pin) + 1), no_cache=True, no_history=True, skip_pin_lock=True) if pin == config.pin: Dict["pin_correct_time"] = datetime.datetime.now() config.locked = False if success_go_to == "channel": return fatality( force_title=_("PIN correct"), header=_("PIN correct"), no_history=True) elif success_go_to == "advanced": return AdvancedMenu(randomize=timestamp()) for i in range(10): oc.add(DirectoryObject( key=Callback( PinMenu, randomize=timestamp(), pin=pin + str(i), success_go_to=success_go_to), title=pad_title(str(i)), )) oc.add(DirectoryObject( key=Callback( PinMenu, randomize=timestamp(), success_go_to=success_go_to), title=pad_title(_("Reset")), )) return oc
def fatality(randomize=None, force_title=None, header=None, message=None, only_refresh=False, no_history=False, replace_parent=False): """ subzero main menu """ from interface.advanced import PinMenu, ClearPin, AdvancedMenu from interface.menu import RefreshMissing, IgnoreListMenu, HistoryMenu 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.", thumb=R("icon-ondeck.jpg"))) if "last_played_items" in Dict and Dict["last_played_items"]: oc.add( DirectoryObject( key=Callback(RecentlyPlayedMenu), title=pad_title("Recently played items"), summary= "Shows the %i recently played items and allows you to individually (force-) refresh their " "metadata/subtitles." % config.store_recently_played_amount, thumb=R("icon-played.jpg"))) oc.add( DirectoryObject( key=Callback(RecentlyAddedMenu), title="Recently-added items", summary="Shows the recently added items per section.", thumb=R("icon-added.jpg"))) oc.add( DirectoryObject( key=Callback(RecentMissingSubtitlesMenu, randomize=timestamp()), title="Show recently added items with missing subtitles", summary= "Lists items with missing subtitles. Click on \"Find recent items with missing subs\" " "to update list", thumb=R("icon-missing.jpg"))) 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.", thumb=R("icon-browse.jpg"))) task_name = "SearchAllRecentlyAddedMissing" task = scheduler.task(task_name) if task.ready_for_display: task_state = "Running: %s/%s (%s%%)" % ( task.items_done, 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, thumb=R("icon-search.jpg"))) 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)", thumb=R("icon-ignore.jpg"))) oc.add( DirectoryObject(key=Callback(HistoryMenu), title="History", summary="Show the last %i downloaded subtitles" % int(Prefs["history_size"]), thumb=R("icon-history.jpg"))) 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"), thumb=R("icon-refresh.jpg"))) # 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", thumb=R("icon-advanced.jpg"))) return oc
def fatality(randomize=None, force_title=None, header=None, message=None, only_refresh=False, no_history=False, replace_parent=False): """ subzero main menu """ from interface.advanced import PinMenu, ClearPin, AdvancedMenu from interface.menu import RefreshMissing, IgnoreListMenu, HistoryMenu 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: if not isinstance(config.missing_permissions, list): oc.add(DirectoryObject( key=Callback(fatality, randomize=timestamp()), title=pad_title(_("Insufficient permissions")), summary=config.missing_permissions, )) else: 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 %(title)s, folder: %(path)s", title=title, path=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."), thumb=R("icon-ondeck.jpg") )) if "last_played_items" in Dict and Dict["last_played_items"]: oc.add(DirectoryObject( key=Callback(RecentlyPlayedMenu), title=pad_title(_("Recently played items")), summary=_("Shows the %s recently played items and allows you to individually (force-) refresh their metadata/subtitles.", config.store_recently_played_amount), thumb=R("icon-played.jpg") )) oc.add(DirectoryObject( key=Callback(RecentlyAddedMenu), title=_("Recently-added items"), summary=_("Shows the recently added items per section."), thumb=R("icon-added.jpg") )) oc.add(DirectoryObject( key=Callback(RecentMissingSubtitlesMenu, randomize=timestamp()), title=_("Show recently added items with missing subtitles"), summary=_("Lists items with missing subtitles. Click on \"Find recent items with missing subs\" to update list"), thumb=R("icon-missing.jpg") )) 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."), thumb=R("icon-browse.jpg") )) task_name = "SearchAllRecentlyAddedMissing" task = scheduler.task(task_name) if task.ready_for_display: task_state = _("Running: %(items_done)s/%(items_searching)s (%(percentage)s%%)", items_done=task.items_done, items_searching=task.items_searching, percentage=task.percentage) else: lr = scheduler.last_run(task_name) nr = scheduler.next_run(task_name) task_state = _("Last run: %s; Next scheduled run: %s; Last runtime: %s", df(scheduler.last_run(task_name)) if lr else "never", df(scheduler.next_run(task_name)) if nr else "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), thumb=R("icon-search.jpg") )) ref_list = get_decision_list() incl_excl_ref = _("include list") if ref_list.store == "include" else _("ignore list") oc.add(DirectoryObject( key=Callback(IgnoreListMenu), title=_("Display %(incl_excl_list_name)s (%(count)d)", incl_excl_list_name=incl_excl_ref, count=len(ref_list)), summary=_("Show the current %(incl_excl_list_name)s (mainly used for the automatic tasks)", incl_excl_list_name=incl_excl_ref), thumb=R("icon-ignore.jpg") )) oc.add(DirectoryObject( key=Callback(HistoryMenu), title=_("History"), summary=_("Show the last %i downloaded subtitles", int(Prefs["history_size"])), thumb=R("icon-history.jpg") )) 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") ), thumb=R("icon-refresh.jpg") )) # 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: if "provider_throttle" in Dict and Dict["provider_throttle"].keys(): summary_data = [] for provider, data in Dict["provider_throttle"].iteritems(): reason, until, desc = data summary_data.append(unicode(_("%(throttled_provider)s until %(until_date)s (%(reason)s)", throttled_provider=provider, until_date=until.strftime("%y/%m/%d %H:%M"), reason=reason))) oc.add(DirectoryObject( key=Callback(fatality, force_title=" ", randomize=timestamp()), title=pad_title(_("Throttled providers: %s", ", ".join(Dict["provider_throttle"].keys()))), summary=", ".join(summary_data), thumb=R("icon-throttled.jpg") )) oc.add(DirectoryObject( key=Callback(AdvancedMenu), title=pad_title(_("Advanced functions")), summary=_("Use at your own risk"), thumb=R("icon-advanced.jpg") )) return oc
def fatality(randomize=None, force_title=None, header=None, message=None, only_refresh=False, no_history=False, replace_parent=False): """ subzero main menu """ from interface.advanced import PinMenu, ClearPin, AdvancedMenu from interface.menu import RefreshMissing, IgnoreListMenu, HistoryMenu 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: if not isinstance(config.missing_permissions, list): oc.add( DirectoryObject( key=Callback(fatality, randomize=timestamp()), title=pad_title(_("Insufficient permissions")), summary=config.missing_permissions, )) else: 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 %(title)s, folder: %(path)s", title=title, path=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." ), thumb=R("icon-ondeck.jpg"))) if "last_played_items" in Dict and Dict["last_played_items"]: oc.add( DirectoryObject( key=Callback(RecentlyPlayedMenu), title=pad_title(_("Recently played items")), summary=_( "Shows the %s recently played items and allows you to individually (force-) refresh their metadata/subtitles.", config.store_recently_played_amount), thumb=R("icon-played.jpg"))) oc.add( DirectoryObject( key=Callback(RecentlyAddedMenu), title=_("Recently-added items"), summary=_("Shows the recently added items per section."), thumb=R("icon-added.jpg"))) oc.add( DirectoryObject( key=Callback(RecentMissingSubtitlesMenu, randomize=timestamp()), title=_("Show recently added items with missing subtitles"), summary= _("Lists items with missing subtitles. Click on \"Find recent items with missing subs\" to update list" ), thumb=R("icon-missing.jpg"))) 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." ), thumb=R("icon-browse.jpg"))) task_name = "SearchAllRecentlyAddedMissing" task = scheduler.task(task_name) if task.ready_for_display: task_state = _( "Running: %(items_done)s/%(items_searching)s (%(percentage)s%%)", items_done=task.items_done, items_searching=task.items_searching, percentage=task.percentage) else: lr = scheduler.last_run(task_name) nr = scheduler.next_run(task_name) task_state = _( "Last run: %s; Next scheduled run: %s; Last runtime: %s", df(scheduler.last_run(task_name)) if lr else "never", df(scheduler.next_run(task_name)) if nr else "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), thumb=R("icon-search.jpg"))) ref_list = get_decision_list() incl_excl_ref = _( "include list") if ref_list.store == "include" else _( "ignore list") oc.add( DirectoryObject( key=Callback(IgnoreListMenu), title=_("Display %(incl_excl_list_name)s (%(count)d)", incl_excl_list_name=incl_excl_ref, count=len(ref_list)), summary= _("Show the current %(incl_excl_list_name)s (mainly used for the automatic tasks)", incl_excl_list_name=incl_excl_ref), thumb=R("icon-ignore.jpg"))) oc.add( DirectoryObject(key=Callback(HistoryMenu), title=_("History"), summary=_("Show the last %i downloaded subtitles", int(Prefs["history_size"])), thumb=R("icon-history.jpg"))) 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")), thumb=R("icon-refresh.jpg"))) # 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: if "provider_throttle" in Dict and Dict["provider_throttle"].keys(): summary_data = [] for provider, data in Dict["provider_throttle"].iteritems(): reason, until, desc = data summary_data.append( unicode( _("%(throttled_provider)s until %(until_date)s (%(reason)s)", throttled_provider=provider, until_date=until.strftime("%y/%m/%d %H:%M"), reason=reason))) oc.add( DirectoryObject( key=Callback(fatality, force_title=" ", randomize=timestamp()), title=pad_title( _("Throttled providers: %s", ", ".join(Dict["provider_throttle"].keys()))), summary=", ".join(summary_data), thumb=R("icon-throttled.jpg"))) oc.add( DirectoryObject(key=Callback(AdvancedMenu), title=pad_title(_("Advanced functions")), summary=_("Use at your own risk"), thumb=R("icon-advanced.jpg"))) return oc