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()) traceback.print_exc()
from xbmcswift2 import xbmc, xbmcgui, Plugin from resources.lib.mubi import Mubi PLUGIN_NAME = 'MUBI' PLUGIN_ID = 'plugin.video.mubi' plugin = Plugin(PLUGIN_NAME, PLUGIN_ID, __file__) if not plugin.get_setting("username"): plugin.open_settings() mubi = Mubi() mubi.login(plugin.get_setting("username", unicode), plugin.get_setting("password", unicode)) @plugin.route('/') def index(): films = mubi.now_showing() items = [{ 'label': film.title, 'is_playable': True, 'path': plugin.url_for('play_film', identifier=film.mubi_id), 'thumbnail': film.artwork, 'info': film.metadata._asdict() } for film in films] return items @plugin.route('/play/<identifier>') def play_film(identifier): return plugin.set_resolved_url(mubi.get_play_url(identifier))