def reorder_preset_elements(elementslist): log_debug("reorder_preset_elements", 2) newelementslist = [] maxpresetnum = get_max_preset_num(elementslist) presetnum = 1 while presetnum <= maxpresetnum: for element in elementslist: if "show" in element and utils.get_int(element["show"], "preset_number") == presetnum: newelementslist.append({"show": element["show"]}) break elif "station" in element and utils.get_int(element["station"], "preset_number") == presetnum: newelementslist.append({"station": element["station"]}) break elif ( "link" in element and __tunein__.is_custom_url_id(utils.get_value(element["link"], "guide_id")) and utils.get_int(element["link"], "preset_number") == presetnum ): newelementslist.append({"link": element["link"]}) break presetnum = presetnum + 1 # Add any links or topics to ordered elements list. for element in elementslist: if "link" in element and not __tunein__.is_custom_url_id(utils.get_value(element["link"], "guide_id")): newelementslist.append({"link": element["link"]}) elif "topic" in element: newelementslist.append({"topic": element["topic"]}) return newelementslist
def reorder_preset_elements(elementslist): log_debug('reorder_preset_elements', 2) newelementslist = [] maxpresetnum = get_max_preset_num(elementslist) presetnum = 1 while presetnum <= maxpresetnum: for element in elementslist: if 'show' in element and utils.get_int(element['show'], 'preset_number') == presetnum: newelementslist.append({'show': element['show']}) break elif 'station' in element and utils.get_int(element['station'], 'preset_number') == presetnum: newelementslist.append({'station': element['station']}) break elif 'link' in element and __tunein__.is_custom_url_id(utils.get_value(element['link'], 'guide_id')) and utils.get_int(element['link'], 'preset_number') == presetnum: newelementslist.append({'link': element['link']}) break presetnum = presetnum + 1 # Add any links or topics to ordered elements list. for element in elementslist: if 'link' in element and not __tunein__.is_custom_url_id(utils.get_value(element['link'], 'guide_id')): newelementslist.append({'link': element['link']}) elif 'topic' in element: newelementslist.append({'topic': element['topic']}) return newelementslist
def add_topic(topic, file=""): log_debug("add_topic", 2) log_debug("topic: %s" % topic, 3) log_debug("file: %s" % file, 3) id = utils.get_value(topic, "guide_id") name = utils.get_value(topic, "title") stream_type = utils.get_value(topic, "stream_type") if not __tunein__.is_topic_id(id): return if not __enabledownloads__ and stream_type == "download": return url = utils.add_params(__settings__.get_argv(0), {"path": "tune", "id": id, "name": name, "file": file}) logo = None contextmenu = None if file is not None and len(file) > 0: contextmenu = [ ( __settings__.get_string(1016), "XBMC.RunPlugin(%s?path=%s&id=%s)" % (__settings__.get_argv(0), "remove-download", id), ) ] if stream_type == "download": logo = __settings__.get_path("%s%s%s" % ("resources/images/", get_logo_colour(), "/downloads-256.png")) add_directory_item(name, url, logo=logo, isfolder=False, contextmenu=contextmenu)
def add_topic(topic, file=''): log_debug('add_topic', 2) log_debug('topic: %s' % topic, 3) log_debug('file: %s' % file, 3) id = utils.get_value(topic, 'guide_id') name = utils.get_value(topic, 'title') stream_type = utils.get_value(topic, 'stream_type') if not __tunein__.is_topic_id(id): return if not __enabledownloads__ and stream_type == 'download': return url = utils.add_params(__settings__.get_argv( 0), {'path': 'tune', 'id': id, 'name': name, 'file': file}) logo = None contextmenu = None if file is not None and len(file) > 0: contextmenu = [(__settings__.get_string(1016), 'XBMC.RunPlugin(%s?path=%s&id=%s)' % ( __settings__.get_argv(0), 'remove-download', id))] if stream_type == 'download': logo = __settings__.get_path('%s%s%s' % ( 'resources/images/', get_logo_colour(), '/downloads-256.png')) add_directory_item( name, url, logo=logo, isfolder=False, contextmenu=contextmenu)
def add_show_outline(show): log_debug('add_show_outline', 2) log_debug('show: %s' % show, 3) id = utils.get_value(show, 'guide_id') name = utils.get_value(show, 'text') logo = utils.get_value(show, 'image') label = utils.get_value(show, 'subtext') album = utils.get_value(show, 'current_track') is_preset = utils.get_value(show, 'is_preset') preset_number = utils.get_value(show, 'preset_number') params = utils.get_params(show['URL'].split('?')[1]) category = utils.get_value(params, 'c') filter = utils.get_value(params, 'filter') if not __tunein__.is_show_id(id): return __showscache__.add(show) url = utils.add_params(__settings__.get_argv(0), {'path': 'tune-show', 'id': id, 'name': name, 'logo': logo, 'c': category, 'filter': filter}) if is_preset == 'true': contextmenu = [(__settings__.get_string(1012), 'XBMC.RunPlugin(%s?path=%s&id=%s&num=%s)' % (__settings__.get_argv(0), 'up', id, preset_number, )), (__settings__.get_string(1013), 'XBMC.RunPlugin(%s?path=%s&id=%s&num=%s)' % (__settings__.get_argv(0), 'down', id, preset_number,)), (__settings__.get_string(1010), 'XBMC.RunPlugin(%s?path=%s&id=%s)' % (__settings__.get_argv(0), 'remove', id, ))] else: contextmenu = [(__settings__.get_string(1009), 'XBMC.RunPlugin(%s?path=%s&id=%s)' % (__settings__.get_argv(0), 'add', id, ))] add_directory_item(name, url, label=label, album=album, logo=logo, contextmenu=contextmenu)
def add_link_outline(link): log_debug('add_link_outline', 2) log_debug('link: %s' % link, 3) if __tunein__.is_custom_url_id(utils.get_value(link, 'guide_id')): add_custom_url(link) return params = utils.get_params(link['URL'].split('?')[1]) category = utils.get_value(params, 'c') offset = utils.get_value(params, 'offset') filter = utils.get_value(params, 'filter') pivot = utils.get_value(params, 'pivot') id = utils.get_value(params, 'id') name = utils.get_value(link, 'text') logo = '' if 'image' in link: logo = utils.get_value(link, 'image') label = '' if 'subtext' in link: label = utils.get_value(link, 'subtext') path = 'browse' if __tunein__.is_show_id(id): path = 'tune-show' contextmenu = [(__settings__.get_string(1009), 'XBMC.RunPlugin(%s?path=%s&id=%s)' % (__settings__.get_argv(0), 'add', id, ))] else: contextmenu = [] url = utils.add_params(__settings__.get_argv(0), { 'path': path, 'id': id, 'c': category, 'name': name, 'filter': filter, 'offset': offset, 'pivot': pivot}) add_directory_item(name, url, label=label, logo=logo, contextmenu=contextmenu)
def add_station_outline(station): log_debug('add_station_outline', 2) log_debug('station: %s' % station, 3) id = utils.get_value(station, 'guide_id') name = utils.get_value(station, 'text') logo = utils.get_value(station, 'image') label = utils.get_value(station, 'subtext') album = utils.get_value(station, 'current_track') is_preset = utils.get_value(station, 'is_preset') preset_number = utils.get_value(station, 'preset_number') genre = utils.get_value(station, 'genre_name') if len(genre) == 0: genre = get_genre_name(utils.get_value(station, 'genre_id')) if not __tunein__.is_station_id(id): return url = utils.add_params(__settings__.get_argv( 0), {'path': 'tune', 'id': id, 'name': name, 'logo': logo}) if is_preset == 'true': contextmenu = [( __settings__.get_string( 1012), 'XBMC.RunPlugin(%s?path=%s&id=%s&num=%s)' % (__settings__.get_argv(0), 'up', id, preset_number, )), (__settings__.get_string(1013), 'XBMC.RunPlugin(%s?path=%s&id=%s&num=%s)' % (__settings__.get_argv(0), 'down', id, preset_number, )), (__settings__.get_string(1005), 'XBMC.RunPlugin(%s?path=%s&id=%s)' % (__settings__.get_argv(0), 'remove', id))] else: contextmenu = [(__settings__.get_string( 1004), 'XBMC.RunPlugin(%s?path=%s&id=%s)' % (__settings__.get_argv(0), 'add', id))] contextmenu.append((__settings__.get_string(1018), 'XBMC.RunPlugin(%s)' % (utils.add_params(__settings__.get_argv(0), {'path': 'xbmc-favourites', 'id': id, 'name': name, 'logo': logo})))) add_directory_item(name, url, album, artist=label, album=name, genre=genre, logo=logo, isfolder=False, contextmenu=contextmenu)
def add_station_outline(station): log_debug("add_station_outline", 2) log_debug("station: %s" % station, 3) id = utils.get_value(station, "guide_id") name = utils.get_value(station, "text") logo = utils.get_value(station, "image") label = utils.get_value(station, "subtext") album = utils.get_value(station, "current_track") is_preset = utils.get_value(station, "is_preset") preset_number = utils.get_value(station, "preset_number") genre = utils.get_value(station, "genre_name") if len(genre) == 0: genre = get_genre_name(utils.get_value(station, "genre_id")) if not __tunein__.is_station_id(id): return url = utils.add_params(__settings__.get_argv(0), {"path": "tune", "id": id, "name": name, "logo": logo}) if is_preset == "true": contextmenu = [ ( __settings__.get_string(1012), "XBMC.RunPlugin(%s?path=%s&id=%s&num=%s)" % (__settings__.get_argv(0), "up", id, preset_number), ), ( __settings__.get_string(1013), "XBMC.RunPlugin(%s?path=%s&id=%s&num=%s)" % (__settings__.get_argv(0), "down", id, preset_number), ), ( __settings__.get_string(1005), "XBMC.RunPlugin(%s?path=%s&id=%s)" % (__settings__.get_argv(0), "remove", id), ), ] else: contextmenu = [ (__settings__.get_string(1004), "XBMC.RunPlugin(%s?path=%s&id=%s)" % (__settings__.get_argv(0), "add", id)) ] contextmenu.append( ( __settings__.get_string(1018), "XBMC.RunPlugin(%s)" % ( utils.add_params( __settings__.get_argv(0), {"path": "xbmc-favourites", "id": id, "name": name, "logo": logo} ) ), ) ) add_directory_item( name, url, album, artist=label, album=name, genre=genre, logo=logo, isfolder=False, contextmenu=contextmenu )
def add_custom_url(link, presets=True): log_debug('add_custom_url', 2) log_debug('link: %s' % link, 3) if not __tunein__.is_custom_url_id(utils.get_value(link, 'guide_id')): return id = utils.get_value(link, 'guide_id') url = utils.get_value(link, 'URL') name = utils.get_value(link, 'text') logo = utils.get_value(link, 'image') path = 'custom-url' contextmenu = None if presets: contextmenu = [(__settings__.get_string(1017), 'XBMC.RunPlugin(%s?path=%s&id=%s)' % (__settings__.get_argv(0), 'remove', id, ))] url = utils.add_params(__settings__.get_argv(0), {'path': path, 'id': id, 'name': name, 'url': url, 'logo': logo}) add_directory_item(name, url, logo=logo, contextmenu=contextmenu, isfolder=False)
def get_max_preset_num(elementslist): maxpresetnum = 0 for element in elementslist: if 'show' in element and utils.get_int(element['show'], 'preset_number') > maxpresetnum: maxpresetnum = utils.get_int(element['show'], 'preset_number') elif 'station' in element and utils.get_int(element['station'], 'preset_number') > maxpresetnum: maxpresetnum = utils.get_int(element['station'], 'preset_number') elif 'link' in element and __tunein__.is_custom_url_id(utils.get_value(element['link'], 'guide_id')) and utils.get_int(element['link'], 'preset_number') > maxpresetnum: maxpresetnum = utils.get_int(element['link'], 'preset_number') return maxpresetnum
def add_show_outline(show): log_debug("add_show_outline", 2) log_debug("show: %s" % show, 3) id = utils.get_value(show, "guide_id") name = utils.get_value(show, "text") logo = utils.get_value(show, "image") label = utils.get_value(show, "subtext") album = utils.get_value(show, "current_track") is_preset = utils.get_value(show, "is_preset") preset_number = utils.get_value(show, "preset_number") params = utils.get_params(show["URL"].split("?")[1]) category = utils.get_value(params, "c") filter = utils.get_value(params, "filter") if not __tunein__.is_show_id(id): return __showscache__.add(show) url = utils.add_params( __settings__.get_argv(0), {"path": "tune-show", "id": id, "name": name, "logo": logo, "c": category, "filter": filter}, ) if is_preset == "true": contextmenu = [ ( __settings__.get_string(1012), "XBMC.RunPlugin(%s?path=%s&id=%s&num=%s)" % (__settings__.get_argv(0), "up", id, preset_number), ), ( __settings__.get_string(1013), "XBMC.RunPlugin(%s?path=%s&id=%s&num=%s)" % (__settings__.get_argv(0), "down", id, preset_number), ), ( __settings__.get_string(1010), "XBMC.RunPlugin(%s?path=%s&id=%s)" % (__settings__.get_argv(0), "remove", id), ), ] else: contextmenu = [ (__settings__.get_string(1009), "XBMC.RunPlugin(%s?path=%s&id=%s)" % (__settings__.get_argv(0), "add", id)) ] add_directory_item(name, url, label=label, album=album, logo=logo, contextmenu=contextmenu)
def add_custom_url(link, presets=True): log_debug('add_custom_url', 2) log_debug('link: %s' % link, 3) if not __tunein__.is_custom_url_id(utils.get_value(link, 'guide_id')): return id = utils.get_value(link, 'guide_id') url = utils.get_value(link, 'URL') name = utils.get_value(link, 'text') logo = utils.get_value(link, 'image') path = 'custom-url' contextmenu = None if presets: contextmenu = [(__settings__.get_string(1017), 'XBMC.RunPlugin(%s?path=%s&id=%s)' % ( __settings__.get_argv(0), 'remove', id, ))] url = utils.add_params(__settings__.get_argv( 0), {'path': path, 'id': id, 'name': name, 'url': url, 'logo': logo}) add_directory_item( name, url, logo=logo, contextmenu=contextmenu, isfolder=False)
def add_station(station): log_debug("add_station", 2) log_debug("station: %s" % station, 3) id = utils.get_value(station, "guide_id") name = utils.get_value(station, "name") logo = utils.get_value(station, "logo") label = utils.get_value(station, "slogan") genre = utils.get_value(station, "genre_name") if len(genre) == 0: genre = get_genre_name(utils.get_value(station, "genre_id")) if not __tunein__.is_station_id(id): return contextmenu = [ ( __settings__.get_string(1018), "XBMC.RunPlugin(%s)" % ( utils.add_params( __settings__.get_argv(0), {"path": "xbmc-favourites", "id": id, "name": name, "logo": logo} ) ), ) ] url = utils.add_params(__settings__.get_argv(0), {"path": "tune", "id": id, "name": name, "logo": logo}) add_directory_item(name, url, label=label, genre=genre, logo=logo, isfolder=False, contextmenu=contextmenu)
def add_custom_url(link, presets=True): log_debug("add_custom_url", 2) log_debug("link: %s" % link, 3) if not __tunein__.is_custom_url_id(utils.get_value(link, "guide_id")): return id = utils.get_value(link, "guide_id") url = utils.get_value(link, "URL") name = utils.get_value(link, "text") logo = utils.get_value(link, "image") path = "custom-url" contextmenu = None if presets: contextmenu = [ ( __settings__.get_string(1017), "XBMC.RunPlugin(%s?path=%s&id=%s)" % (__settings__.get_argv(0), "remove", id), ) ] url = utils.add_params(__settings__.get_argv(0), {"path": path, "id": id, "name": name, "url": url, "logo": logo}) add_directory_item(name, url, logo=logo, contextmenu=contextmenu, isfolder=False)
def get_max_preset_num(elementslist): maxpresetnum = 0 for element in elementslist: if "show" in element and utils.get_int(element["show"], "preset_number") > maxpresetnum: maxpresetnum = utils.get_int(element["show"], "preset_number") elif "station" in element and utils.get_int(element["station"], "preset_number") > maxpresetnum: maxpresetnum = utils.get_int(element["station"], "preset_number") elif ( "link" in element and __tunein__.is_custom_url_id(utils.get_value(element["link"], "guide_id")) and utils.get_int(element["link"], "preset_number") > maxpresetnum ): maxpresetnum = utils.get_int(element["link"], "preset_number") return maxpresetnum
def add_link_outline(link): log_debug("add_link_outline", 2) log_debug("link: %s" % link, 3) if __tunein__.is_custom_url_id(utils.get_value(link, "guide_id")): add_custom_url(link) return params = utils.get_params(link["URL"].split("?")[1]) category = utils.get_value(params, "c") offset = utils.get_value(params, "offset") filter = utils.get_value(params, "filter") pivot = utils.get_value(params, "pivot") id = utils.get_value(params, "id") name = utils.get_value(link, "text") logo = "" if "image" in link: logo = utils.get_value(link, "image") label = "" if "subtext" in link: label = utils.get_value(link, "subtext") path = "browse" if __tunein__.is_show_id(id): path = "tune-show" contextmenu = [ (__settings__.get_string(1009), "XBMC.RunPlugin(%s?path=%s&id=%s)" % (__settings__.get_argv(0), "add", id)) ] else: contextmenu = [] url = utils.add_params( __settings__.get_argv(0), {"path": path, "id": id, "c": category, "name": name, "filter": filter, "offset": offset, "pivot": pivot}, ) add_directory_item(name, url, label=label, logo=logo, contextmenu=contextmenu)
def add_show_outline(show): log_debug('add_show_outline', 2) log_debug('show: %s' % show, 3) id = utils.get_value(show, 'guide_id') name = utils.get_value(show, 'text') logo = utils.get_value(show, 'image') label = utils.get_value(show, 'subtext') album = utils.get_value(show, 'current_track') is_preset = utils.get_value(show, 'is_preset') preset_number = utils.get_value(show, 'preset_number') params = utils.get_params(show['URL'].split('?')[1]) category = utils.get_value(params, 'c') filter = utils.get_value(params, 'filter') if not __tunein__.is_show_id(id): return __showscache__.add(show) url = utils.add_params(__settings__.get_argv(0), { 'path': 'tune-show', 'id': id, 'name': name, 'logo': logo, 'c': category, 'filter': filter}) if is_preset == 'true': contextmenu = [( __settings__.get_string( 1012), 'XBMC.RunPlugin(%s?path=%s&id=%s&num=%s)' % (__settings__.get_argv(0), 'up', id, preset_number, )), (__settings__.get_string(1013), 'XBMC.RunPlugin(%s?path=%s&id=%s&num=%s)' % (__settings__.get_argv(0), 'down', id, preset_number,)), (__settings__.get_string(1010), 'XBMC.RunPlugin(%s?path=%s&id=%s)' % (__settings__.get_argv(0), 'remove', id, ))] else: contextmenu = [(__settings__.get_string( 1009), 'XBMC.RunPlugin(%s?path=%s&id=%s)' % (__settings__.get_argv(0), 'add', id, ))] add_directory_item(name, url, label=label, album=album, logo=logo, contextmenu=contextmenu)
def add_station(station): log_debug('add_station', 2) log_debug('station: %s' % station, 3) id = utils.get_value(station, 'guide_id') name = utils.get_value(station, 'name') logo = utils.get_value(station, 'logo') label = utils.get_value(station, 'slogan') genre = utils.get_value(station, 'genre_name') if len(genre) == 0: genre = get_genre_name(utils.get_value(station, 'genre_id')) if not __tunein__.is_station_id(id): return url = utils.add_params(__settings__.get_argv(0), {'path': 'tune', 'id': id, 'name': name, 'logo': logo}) add_directory_item(name, url, label=label, genre=genre, logo=logo, isfolder=False)
def add_show(show): log_debug('add_show', 2) log_debug('show: %s' % show, 3) id = utils.get_value(show, 'guide_id') name = utils.get_value(show, 'title') logo = utils.get_value(show, 'logo') label = utils.get_value(show, 'description') genre = utils.get_value(show, 'genre_name') if len(genre) == 0: genre = get_genre_name(utils.get_value(show, 'genre_id')) if not __tunein__.is_show_id(id): return __showscache__.add(show) url = utils.add_params(__settings__.get_argv(0), {'path': 'tune-show', 'id': id, 'name': name, 'logo': logo}) contextmenu = [(__settings__.get_string(1009), 'XBMC.RunPlugin(%s?path=%s&id=%s)' % (__settings__.get_argv(0), 'add', id, ))] add_directory_item(name, url, label=label, genre=genre, logo=logo, contextmenu=contextmenu)
def add_station(station): log_debug('add_station', 2) log_debug('station: %s' % station, 3) id = utils.get_value(station, 'guide_id') name = utils.get_value(station, 'name') logo = utils.get_value(station, 'logo') label = utils.get_value(station, 'slogan') genre = utils.get_value(station, 'genre_name') if len(genre) == 0: genre = get_genre_name(utils.get_value(station, 'genre_id')) if not __tunein__.is_station_id(id): return contextmenu = [(__settings__.get_string(1018), 'XBMC.RunPlugin(%s)' % (utils.add_params(__settings__.get_argv(0), {'path': 'xbmc-favourites', 'id': id, 'name': name, 'logo': logo})))] url = utils.add_params(__settings__.get_argv( 0), {'path': 'tune', 'id': id, 'name': name, 'logo': logo}) add_directory_item( name, url, label=label, genre=genre, logo=logo, isfolder=False, contextmenu=contextmenu)
def add_show(show): log_debug("add_show", 2) log_debug("show: %s" % show, 3) id = utils.get_value(show, "guide_id") name = utils.get_value(show, "title") logo = utils.get_value(show, "logo") label = utils.get_value(show, "description") genre = utils.get_value(show, "genre_name") if len(genre) == 0: genre = get_genre_name(utils.get_value(show, "genre_id")) if not __tunein__.is_show_id(id): return __showscache__.add(show) url = utils.add_params(__settings__.get_argv(0), {"path": "tune-show", "id": id, "name": name, "logo": logo}) contextmenu = [ (__settings__.get_string(1009), "XBMC.RunPlugin(%s?path=%s&id=%s)" % (__settings__.get_argv(0), "add", id)) ] add_directory_item(name, url, label=label, genre=genre, logo=logo, contextmenu=contextmenu)
def add_show(show): log_debug('add_show', 2) log_debug('show: %s' % show, 3) id = utils.get_value(show, 'guide_id') name = utils.get_value(show, 'title') logo = utils.get_value(show, 'logo') label = utils.get_value(show, 'description') genre = utils.get_value(show, 'genre_name') if len(genre) == 0: genre = get_genre_name(utils.get_value(show, 'genre_id')) if not __tunein__.is_show_id(id): return __showscache__.add(show) url = utils.add_params(__settings__.get_argv( 0), {'path': 'tune-show', 'id': id, 'name': name, 'logo': logo}) contextmenu = [(__settings__.get_string(1009), 'XBMC.RunPlugin(%s?path=%s&id=%s)' % (__settings__.get_argv(0), 'add', id, ))] add_directory_item(name, url, label=label, genre=genre, logo=logo, contextmenu=contextmenu)
# Get addon settings values. __username__ = __settings__.get('username') __password__ = __settings__.get('password') __latlon__ = __settings__.get('latlon') __locale__ = __settings__.get('locale') __iconcolour__ = __settings__.get('iconcolour') __prompt__ = __settings__.get('prompt') == "true" __featured__ = __settings__.get('featured') == "true" __local__ = __settings__.get('local') == "true" __debuglevel__ = __settings__.get('debuglevel') __enabledownloads__ = __settings__.get('enabledownloads') == "true" __onlyfavourites__ = __settings__.get('onlyfavourites') == "true" # Initialise parameters. __params__ = utils.get_params(__settings__.get_argv(2)) __path__ = utils.get_value(__params__, 'path') __id__ = utils.get_value(__params__, 'id') __fanart__ = os.path.join(__settings__.get_path(), 'fanart.jpg') if __settings__.get('fanart') == "true" and int(__settings__.get_argv(1)) != -1: xbmcplugin.setPluginFanart(int(__settings__.get_argv(1)), __fanart__) modtime = __formatscache__.lastupdate() if modtime is None or modtime > (__settings__.get('cacheupdate') * 60 * 60) or len(__formatscache__.get()) == 0: __formatscache__.clear() __formatscache__.add(tunein.TuneIn(__partnerid__).describe_formats()) __formats__ = get_formats() # Get mac address to be used as serial. # Note: function seems to occasionally return 'Busy', so added workaround. mac_address = utils.mac_address() if mac_address == 'Busy':
def add_directory_item( name, url, label="", artist="", album="", genre="", comment="", logo=None, isfolder=True, contextmenu=None ): log_debug("add_directory_item", 2) log_debug("name: %s" % name, 3) log_debug("url: %s" % url, 3) log_debug("label: %s" % label, 3) log_debug("artist: %s" % artist, 3) log_debug("album: %s" % album, 3) log_debug("genre: %s" % genre, 3) log_debug("comment: %s" % comment, 3) log_debug("logo: %s" % logo, 3) log_debug("isfolder: %s" % isfolder, 3) log_debug("contextmenu: %s" % contextmenu, 3) # If logo argument not set use default directory/stream image. if (logo is None or len(logo) == 0) and isfolder: iconImage = __settings__.get_path("%s%s%s" % ("resources/images/", get_logo_colour(), "/folder-32.png")) thumbnailImage = __settings__.get_path("%s%s%s" % ("resources/images/", get_logo_colour(), "/folder-256.png")) # Add custom logos for Browse category # pattern = re.compile('(.*)c=(\w+)') # result = pattern.match(url) params = utils.get_params(url.split("?")[1]) category = utils.get_value(params, "c") if category: # if result.group(2) == "local": if category == "local": iconImage = __settings__.get_path("%s%s%s" % ("resources/images/", get_logo_colour(), "/local-32.png")) thumbnailImage = __settings__.get_path( "%s%s%s" % ("resources/images/", get_logo_colour(), "/local-256.png") ) elif category == "music": iconImage = __settings__.get_path("%s%s%s" % ("resources/images/", get_logo_colour(), "/music-32.png")) thumbnailImage = __settings__.get_path( "%s%s%s" % ("resources/images/", get_logo_colour(), "/music-256.png") ) elif category == "talk": iconImage = __settings__.get_path("%s%s%s" % ("resources/images/", get_logo_colour(), "/talk-32.png")) thumbnailImage = __settings__.get_path( "%s%s%s" % ("resources/images/", get_logo_colour(), "/talk-256.png") ) elif category == "sports": iconImage = __settings__.get_path("%s%s%s" % ("resources/images/", get_logo_colour(), "/sports-32.png")) thumbnailImage = __settings__.get_path( "%s%s%s" % ("resources/images/", get_logo_colour(), "/sports-256.png") ) elif category == "lang": iconImage = __settings__.get_path( "%s%s%s" % ("resources/images/", get_logo_colour(), "/by_language-32.png") ) thumbnailImage = __settings__.get_path( "%s%s%s" % ("resources/images/", get_logo_colour(), "/by_language-256.png") ) elif category == "podcast": iconImage = __settings__.get_path( "%s%s%s" % ("resources/images/", get_logo_colour(), "/podcasts-32.png") ) thumbnailImage = __settings__.get_path( "%s%s%s" % ("resources/images/", get_logo_colour(), "/podcasts-256.png") ) elif category == "video": iconImage = __settings__.get_path("%s%s%s" % ("resources/images/", get_logo_colour(), "/livetv-32.png")) thumbnailImage = __settings__.get_path( "%s%s%s" % ("resources/images/", get_logo_colour(), "/livetv-256.png") ) # Add custom logo for location pattern = re.compile("(.*)id=r(.*)") result = pattern.match(url) if result: iconImage = __settings__.get_path( "%s%s%s" % ("resources/images/", get_logo_colour(), "/by_location-32.png") ) thumbnailImage = __settings__.get_path( "%s%s%s" % ("resources/images/", get_logo_colour(), "/by_location-256.png") ) elif (logo is None or len(logo) == 0) and not isfolder: iconImage = __settings__.get_path("%s%s%s" % ("resources/images/", get_logo_colour(), "/stream-32.png")) thumbnailImage = __settings__.get_path("%s%s%s" % ("resources/images/", get_logo_colour(), "/stream-256.png")) else: iconImage = logo thumbnailImage = logo # Add addons settings context menu. if contextmenu is None: contextmenu = [(__settings__.get_string(1011), "XBMC.RunPlugin(%s?path=refresh)" % __settings__.get_argv(0))] else: contextmenu.append( (__settings__.get_string(1011), "XBMC.RunPlugin(%s?path=refresh)" % __settings__.get_argv(0)) ) liz = xbmcgui.ListItem(name, label, iconImage=iconImage, thumbnailImage=thumbnailImage) liz.addContextMenuItems(items=contextmenu, replaceItems=True) liz.setInfo("Music", {"Title": name, "Artist": artist, "Album": album, "Genre": genre, "Comment": comment}) if not isfolder: liz.setProperty("IsPlayable", "true") if __settings__.get("fanart") == "true": liz.setProperty("fanart_image", __fanart__) xbmcplugin.addDirectoryItem(handle=int(__settings__.get_argv(1)), url=url, listitem=liz, isFolder=isfolder)
def add_topic_outline(topic): log_debug("add_topic_outline", 2) log_debug("topic: %s" % topic, 3) id = utils.get_value(topic, "guide_id") name = utils.get_value(topic, "text") subtext = utils.get_value(topic, "subtext") stream_type = utils.get_value(topic, "stream_type") params = utils.get_params(topic["URL"].split("?")[1]) show_id = utils.get_value(params, "sid") if not __tunein__.is_topic_id(id): return if not __enabledownloads__ and stream_type == "download": return artist = "" comment = "" genre = "" album = "" for show in __showscache__.get(): if "guide_id" in show and show["guide_id"] == show_id: artist = utils.get_value(show, "text") if len(artist) == 0: artist = utils.get_value(show, "hosts") album = utils.get_value(show, "title") comment = utils.get_value(show, "subtext") if len(comment) == 0: comment = utils.get_value(show, "description") genre = get_genre_name(utils.get_value(show, "genre_id")) break url = utils.add_params(__settings__.get_argv(0), {"path": "tune", "id": id, "name": name}) logo = None contextmenu = None if stream_type == "download": contextmenu = [ ( __settings__.get_string(1014), "XBMC.RunPlugin(%s?path=%s&id=%s)" % (__settings__.get_argv(0), "download", id), ) ] logo = __settings__.get_path("%s%s%s" % ("resources/images/", get_logo_colour(), "/downloads-256.png")) add_directory_item( name, url, label=subtext, artist=artist, album=album, comment=comment, genre=genre, logo=logo, isfolder=False, contextmenu=contextmenu, )
# Get addon settings values. __username__ = __settings__.get('username') __password__ = __settings__.get('password') __latlon__ = __settings__.get('latlon') __locale__ = __settings__.get('locale') __iconcolour__ = __settings__.get('iconcolour') __prompt__ = __settings__.get('prompt') == "true" __featured__ = __settings__.get('featured') == "true" __local__ = __settings__.get('local') == "true" __debuglevel__ = __settings__.get('debuglevel') __enabledownloads__ = __settings__.get('enabledownloads') == "true" # Initialise parameters. __params__ = utils.get_params(__settings__.get_argv(2)) __path__ = utils.get_value(__params__, 'path') __id__ = utils.get_value(__params__, 'id') __fanart__ = os.path.join(__settings__.get_path(),'fanart.jpg') if __settings__.get('fanart') == "true": xbmcplugin.setPluginFanart(int(__settings__.get_argv(1)), __fanart__) modtime = __formatscache__.lastupdate() if modtime == None or modtime > (__settings__.get('cacheupdate') * 60 * 60) or len(__formatscache__.get()) == 0: __formatscache__.clear() __formatscache__.add(tunein.TuneIn(__partnerid__).describe_formats()) __formats__ = get_formats() # Initialise tunein. __tunein__ = tunein.TuneIn(__partnerid__, locale=__locale__, formats=__formats__, https=(__settings__.get('https') == "true"), debug=(__debuglevel__ > 0)) modtime = __genrescache__.lastupdate()
# Get addon settings values. __username__ = __settings__.get("username") __password__ = __settings__.get("password") __latlon__ = __settings__.get("latlon") __locale__ = __settings__.get("locale") __iconcolour__ = __settings__.get("iconcolour") __prompt__ = __settings__.get("prompt") == "true" __featured__ = __settings__.get("featured") == "true" __local__ = __settings__.get("local") == "true" __debuglevel__ = __settings__.get("debuglevel") __enabledownloads__ = __settings__.get("enabledownloads") == "true" # Initialise parameters. __params__ = utils.get_params(__settings__.get_argv(2)) __path__ = utils.get_value(__params__, "path") __id__ = utils.get_value(__params__, "id") __fanart__ = os.path.join(__settings__.get_path(), "fanart.jpg") if __settings__.get("fanart") == "true" and int(__settings__.get_argv(1)) != -1: xbmcplugin.setPluginFanart(int(__settings__.get_argv(1)), __fanart__) modtime = __formatscache__.lastupdate() if modtime is None or modtime > (__settings__.get("cacheupdate") * 60 * 60) or len(__formatscache__.get()) == 0: __formatscache__.clear() __formatscache__.add(tunein.TuneIn(__partnerid__).describe_formats()) __formats__ = get_formats() # Get mac address to be used as serial. # Note: function seems to occasionally return 'Busy', so added workaround. mac_address = utils.mac_address() if mac_address == "Busy":
def add_directory_item(name, url, label='', artist='', album='', genre='', comment='', logo=None, isfolder=True, contextmenu=None): log_debug('add_directory_item', 2) log_debug('name: %s' % name, 3) log_debug('url: %s' % url, 3) log_debug('label: %s' % label, 3) log_debug('artist: %s' % artist, 3) log_debug('album: %s' % album, 3) log_debug('genre: %s' % genre, 3) log_debug('comment: %s' % comment, 3) log_debug('logo: %s' % logo, 3) log_debug('isfolder: %s' % isfolder, 3) log_debug('contextmenu: %s' % contextmenu, 3) # If logo argument not set use default directory/stream image. if (logo is None or len(logo) == 0) and isfolder: iconImage = __settings__.get_path('%s%s%s' % ( 'resources/images/', get_logo_colour(), '/folder-32.png')) thumbnailImage = __settings__.get_path('%s%s%s' % ( 'resources/images/', get_logo_colour(), '/folder-256.png')) # Add custom logos for Browse category # pattern = re.compile('(.*)c=(\w+)') # result = pattern.match(url) params = utils.get_params(url.split('?')[1]) category = utils.get_value(params, 'c') if (category): # if result.group(2) == "local": if category == "local": iconImage = __settings__.get_path('%s%s%s' % ( 'resources/images/', get_logo_colour(), '/local-32.png')) thumbnailImage = __settings__.get_path('%s%s%s' % ( 'resources/images/', get_logo_colour(), '/local-256.png')) elif category == "music": iconImage = __settings__.get_path('%s%s%s' % ( 'resources/images/', get_logo_colour(), '/music-32.png')) thumbnailImage = __settings__.get_path('%s%s%s' % ( 'resources/images/', get_logo_colour(), '/music-256.png')) elif category == "talk": iconImage = __settings__.get_path('%s%s%s' % ( 'resources/images/', get_logo_colour(), '/talk-32.png')) thumbnailImage = __settings__.get_path('%s%s%s' % ( 'resources/images/', get_logo_colour(), '/talk-256.png')) elif category == "sports": iconImage = __settings__.get_path('%s%s%s' % ( 'resources/images/', get_logo_colour(), '/sports-32.png')) thumbnailImage = __settings__.get_path('%s%s%s' % ( 'resources/images/', get_logo_colour(), '/sports-256.png')) elif category == "lang": iconImage = __settings__.get_path('%s%s%s' % ( 'resources/images/', get_logo_colour(), '/by_language-32.png')) thumbnailImage = __settings__.get_path('%s%s%s' % ( 'resources/images/', get_logo_colour(), '/by_language-256.png')) elif category == "podcast": iconImage = __settings__.get_path('%s%s%s' % ( 'resources/images/', get_logo_colour(), '/podcasts-32.png')) thumbnailImage = __settings__.get_path('%s%s%s' % ( 'resources/images/', get_logo_colour(), '/podcasts-256.png')) elif category == "video": iconImage = __settings__.get_path('%s%s%s' % ( 'resources/images/', get_logo_colour(), '/livetv-32.png')) thumbnailImage = __settings__.get_path('%s%s%s' % ( 'resources/images/', get_logo_colour(), '/livetv-256.png')) # Add custom logo for location pattern = re.compile('(.*)id=r(.*)') result = pattern.match(url) if (result): iconImage = __settings__.get_path('%s%s%s' % ( 'resources/images/', get_logo_colour(), '/by_location-32.png')) thumbnailImage = __settings__.get_path('%s%s%s' % ( 'resources/images/', get_logo_colour(), '/by_location-256.png')) elif (logo is None or len(logo) == 0) and not isfolder: iconImage = __settings__.get_path('%s%s%s' % ( 'resources/images/', get_logo_colour(), '/stream-32.png')) thumbnailImage = __settings__.get_path('%s%s%s' % ( 'resources/images/', get_logo_colour(), '/stream-256.png')) else: iconImage = logo thumbnailImage = logo # Add addons settings context menu. if contextmenu is None: contextmenu = [(__settings__.get_string( 1011), 'XBMC.RunPlugin(%s?path=refresh)' % __settings__.get_argv(0))] else: contextmenu.append((__settings__.get_string( 1011), 'XBMC.RunPlugin(%s?path=refresh)' % __settings__.get_argv(0))) liz = xbmcgui.ListItem(name, label, iconImage=iconImage, thumbnailImage=thumbnailImage) liz.addContextMenuItems(items=contextmenu, replaceItems=True) liz.setInfo('Music', {'Title': name, 'Artist': artist, 'Album': album, 'Genre': genre, 'Comment': comment}) if not isfolder: liz.setProperty('IsPlayable', 'true') if __settings__.get('fanart') == "true": liz.setProperty('fanart_image', __fanart__) xbmcplugin.addDirectoryItem(handle=int( __settings__.get_argv(1)), url=url, listitem=liz, isFolder=isfolder)
def add_topic_outline(topic): log_debug('add_topic_outline', 2) log_debug('topic: %s' % topic, 3) id = utils.get_value(topic, 'guide_id') name = utils.get_value(topic, 'text') subtext = utils.get_value(topic, 'subtext') stream_type = utils.get_value(topic, 'stream_type') params = utils.get_params(topic['URL'].split('?')[1]) show_id = utils.get_value(params, 'sid') if not __tunein__.is_topic_id(id): return if not __enabledownloads__ and stream_type == 'download': return artist = '' comment = '' genre = '' album = '' for show in __showscache__.get(): if 'guide_id' in show and show['guide_id'] == show_id: artist = utils.get_value(show, 'text') if len(artist) == 0: artist = utils.get_value(show, 'hosts') album = utils.get_value(show, 'title') comment = utils.get_value(show, 'subtext') if len(comment) == 0: comment = utils.get_value(show, 'description') genre = get_genre_name(utils.get_value(show, 'genre_id')) break url = utils.add_params( __settings__.get_argv(0), {'path': 'tune', 'id': id, 'name': name}) logo = None contextmenu = None if stream_type == 'download': contextmenu = [(__settings__.get_string(1014), 'XBMC.RunPlugin(%s?path=%s&id=%s)' % ( __settings__.get_argv(0), 'download', id))] logo = __settings__.get_path('%s%s%s' % ( 'resources/images/', get_logo_colour(), '/downloads-256.png')) add_directory_item(name, url, label=subtext, artist=artist, album=album, comment=comment, genre=genre, logo=logo, isfolder=False, contextmenu=contextmenu)