def last_queries(): queries = load_queries() for index, item in enumerate(queries): query = item.get('query') # fix type for already saved encoded queries if type(query) == str: query = py2_decode(query) channel = item.get('channel') if channel: label = "{0}: {1}".format(channel, query) url = plugin.get_url(action='search_channel', query=query, channel=channel) else: label = query url = plugin.get_url(action='search_all', query=query) li = xbmcgui.ListItem(label) li.addContextMenuItems([ ( _("Remove query"), 'XBMC.RunPlugin({0})'.format(plugin.get_url(action='remove_query', index=index)) ) ]) xbmcplugin.addDirectoryItem( plugin.handle, url, li, isFolder=True ) xbmcplugin.endOfDirectory(plugin.handle)
def search_all(params): page = int(params.get("page", 1)) query = params.get("query") if not query: dialog = xbmcgui.Dialog() query = dialog.input(_("Search term")) query = py2_decode(query) if not query: return save_query(query) list_videos("search_all", page, query=query)
def search_channel(params): page = int(params.get("page", 1)) channel = params.get("channel") if not channel: channel = get_channel() if not channel: return query = params.get("query") if not query: dialog = xbmcgui.Dialog() query = dialog.input(_("Search term")) query = py2_decode(query) if not query: return save_query(query, channel) list_videos("search_channel", page, query=query, channel=channel)
def main_folders(): artPath = py2_decode(control.artPath()) addDirectoryItem("Műsorok", "musorok", os.path.join(artPath, "tv2play.png"), None) r = client.request("%s/channels" % api_url) channels = sorted(json.loads(r), key=lambda k:k["id"]) for channel in channels: if channel["slug"] != "spiler2" and (not channel["isPremium"] or hasPremium): try: logopath = os.path.join(artPath, "%s%s" % (channel["slug"], ".png")) except: logopath = '' addDirectoryItem(channel["name"], "apisearch¶m=%s&ispremium=%s" % (channel["slug"], channel["isPremium"]), logopath, logopath, meta={'title': channel["name"]}) endDirectory(type="")
from __future__ import unicode_literals import datetime import os import sys import xbmc import xbmcaddon import xbmcgui import xbmcplugin from resources.lib.mediathekviewweb import MediathekViewWeb from resources.lib.simpleplugin import Plugin, Addon from resources.lib.utils import py2_encode, py2_decode # add pytz module to path addon_dir = py2_decode(xbmc.translatePath(xbmcaddon.Addon().getAddonInfo('path'))) module_dir = os.path.join(addon_dir, "resources", "lib", "pytz") sys.path.insert(0, module_dir) import pytz plugin = Plugin() addon = Addon() _ = plugin.initialize_gettext() PER_PAGE = plugin.get_setting("per_page") FUTURE = plugin.get_setting("enable_future") QUALITY = plugin.get_setting("quality") SUBTITLE = plugin.get_setting("enable_subtitle")