}, 'path': plugin.url_for( endpoint='play_movie', stream_path=item['stream_path'] ), 'is_playable': True } for item in category_items] return items items = get_movies(category_id) finish_kwargs = {} if plugin.get_setting('force_viewmode') == 'true': finish_kwargs['view_mode'] = 'thumbnail' return plugin.finish(items, **finish_kwargs) @plugin.route('/movie/<stream_path>/') def play_movie(stream_path): if plugin.get_setting('use_rtmp') == 'true': stream_url = api.get_rtmp_url(stream_path) else: stream_url = api.get_stream_url(stream_path) return plugin.set_resolved_url(stream_url) if __name__ == '__main__': try: plugin.run() except NetworkError: plugin.log.error(NetworkError) plugin.notify(msg=plugin.get_string('30200'))
helpers = Helpers(plugin) try: from rhapsody import exceptions rhapsody = helpers.get_api() rhapsody.ENABLE_DEBUG = plugin.get_setting('api_debug', converter=bool) rhapsody.ENABLE_CACHE = not plugin.get_setting('api_cache_disable', converter=bool) if not rhapsody.ENABLE_DEBUG and not rhapsody.ENABLE_CACHE: rhapsody.ENABLE_CACHE = True plugin.set_setting('api_cache_disable', '0') plugin.run() except exceptions.AuthenticationError: plugin.notify(_(30100).encode('utf-8')) plugin.open_settings() except exceptions.RequestError: plugin.notify(_(30103).encode('utf-8')) plugin.log.error(sys.stdout.getvalue()) except exceptions.ResourceNotFoundError: plugin.notify(_(30104).encode('utf-8')) plugin.log.error(sys.stdout.getvalue()) except exceptions.ResponseError: plugin.notify(_(30105).encode('utf-8')) plugin.log.error(sys.stdout.getvalue()) except exceptions.StreamingRightsError: plugin.notify(_(30106).encode('utf-8')) plugin.log.error(sys.stdout.getvalue()) except IOError as e: plugin.log.error(sys.stdout.getvalue())
plugin.set_setting("language", "1") elif xbmc_language.startswith("french"): plugin.set_setting("language", "2") else: plugin.open_settings() plugin.set_setting("not_first_run", "1") lang_id = plugin.get_setting("language") or 0 return ("english", "german", "french")[int(lang_id)] def __log(text): plugin.log.info(text) def _(string_id): if string_id in STRINGS: return plugin.get_string(STRINGS[string_id]) else: __log("String is missing: %s" % string_id) return string_id if __name__ == "__main__": radio_api.set_language(__get_language()) radio_api.log = __log migrate_my_stations() try: plugin.run() except RadioApiError: plugin.notify(msg=_("network_error"))
else: msg = _('video_url_not_found') raise Exception(msg) def __is_resolved(url): return (url and isinstance(url, basestring)) def __resolve_item(url, title): import urlresolver media = urlresolver.HostedMediaFile(url=url, title=title) return media.resolve() ############################################### def get_args(arg_name, default=None): return plugin.request.args.get(arg_name, [default])[0] if __name__ == '__main__': try: plugin.run() except Exception, e: print e plugin.log.error(e) plugin.notify(msg=e, delay=8000)
if media: plugin.set_resolved_url(media) else: msg = ['cannot play video stream'] plugin.log.error(msg[0]) dialog = xbmcgui.Dialog() dialog.ok(api.LONG_NAME, *msg) else: msg = ['video url not found'] plugin.log.error(msg[0]) dialog = xbmcgui.Dialog() dialog.ok(api.LONG_NAME, *msg) def __resolve_item(url, title): import urlresolver media = urlresolver.HostedMediaFile(url=url, title=title) return media.resolve() ############################################### if __name__ == '__main__': try: plugin.run() except Exception, e: print e plugin.log.error(e) plugin.notify(msg=e)
plugin = Plugin() my_stations = plugin.get_storage('my_stations.json', file_format='json') found = False if plugin.get_setting('autostart', bool): for station in my_stations.values(): if 'autostart' in station: found = True plugin.log.info("Play startup radio station: %s" % station['name']) listitem = xbmcgui.ListItem(station['name']) listitem.setArt({'thumb': station['thumbnail']}) listitem.setRating("radio.de", float(station.get('rating', '0.0'))) listitem.setInfo( 'music', { 'title': station['name'], 'genre': station['genre'], 'size': station['bitrate'], 'comment': station['current_track'] }) xbmc.Player().play(item=station['stream_url'], listitem=listitem) if not found: plugin.notify(plugin.get_string( Strings['no-station-notification']).encode('utf-8'), delay=25000, image=plugin.addon.getAddonInfo('path') + "/icon.png")
plugin = Plugin() @plugin.route('/') def show_root(): videos = scraper.get_videos() shuffle(videos) items = [{ 'label': u'%s - %s' % (video['interpret'], video['title']), 'thumbnail': video['thumb'], 'is_playable': True, 'path': plugin.url_for('play_video', video_url=video['video_url']) } for video in videos] finish_kwargs = {} if plugin.get_setting('force_viewmode', bool): finish_kwargs['view_mode'] = 'thumbnail' return plugin.finish(items, **finish_kwargs) @plugin.route('/play/<video_url>') def play_video(video_url): return plugin.set_resolved_url(video_url) if __name__ == '__main__': try: plugin.run() except scraper.NetworkError: plugin.notify(plugin.get_string(30020))
) country = None xbmc_language = xbmc.getLanguage().lower() for lang, country_code in lang_country_mapping: if xbmc_language.startswith(lang): country = country_code plugin.set_setting('country', country) break if not country: plugin.open_settings() country = plugin.get_setting('country') or 'US' plugin.set_setting('country_already_set', '1') return country def _(string_id): if string_id in STRINGS: return plugin.get_string(STRINGS[string_id]) else: plugin.log.warning('String is missing: %s' % string_id) return string_id if __name__ == '__main__': country = __get_country() api.set_country(country=country) try: plugin.run() except NetworkError: plugin.notify(msg=_('network_error'))
kwargs = { 'update_listing': 'update' in plugin.request.args, 'view_mode': 'thumbnail' if force_thumbnail else None, } return plugin.finish(items, **kwargs) def get_cached(func, *args, **kwargs): '''Return the result of func with the given args and kwargs from cache or execute it if needed''' @plugin.cached(kwargs.pop('TTL', 1440)) def wrap(func_name, *args, **kwargs): return func(*args, **kwargs) return wrap(func.__name__, *args, **kwargs) def _(string_id): if string_id in STRINGS: return plugin.get_string(STRINGS[string_id]) else: plugin.log.warning('String is missing: %s' % string_id) return string_id if __name__ == '__main__': try: plugin.run() except cheez_api.NetworkError: plugin.notify(title=__addon_name__, msg=_('network_error'))
@plugin.route('/') def show_root(): videos = scraper.get_videos() shuffle(videos) items = [{ 'label': u'%s - %s' % (video['interpret'], video['title']), 'thumbnail': video['thumb'], 'is_playable': True, 'path': plugin.url_for( 'play_video', video_url=video['video_url'] ) } for video in videos] finish_kwargs = {} if plugin.get_setting('force_viewmode', bool): finish_kwargs['view_mode'] = 'thumbnail' return plugin.finish(items, **finish_kwargs) @plugin.route('/play/<video_url>') def play_video(video_url): return plugin.set_resolved_url(video_url) if __name__ == '__main__': try: plugin.run() except scraper.NetworkError: plugin.notify(plugin.get_string(30020))
'path': plugin.url_for(endpoint='play_movie', stream_path=item['stream_path']), 'is_playable': True } for item in category_items] return items items = get_movies(category_id) finish_kwargs = {} if plugin.get_setting('force_viewmode') == 'true': finish_kwargs['view_mode'] = 'thumbnail' return plugin.finish(items, **finish_kwargs) @plugin.route('/movie/<stream_path>/') def play_movie(stream_path): if plugin.get_setting('use_rtmp') == 'true': stream_url = api.get_rtmp_url(stream_path) else: stream_url = api.get_stream_url(stream_path) return plugin.set_resolved_url(stream_url) if __name__ == '__main__': try: plugin.run() except NetworkError: plugin.log.error(NetworkError) plugin.notify(msg=plugin.get_string('30200'))
{ 'title': channel.name[:15], 'tvshowtitle': titleandtime, 'duration': channel.v_nowduration, 'plot': channel.v_nowdescription, 'plotoutline': channel.v_nowdescription, 'tagline': channel.nowstarttimeandtitle(), 'playcount': 0, #'cast': channel.v_nowactors, 'fanart': channel.v_nowfanart, 'extrafanart': channel.v_nowposter, 'originaltitle': channel.v_nowtitle, 'year': channel.v_nowyear, 'album': titleandtime, # I used album 'cause I haven't found another field to display label2 'genre': channel.v_nowgenre }) item.add_context_menu_items(create_context_menu(channel.name, adapter, channel.channelid), replace_items=True) item.add_stream_info('video', {'duration': try_parse_int(channel.v_nowduration) * 60, 'plot': channel.v_nowdescription}) return item if __name__ == '__main__': try: plugin.run() except TVSError: plugin.notify(msg=TVSError.message) except: plugin.log.error(str(sys.exc_info()[0].__name__) + ': ' + str(sys.exc_info()[1])) sys.modules.clear()
'label': video['title'], 'thumbnail': video['thumb'], 'is_playable': True, 'path': plugin.url_for( endpoint = 'play_video', video_id = video['id'] ) } for video in videos]) if next_page != '-1': items.append({ 'label' : _('next_page') % ( next_page ), 'path' : plugin.url_for( endpoint = 'show_videos', page = next_page, update = 'true' ) }) return items @plugin.route('/video/<video_id>') def play_video(video_id): youtube_id = scraper.get_youtube_id(video_id) if youtube_id == '': return plugin.set_resolved_url(YOUTUBE_CMD_PATTERN % youtube_id) def _(string_id): if string_id in STRINGS: return plugin.get_string(STRINGS[string_id]) else: plugin.log.warning('String is missing: %s' % string_id) return string_id if __name__ == '__main__': try: plugin.run() except NetworkError: plugin.notify(msg='Network error')
plugin.set_resolved_url(media) else: msg = ["cannot play video stream"] plugin.log.error(msg[0]) dialog = xbmcgui.Dialog() dialog.ok(api.LONG_NAME, *msg) else: msg = ["video url not found"] plugin.log.error(msg[0]) dialog = xbmcgui.Dialog() dialog.ok(api.LONG_NAME, *msg) def __resolve_item(url, title): import urlresolver media = urlresolver.HostedMediaFile(url=url, title=title) return media.resolve() ############################################### if __name__ == "__main__": try: plugin.run() except Exception, e: print e plugin.log.error(e) plugin.notify(msg=e)
themes[group['themeId']]['clips'] = [] themes[group['themeId']]['clips'].append(group); return themes def load_themes(): xml = fetch_videos_xml() themes_and_clips = parse_themes_xml(xml) return themes_and_clips def fetch_video_info(video_id): log("fetch_video_info") response = urllib2.urlopen("http://tv.lrytas.lt/?id=" + video_id) html = response.read() video_url = re.search('href="(http.+mp4)"', html).group(1) video_title = re.search('<h1[^>]*>([^<]+)</h1>', html).group(1) img_id = re.search('rel\="image_src" href\=.+img\.lrytas\.lt/show_foto/\?id=(\d+)', html).group(1) return video_url, video_title, img_id def get_img_src(img_id): return "http://img.lrytas.lt/show_foto/?id=%s&s=5&f=5" % (img_id) if __name__ == '__main__': try: plugin.run() except Exception, err: plugin.notify(msg='Could not load the plugin.') log(err) # log(traceback.format_exc())
items = [ { 'label': station.name, 'path': plugin.url_for('play', api_id=station.api_id), } for station in api.get_stations() ] return plugin.finish(items) @plugin.route('/play/<api_id>') def play(api_id): station = api.get_station(api_id) items = [ { 'label': '{station} ({url})'.format(station=station.name, url=source), 'thumbnail': station.thumbnail, 'path': source, 'is_playable': True, } for source in station.get_sources() ] return plugin.finish(items) if __name__ == '__main__': try: plugin.run() except ApiError: plugin.notify('Network error')
else: plugin.open_settings() plugin.set_setting('not_first_run', '1') lang_id = plugin.get_setting('language') or 0 return ('english', 'german', 'french')[int(lang_id)] def __log(text): xbmc.log('%s plugin: %s' % (__addon_name__, repr(text))) def __log_api(text): xbmc.log('%s api: %s' % (__addon_name__, repr(text))) def _(string_id): if string_id in STRINGS: return plugin.get_string(STRINGS[string_id]) else: __log('String is missing: %s' % string_id) return string_id if __name__ == '__main__': language = __get_language() radio_api = RadioApi(language=language, user_agent='XBMC Addon Radio') radio_api.log = __log_api try: plugin.run() except RadioApiError: plugin.notify(title=__addon_name__, msg=_('network_error'))
msg = _('video_url_not_found') raise Exception(msg) def __is_resolved(url): return (url and isinstance(url, basestring)) def __resolve_item(url, title): import urlresolver media = urlresolver.HostedMediaFile( url=url, title=title) return media.resolve() ############################################### def get_args(arg_name, default=None): return plugin.request.args.get(arg_name, [default])[0] if __name__ == '__main__': try: plugin.run() except Exception, e: print e plugin.log.error(e) plugin.notify(msg=e, delay=8000)
filedata = f.read().split('\n')[0].split(':') if len(filedata) < 2: return username, password = filedata[:2] plugin.set_setting('ip', '127.0.0.1') plugin.set_setting('port', '58846') plugin.set_setting('username', username) plugin.set_setting('password', password) def check_config(): try: client = get_client() client.call('core.get_free_space') except: return False else: return True if __name__ == '__main__': if not plugin.get_setting('first_run_done', str): plugin.set_setting('first_run_done', 'run') do_first_run() if not check_config(): plugin.notify('Unable to connect to Deluge') plugin.open_settings() else: plugin.run()
__log('__get_language has first run with xbmc_language=%s' % xbmc_language) for i, lang in enumerate(languages): if xbmc_language.lower().startswith(lang): plugin.set_setting('language', str(i)) __log('__get_language detected: %s' % languages[i]) break plugin.set_setting('not_first_run', '1') return plugin.get_setting('language', choices=languages) def __log(text): plugin.log.info(text) def _(string_id): if string_id in STRINGS: return plugin.get_string(STRINGS[string_id]) else: __log('String is missing: %s' % string_id) return string_id if __name__ == '__main__': radio_api.set_language(__get_language()) radio_api.log = __log try: plugin.run() except RadioApiError: plugin.notify(msg=_('network_error'))
pool = ThreadPool(processes=2) stream_result = pool.apply_async(lambda: rhapsody.streams.detail(track_id)) if thumbnail_missing: album_result = pool.apply_async(lambda: rhapsody.albums.detail(album_id)) album = album_result.get() item['thumbnail'] = album.images[0].get_url(size=Image.SIZE_ORIGINAL) stream = stream_result.get() item['path'] = stream.url plugin.set_resolved_url(item) started = rhapsody.events.log_playstart(track_id, stream) rhapsody.events.log_playstop(track_id, stream, started, duration) pool.close() pool.join() if __name__ == '__main__': try: plugin.run() except exceptions.RequestError: plugin.notify(_(30103).encode('utf-8')) except exceptions.ResourceNotFoundError: plugin.notify(_(30104).encode('utf-8')) except exceptions.ResponseError: plugin.notify(_(30105).encode('utf-8')) except exceptions.StreamingRightsError: plugin.notify(_(30106).encode('utf-8'))