from resources.lib.client import Client from resources.lib import items from resources.lib.common import * client = Client() def run(): if mode == 'rails': items.rails_items(client.rails(id,params)) elif mode == 'rail': items.rail_items(client.rail(id,params)) elif mode == 'play': items.playback(client.playback(id)) elif mode == 'play_context': items.play_context(client.playback(id), title) args = urlparse.parse_qs(sys.argv[2][1:]) mode = args.get('mode', ['rails'])[0] title = args.get('title', [''])[0] id = args.get('id', ['home'])[0] params = args.get('params', [''])[0] if not args: args = version log('[%s] arguments: %s' % (addon_id, str(args))) if id == 'home': client.startUp() if client.TOKEN: run() else: run()
client = Client() def run(): if mode == 'rails': dazn.rails_items(client.rails(id, params)) elif mode == 'rail': dazn.rail_items(client.rail(id, params)) elif mode == 'play': dazn.playback(client.playback(id)) elif mode == 'play_context': dazn.play_context(client.playback(id), title) args = urlparse.parse_qs(sys.argv[2][1:]) mode = args.get('mode', ['rails'])[0] title = args.get('title', [''])[0] id = args.get('id', ['home'])[0] params = args.get('params', [''])[0] if not args: args = version log('[%s] arguments: %s' % (addon_id, str(args))) if id == 'home': if uniq_id(): client.startUp() if client.TOKEN: run() else: run()
sys.exit(0) elif mode == 'is_settings': plugin.open_is_settings() else: sys.exit(0) if __name__ == '__main__': if plugin.get_setting('save_login') == 'false' and credential.has_credentials(): credential.clear_credentials() if plugin.startup or not client.TOKEN: startup_data = client.initStartupData() endpoint_dict = plugin.init_api_endpoints(startup_data.get('ServiceDictionary')) client.initApiEndpoints(endpoint_dict) region = client.initRegion(startup_data) playable = plugin.start_is_helper() client.DEVICE_ID = plugin.uniq_id() if client.DEVICE_ID and playable: client.startUp(region) if client.TOKEN: plugin.set_setting('startup', 'false') client.userProfile() else: client.TOKEN = '' if client.TOKEN and client.DEVICE_ID: router(sys.argv[2][1:]) else: sys.exit(0)