def add_ignore_options(oc, kind, callback_menu=None, title=None, rating_key=None, add_kind=True): """ :param oc: oc to add our options to :param kind: movie, show, episode ... - gets translated to the ignore key (sections, series, items) :param callback_menu: menu to inject :param title: :param rating_key: :return: """ # try to translate kind to the ignore key use_kind = kind if kind not in ignore_list: use_kind = ignore_list.translate_key(kind) if not use_kind or use_kind not in ignore_list: return in_list = rating_key in ignore_list[use_kind] oc.add(DirectoryObject( key=Callback(callback_menu, kind=use_kind, rating_key=rating_key, title=title), title=u"%s %s \"%s\" %s the ignore list" % ( "Remove" if in_list else "Add", ignore_list.verbose(kind) if add_kind else "", unicode(title), "from" if in_list else "to") ) )
def add_ignore_options(oc, kind, callback_menu=None, title=None, rating_key=None, add_kind=True): """ :param oc: oc to add our options to :param kind: movie, show, episode ... - gets translated to the ignore key (sections, series, items) :param callback_menu: menu to inject :param title: :param rating_key: :return: """ # try to translate kind to the ignore key use_kind = kind if kind not in ignore_list: use_kind = ignore_list.translate_key(kind) if not use_kind or use_kind not in ignore_list: return in_list = rating_key in ignore_list[use_kind] oc.add(DirectoryObject( key=Callback(callback_menu, kind=use_kind, rating_key=rating_key, title=title), title="%s %s \"%s\" %s the ignore list" % ( "Remove" if in_list else "Add", ignore_list.verbose(kind) if add_kind else "", unicode(title), "from" if in_list else "to") ) )
def add_ignore_options(oc, kind, callback_menu=None, title=None, rating_key=None, add_kind=True): """ :param oc: oc to add our options to :param kind: movie, show, episode ... - gets translated to the ignore key (sections, series, items) :param callback_menu: menu to inject :param title: :param rating_key: :return: """ # try to translate kind to the ignore key use_kind = kind if kind not in ignore_list: use_kind = ignore_list.translate_key(kind) if not use_kind or use_kind not in ignore_list: return in_list = rating_key in ignore_list[use_kind] t = u"Ignore %(kind)s \"%(title)s\"" if in_list: t = u"Un-ignore %(kind)s \"%(title)s\"" oc.add(DirectoryObject( key=Callback(callback_menu, kind=use_kind, sure=False, todo="not_set", rating_key=rating_key, title=title), title=_(t, kind=ignore_list.verbose(kind) if add_kind else "", title=unicode(title)) ) )
def IgnoreMenu(kind, rating_key, title=None, sure=False, todo="not_set"): is_ignored = rating_key in ignore_list[kind] if not sure: oc = ObjectContainer( no_history=True, replace_parent=True, title1="%s %s %s %s the ignore list" % ( "Add" if not is_ignored else "Remove", ignore_list.verbose(kind), title, "to" if not is_ignored else "from", ), title2="Are you sure?", ) oc.add( DirectoryObject( key=Callback( IgnoreMenu, kind=kind, rating_key=rating_key, title=title, sure=True, todo="add" if not is_ignored else "remove", ), title=pad_title("Are you sure?"), ) ) return oc rel = ignore_list[kind] dont_change = False if todo == "remove": if not is_ignored: dont_change = True else: rel.remove(rating_key) Log.Info("Removed %s (%s) from the ignore list", title, rating_key) ignore_list.remove_title(kind, rating_key) ignore_list.save() state = "removed from" elif todo == "add": if is_ignored: dont_change = True else: rel.append(rating_key) Log.Info("Added %s (%s) to the ignore list", title, rating_key) ignore_list.add_title(kind, rating_key, title) ignore_list.save() state = "added to" else: dont_change = True if dont_change: return fatality(force_title=" ", header="Didn't change the ignore list", no_history=True) return fatality(force_title=" ", header="%s %s the ignore list" % (title, state), no_history=True)
def IgnoreMenu(kind, rating_key, title=None, sure=False, todo="not_set"): """ displays the ignore options for a menu :param kind: :param rating_key: :param title: :param sure: :param todo: :return: """ is_ignored = rating_key in ignore_list[kind] if not sure: oc = SubFolderObjectContainer(no_history=True, replace_parent=True, title1="%s %s %s %s the ignore list" % ( "Add" if not is_ignored else "Remove", ignore_list.verbose(kind), title, "to" if not is_ignored else "from"), title2="Are you sure?") oc.add(DirectoryObject( key=Callback(IgnoreMenu, kind=kind, rating_key=rating_key, title=title, sure=True, todo="add" if not is_ignored else "remove"), title=pad_title("Are you sure?"), )) return oc rel = ignore_list[kind] dont_change = False if todo == "remove": if not is_ignored: dont_change = True else: rel.remove(rating_key) Log.Info("Removed %s (%s) from the ignore list", title, rating_key) ignore_list.remove_title(kind, rating_key) ignore_list.save() state = "removed from" elif todo == "add": if is_ignored: dont_change = True else: rel.append(rating_key) Log.Info("Added %s (%s) to the ignore list", title, rating_key) ignore_list.add_title(kind, rating_key, title) ignore_list.save() state = "added to" else: dont_change = True if dont_change: return fatality(force_title=" ", header="Didn't change the ignore list", no_history=True) return fatality(force_title=" ", header="%s %s the ignore list" % (title, state), no_history=True)