def event(key): def itemMaker(source, fn): li = ListItem("[%s][%s] [B]%s[/B] (%s)" % ( source.get("quality", "XY"), source.get("lang", "Xyz"), source.get("channel", "UNKNOWN"), fn.NAME, )) return li sources = get_all_sources(key) sources_dec = [] for s in sources: source_fn = url_to_source(s["url"]) sources_dec.append({"el": s, "fn": source_fn}) items = list( map( lambda s: (PLUGIN.url_for(s["fn"].root, url=urllib.parse.quote( s["el"]["url"].encode('utf8'), safe='')), itemMaker(s["el"], s["fn"]), True), sources_dec)) if (len(sources) == 0): li = ListItem("No playable sources found") addDirectoryItem(PLUGIN.handle, "", li) addDirectoryItems(PLUGIN.handle, items) endOfDirectory(PLUGIN.handle)
def index(): """Start page of addon""" items = list( map(lambda p: (PLUGIN.url_for(p.root), ListItem(p.NAME), True), all_providers)) addDirectoryItems(PLUGIN.handle, items) endOfDirectory(PLUGIN.handle)
def root(): def itemMaker(event): li = ListItem("[%s] %s - %s" % ( event.get("category", "XY"), event.get("name", "UNKNOWN"), event.get("date", "Xyz") )) li.setArt({'thumb': event.get("thumb", None), 'fanart': event.get("fanart", None)}) return li events = get_all_events() items = list(map(lambda e: (PLUGIN.url_for(event, key=e["key"]), itemMaker(e), True), events)) addDirectoryItems(PLUGIN.handle, items) endOfDirectory(PLUGIN.handle)
def root(): def itemMaker(event): li = ListItem("[B][COLOR %s]%s[/COLOR][/B] | %s" % ( league_color(event.get("league", "")), event.get("league", ""), event.get("name", ""), )) li.setArt({ 'thumb': event.get("thumb", None), 'fanart': event.get("fanart", None) }) return li events = get_all_events() items = list( map( lambda e: (PLUGIN.url_for(event, key=e["key"]), itemMaker(e), True), events)) addDirectoryItems(PLUGIN.handle, items) endOfDirectory(PLUGIN.handle)