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': 'kodi-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_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_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(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': 'kodi-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_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)
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_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_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)
log_debug('Addon: %s' % __addonname__, 1) log_debug('Version: %s' % __version__, 1) log_debug('Params: %s: %s' % (__path__, __params__), 1) __overcast__ = overcast.Overcast() if __path__ == 'podcast': for episode in __overcast__.episodes(__url__): liz = xbmcgui.ListItem(episode['title'], iconImage=episode['artworkURL'], thumbnailImage=episode['artworkURL']) u = utils.add_params(root=__settings__.get_argv(0), params={ 'path': 'episode', 'url': episode['url'] }) ok = xbmcplugin.addDirectoryItem(handle=int(__settings__.get_argv(1)), url=u, listitem=liz, isFolder=False) xbmcplugin.endOfDirectory(int(__settings__.get_argv(1))) # Play an episode elif __path__ == 'episode': episode = __overcast__.episode(__url__) liz = xbmcgui.ListItem(episode['title'], iconImage=episode['artworkURL'], thumbnailImage=episode['artworkURL']) liz.setInfo('music', {
download = (topic[0], result[1]) __downloadscache__.add(download) else: utils.ok(__addonname__, __settings__.get_string( 3015), __settings__.get_string(3010)) # Refresh display. elif __path__ == 'refresh': xbmc.executebuiltin('Container.Refresh') # Add station/show to Kodi favourites. elif __path__ == 'kodi-favourites': log_debug('Adding %s to Kodi favourites' % utils.get_value(__params__, 'name'), 1) name = utils.get_value(__params__, 'name') logo = utils.get_value(__params__, 'logo') command = 'PlayMedia(\"%s\")' % (utils.add_params(root='plugin://%s/' % (__addonid__), params={'logo': logo, 'path': 'tune', 'id': utils.get_value(__params__, 'id'), 'name': name})) if not utils.add_to_favourites(name, logo, command): utils.ok(__addonname__, __settings__.get_string(3017)) # Display main menu. else: __showscache__.clear() if __onlyfavourites__: # Display users presets. if __username__ is None or len(__username__) == 0: utils.ok(__addonname__, __settings__.get_string( 3001), __settings__.get_string(3002)) else: results = __tunein__.browse_presets(username=__username__) process_tunein_json(results)