def groups_menu(type, **kwargs): if type == 'tv': typestr = 'TV ' else: typestr = 'Radio ' folder = plugin.Folder(title=typestr + _.GROUPS) groups = load_file(type + '_groups.json', ext=False, isJSON=True) if not groups: groups = [] else: groups = list(groups) folder.add_item(label=_(_.ADD_GROUP, _bold=True), path=plugin.url_for(func_or_url=add_group, type=type)) for entry in groups: folder.add_item(label=_(entry, _bold=True), path=plugin.url_for(func_or_url=remove_group, type=type, name=entry)) return folder
def radio_order_picker_menu(double=None, primary=None, **kwargs): save_all_radio_order(double=double, primary=primary) folder = plugin.Folder(title=_.SELECT_ORDER) desc2 = _.NEXT_SETUP_IPTV folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=simple_iptv_menu)) prefs = load_radio_prefs(profile_id=1) order = load_radio_order(profile_id=1) if order: for currow in order: row = prefs[currow] if int(row['radio']) == 0: continue label = _(row['name'] + ": " + unicode(order[unicode(currow)]), _bold=True) folder.add_item( label=label, path=plugin.url_for(func_or_url=change_radio_order, id=currow), playable=False, ) folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=simple_iptv_menu)) return folder
def primary(addons, **kwargs): folder = plugin.Folder(title=_.SELECT_PRIMARY) addons = json.loads(addons) desc = _.SELECT_PRIMARY_DESC desc2 = _.SKIP_DESC for entry in addons: folder.add_item(label=_(entry['label'], _bold=True), info={'plot': desc}, path=plugin.url_for(func_or_url=alternative, num=1, addon=entry['addonid'], addons=json.dumps(addons))) profile_settings = load_profile(profile_id=1) try: if len(profile_settings['addon1']) > 0: folder.add_item(label=_(_.SKIP, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=radio_select, num=6)) except: pass return folder
def home(**kwargs): api_get_channels() folder = plugin.Folder(title='Installed Addons') installed = False loggedin = False addons = [] desc = _.ADDON_NOT_INSTALLED_DESC desc2 = _.NO_ADDONS_ENABLED_DESC desc3 = _.RESET_SETTINGS_DESC desc4 = _.ADDON_NOT_LOGGEDIN_DESC desc5 = _.ADDON_ENABLED_DESC desc6 = _.ADDONS_CONTINUE_DESC for entry in CONST_ADDONS: if check_addon(addon=entry['addonid']): if check_loggedin(addon=entry['addonid']): color = 'green' loggedin = True addons.append(entry) folder.add_item(label=_(entry['label'], _bold=True, _color=color), info={'plot': desc5}, path=plugin.url_for(func_or_url=home)) else: color = 'orange' folder.add_item(label=_(entry['label'], _bold=True, _color=color), info={'plot': desc4}, path=plugin.url_for(func_or_url=home)) installed = True else: color = 'red' folder.add_item(label=_(entry['label'], _bold=True, _color=color), info={'plot': desc}, path=plugin.url_for(func_or_url=home)) if installed == True and loggedin == True: folder.add_item(label=_.NEXT, info={'plot': desc6}, path=plugin.url_for(func_or_url=primary, addons=json.dumps(addons))) else: folder.add_item(label=_.NO_ADDONS_ENABLED, info={'plot': desc2}, path=plugin.url_for(func_or_url=home)) folder.add_item(label=_.RESET_SETTINGS, info={'plot': desc3}, path=plugin.url_for(func_or_url=reset_settings)) return folder
def simple_iptv_menu(**kwargs): folder = plugin.Folder(title=_.SETUP_IPTV) desc = _.SETUP_IPTV_FINISH_DESC desc2 = _.SKIP_IPTV_FINISH_DESC folder.add_item(label=_(_.SETUP_IPTV_FINISH, _bold=True), info={'plot': desc}, path=plugin.url_for(func_or_url=finish_setup, setup=1)) folder.add_item(label=_(_.SKIP_IPTV_FINISH, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=finish_setup, setup=0)) return folder
def live_channel_picker_menu(save_all=0, radio=None, **kwargs): save_all = int(save_all) if not radio == None: radio = int(radio) profile_settings = load_profile(profile_id=1) profile_settings['radio'] = radio save_profile(profile_id=1, profile=profile_settings) if save_all == 1: save_all_live_prefs() folder = plugin.Folder(title=_.SELECT_LIVE) desc2 = _.NEXT_SETUP_REPLAY folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=replay_channel_picker_menu, save_all=1)) prefs = load_prefs(profile_id=1) if prefs: for currow in prefs: row = prefs[currow] if row['live'] == 1: color = 'green' addon_type = row['live_addonid'].replace('plugin.video.', '') else: color = 'red' addon_type = _.DISABLED label = _(row['name'] + ": " + addon_type, _bold=True, _color=color) folder.add_item( label=label, path=plugin.url_for(func_or_url=change_live_channel, id=currow), playable=False, ) folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=replay_channel_picker_menu, save_all=1)) return folder
def channel_picker(type, **kwargs): if type=='live': title = _.LIVE_TV rows = get_live_channels(all=True) elif type=='replay': title = _.CHANNELS rows = get_replay_channels(all=True) folder = plugin.Folder(title=title) prefs = load_prefs(profile_id=1) type = unicode(type) for row in rows: id = unicode(row['channel']) if not prefs or not check_key(prefs, id) or prefs[id][type] == 1: color = 'green' else: color = 'red' label = _(unicode(row['label']), _bold=True, _color=color) folder.add_item( label = label, art = {'thumb': unicode(row['image'])}, path = plugin.url_for(func_or_url=change_channel, type=type, id=id, change=0), playable = False, ) return folder
def alternative(num, addon, addons, **kwargs): num = int(num) profile_settings = load_profile(profile_id=1) profile_settings['addon' + str(num)] = addon save_profile(profile_id=1, profile=profile_settings) folder = plugin.Folder(title=_.SELECT_SECONDARY) addons = json.loads(addons) addons2 = [] desc = _.SELECT_SECONDARY_DESC for entry in addons: if not entry['addonid'] == addon: addons2.append(entry) for entry in addons2: folder.add_item(label=_(entry['label'], _bold=True), info={'plot': desc}, path=plugin.url_for(func_or_url=alternative, num=num + 1, addon=entry['addonid'], addons=json.dumps(addons2))) folder.add_item(label=_.DONE, info={'plot': desc}, path=plugin.url_for(func_or_url=radio_select, num=num + 1)) return folder
def display(self): handle = _handle() items = [i for i in self.items if i] if not items and self.no_items_label: items.append( Item( label=_(self.no_items_label, _label=True), is_folder=False, )) for item in items: item.art['thumb'] = item.art.get('thumb') or self.thumb item.art['fanart'] = item.art.get('fanart') or self.fanart li = item.get_li() xbmcplugin.addDirectoryItem(handle, item.path, li, item.is_folder) if self.content: xbmcplugin.setContent(handle, self.content) if self.title: xbmcplugin.setPluginCategory(handle, self.title) for sort_method in self.sort_methods: xbmcplugin.addSortMethod(handle, sort_method) xbmcplugin.endOfDirectory(handle, succeeded=True, updateListing=self.updateListing, cacheToDisc=self.cacheToDisc)
def order_picker_menu(type_tv_radio, double=None, primary=None, **kwargs): type_tv_radio = str(type_tv_radio) save_all_order(type_tv_radio=type_tv_radio, double=double, primary=primary) folder = plugin.Folder(title=_.SELECT_ORDER) desc2 = _.NEXT_SETUP_GROUPS folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=group_picker_menu, type_tv_radio=type_tv_radio)) if type_tv_radio == 'live': prefs = load_prefs(profile_id=1) order = load_order(profile_id=1) else: prefs = load_radio_prefs(profile_id=1) order = load_radio_order(profile_id=1) if order: for currow in order: row = prefs[currow] if int(row[type_tv_radio]) == 0: continue label = _(row['name'] + ": " + str(order[str(currow)]), _bold=True) folder.add_item( label=label, path=plugin.url_for(func_or_url=change_order, id=currow, type_tv_radio=type_tv_radio), playable=False, ) desc2 = _.NEXT_SETUP_GROUPS folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=group_picker_menu, type_tv_radio=type_tv_radio)) return folder
def replay_channel_picker_menu(save_all=0, **kwargs): save_all = int(save_all) if save_all == 1: save_all_replay_prefs() folder = plugin.Folder(title=_.SELECT_REPLAY) desc2 = _.NEXT_SETUP_ORDER folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=tv_order_picker_menu)) prefs = load_prefs(profile_id=1) if prefs: for currow in prefs: row = prefs[currow] if row['replay'] == 1: color = 'green' addon_type = row['replay_addonid'].replace('plugin.video.', '') else: color = 'red' addon_type = _.DISABLED label = _(row['name'] + ": " + addon_type, _bold=True, _color=color) folder.add_item( label=label, path=plugin.url_for(func_or_url=change_replay_channel, id=currow), playable=False, ) folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=tv_order_picker_menu)) return folder
def home(**kwargs): clear_old() check_first() profile_settings = load_profile(profile_id=1) folder = plugin.Folder() if profile_settings and check_key(profile_settings, 'pswd') and len(profile_settings['pswd']) > 0: folder.add_item(label=_(_.LIVE_TV, _bold=True), path=plugin.url_for(func_or_url=live_tv)) folder.add_item(label=_(_.CHANNELS, _bold=True), path=plugin.url_for(func_or_url=replaytv)) if settings.getBool('showMoviesSeries'): for vod_entry in CONST_VOD_CAPABILITY: folder.add_item(label=_(vod_entry['label'], _bold=True), path=plugin.url_for(func_or_url=vod, file=vod_entry['file'], label=vod_entry['label'], start=vod_entry['start'], online=vod_entry['online'], split=vod_entry['split'])) if CONST_WATCHLIST: folder.add_item(label=_(_.WATCHLIST, _bold=True), path=plugin.url_for(func_or_url=watchlist)) folder.add_item(label=_(_.SEARCH, _bold=True), path=plugin.url_for(func_or_url=search_menu)) folder.add_item(label=_(_.LOGIN, _bold=True), path=plugin.url_for(func_or_url=login)) folder.add_item(label=_.SETTINGS, path=plugin.url_for(func_or_url=settings_menu)) return folder
def radio_channel_picker_menu(save_all=0, **kwargs): save_all = int(save_all) if save_all == 1: save_all_radio_prefs() folder = plugin.Folder(title=_.SELECT_RADIO) desc2 = _.NEXT_SETUP_ORDER folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=radio_order_picker_menu)) prefs = load_radio_prefs(profile_id=1) if prefs: for currow in prefs: row = prefs[currow] if row['radio'] == 1: color = 'green' else: color = 'red' label = _(row['name'], _bold=True, _color=color) folder.add_item( label=label, path=plugin.url_for(func_or_url=change_radio_channel, id=currow), playable=False, ) folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=radio_order_picker_menu)) return folder
def _error(e): try: error = str(e) except: error = e.message.encode('utf-8') if not hasattr(e, 'heading') or not e.heading: e.heading = _(_.PLUGIN_ERROR, addon=ADDON_NAME) log.error(error) _close() gui.ok(error, heading=e.heading) resolve()
def search_menu(**kwargs): folder = plugin.Folder(title=_.SEARCHMENU) label = _.NEWSEARCH folder.add_item( label = label, info = {'plot': _.NEWSEARCHDESC}, path = plugin.url_for(func_or_url=search), ) if CONST_ONLINE_SEARCH: folder.add_item( label= label + " (Online)", path=plugin.url_for(func_or_url=online_search) ) profile_settings = load_profile(profile_id=1) for x in range(1, 10): try: if check_key(profile_settings, 'search' + unicode(x)): searchstr = profile_settings['search' + unicode(x)] else: searchstr = '' if searchstr != '': label = unicode(searchstr) path = plugin.url_for(func_or_url=search, query=searchstr) if CONST_ONLINE_SEARCH: if check_key(profile_settings, 'search_type' + unicode(x)): type = profile_settings['search_type' + unicode(x)] else: type = 0 if type == 1: label = unicode(searchstr) + ' (Online)' path = plugin.url_for(func_or_url=online_search, query=searchstr) folder.add_item( label = label, info = {'plot': _(_.SEARCH_FOR, query=searchstr)}, path = path, ) except: pass return folder
def search(query=None, **kwargs): items = [] if not query: query = gui.input(message=_.SEARCH, default='').strip() if not query: return profile_settings = load_profile(profile_id=1) for x in reversed(range(2, 10)): if check_key(profile_settings, 'search' + unicode(x - 1)): profile_settings['search' + unicode(x)] = profile_settings['search' + unicode(x - 1)] else: profile_settings['search' + unicode(x)] = '' profile_settings['search1'] = query if CONST_ONLINE_SEARCH: for x in reversed(range(2, 10)): if check_key(profile_settings, 'search_type' + unicode(x - 1)): profile_settings['search_type' + unicode(x)] = profile_settings['search_type' + unicode(x - 1)] else: profile_settings['search_type' + unicode(x)] = 0 profile_settings['search_type1'] = 0 save_profile(profile_id=1, profile=profile_settings) else: query = unicode(query) folder = plugin.Folder(title=_(_.SEARCH_FOR, query=query)) processed = process_replaytv_search(search=query) items += processed['items'] if settings.getBool('showMoviesSeries'): for vod_entry in CONST_VOD_CAPABILITY: processed = process_vod_content(data=vod_entry['file'], start=vod_entry['start'], search=query, type=vod_entry['label'], online=vod_entry['online']) items += processed['items'] items[:] = sorted(items, key=_sort_replay_items, reverse=True) items = items[:25] folder.add_items(items) return folder
def exception(heading=None): if not heading: heading = _(_.PLUGIN_EXCEPTION, addon=ADDON_NAME) exc_type, exc_value, exc_traceback = sys.exc_info() tb = [] for trace in reversed(traceback.extract_tb(exc_traceback)): if ADDON_ID in trace[0]: trace = list(trace) trace[0] = trace[0].split(ADDON_ID)[1] tb.append(trace) error = '{}\n{}'.format(''.join(traceback.format_exception_only(exc_type, exc_value)), ''.join(traceback.format_list(tb))) text(error, heading=heading)
def replaytv_item(label=None, idtitle=None, start=0, **kwargs): start = int(start) folder = plugin.Folder(title=label) processed = process_replaytv_list_content(label=label, idtitle=idtitle, start=start) if check_key(processed, 'items'): folder.add_items(processed['items']) if check_key(processed, 'total') and check_key(processed, 'count2') and processed['total'] > processed['count2']: folder.add_item( label = _(_.NEXT_PAGE, _bold=True), properties = {'SpecialSort': 'bottom'}, path = plugin.url_for(func_or_url=replaytv_item, label=label, idtitle=idtitle, start=processed['count2']), ) return folder
def vod(file, label, start=0, character=None, online=0, split=0, **kwargs): start = int(start) online = int(online) split = int(split) if split == 1: folder = plugin.Folder(title=_.PROGSAZ) label = _.OTHERTITLES folder.add_item( label = label, info = {'plot': _.OTHERTITLESDESC}, path = plugin.url_for(func_or_url=vod, file=file, label=label, start=start, character='other', online=online, split=0), ) for character in string.ascii_uppercase: label = _.TITLESWITH + character folder.add_item( label = label, info = {'plot': _.TITLESWITHDESC + character}, path = plugin.url_for(func_or_url=vod, file=file, label=label, start=start, character=character, online=online, split=0), ) return folder else: folder = plugin.Folder(title=label) processed = process_vod_content(data=file, start=start, type=label, character=character, online=online) if check_key(processed, 'items'): folder.add_items(processed['items']) if check_key(processed, 'total') and check_key(processed, 'count2') and processed['total'] > processed['count2']: folder.add_item( label = _(_.NEXT_PAGE, _bold=True), properties = {'SpecialSort': 'bottom'}, path = plugin.url_for(func_or_url=vod, file=file, label=label, start=processed['count2'], character=character, online=online, split=split), ) return folder
def parse_url(url): if url.startswith('?'): params = dict(parse_qsl(url.lstrip('?'), keep_blank_values=True)) for key in params: params[key] = unquote(params[key]) _url = params.pop('_', '') else: params = {} _url = url params['_url'] = url function = _routes.get(_url) if not function: raise RouterError(_(_.ROUTER_NO_FUNCTION, raw_url=url, parsed_url=_url)) #log.debug('Router Parsed: \'{0}\' => {1} {2}'.format(url, function.__name__, params)) return function, params
def online_search(query=None, **kwargs): items = [] if not query: query = gui.input(message=_.SEARCH, default='').strip() if not query: return profile_settings = load_profile(profile_id=1) for x in reversed(range(2, 10)): if check_key(profile_settings, 'search' + unicode(x - 1)): profile_settings['search' + unicode(x)] = profile_settings['search' + unicode(x - 1)] else: profile_settings['search' + unicode(x)] = '' if check_key(profile_settings, 'search_type' + unicode(x - 1)): profile_settings['search_type' + unicode(x)] = profile_settings['search_type' + unicode(x - 1)] else: profile_settings['search_type' + unicode(x)] = 0 profile_settings['search1'] = query profile_settings['search_type1'] = 1 save_profile(profile_id=1, profile=profile_settings) else: query = unicode(query) folder = plugin.Folder(title=_(_.SEARCH_FOR, query=query)) processed = process_vod_content(data=None, start=0, search=query, type='Online', online=1) items += processed['items'] items[:] = sorted(items, key=_sort_replay_items, reverse=True) items = items[:25] folder.add_items(items) return folder
def group_picker_menu(type_tv_radio, **kwargs): type_tv_radio = str(type_tv_radio) folder = plugin.Folder(title=_.SELECT_GROUP) if type_tv_radio == 'live': profile_settings = load_profile(profile_id=1) if int(profile_settings['radio']) == 1: desc2 = _.NEXT_SETUP_RADIO path = plugin.url_for(func_or_url=channel_picker_menu, type_tv_radio='radio', save_all=1) else: desc2 = _.NEXT_SETUP_IPTV path = plugin.url_for(func_or_url=simple_iptv_menu) folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=path) prefs = load_prefs(profile_id=1) groups = load_file('tv_groups.json', ext=False, isJSON=True) else: desc2 = _.NEXT_SETUP_IPTV folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=simple_iptv_menu)) prefs = load_radio_prefs(profile_id=1) groups = load_file('radio_groups.json', ext=False, isJSON=True) if not groups: groups = [] else: groups = list(groups) if prefs: for currow in prefs: row = prefs[currow] if int(row[type_tv_radio]) == 0: continue if check_key(row, 'group'): label = _(row['name'] + ": " + str(row['group']), _bold=True) else: if type_tv_radio == 'live': label = _(row['name'] + ": TV", _bold=True) else: label = _(row['name'] + ": Radio", _bold=True) folder.add_item( label=label, path=plugin.url_for(func_or_url=change_group, id=currow, type_tv_radio=type_tv_radio), playable=False, ) if type_tv_radio == 'live': folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=path) else: folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=simple_iptv_menu)) return folder
def channel_picker_menu(type_tv_radio, save_all=0, radio=None, **kwargs): type_tv_radio = str(type_tv_radio) save_all = int(save_all) if not radio == None: radio = int(radio) profile_settings = load_profile(profile_id=1) profile_settings['radio'] = radio save_profile(profile_id=1, profile=profile_settings) if save_all == 1: save_all_prefs(type_tv_radio) if type_tv_radio == 'live': folder = plugin.Folder(title=_.SELECT_LIVE) desc2 = _.NEXT_SETUP_REPLAY folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=channel_picker_menu, type_tv_radio='replay', save_all=1)) prefs = load_prefs(profile_id=1) elif type_tv_radio == 'replay': folder = plugin.Folder(title=_.SELECT_REPLAY) desc2 = _.NEXT_SETUP_ORDER prefs = load_prefs(profile_id=1) folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=order_picker_menu, type_tv_radio='live')) else: folder = plugin.Folder(title=_.SELECT_RADIO) desc2 = _.NEXT_SETUP_ORDER folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=order_picker_menu, type_tv_radio='radio')) prefs = load_radio_prefs(profile_id=1) if prefs: for currow in prefs: row = prefs[currow] if not check_key(row, type_tv_radio): continue if row[type_tv_radio] == 1: color = 'green' if not type_tv_radio == 'radio': addon_type = row[type_tv_radio + '_addonid'].replace( 'plugin.video.', '') else: color = 'red' if not type_tv_radio == 'radio': addon_type = _.DISABLED if not type_tv_radio == 'radio': label = _(row['name'] + ": " + addon_type, _bold=True, _color=color) else: label = _(row['name'], _bold=True, _color=color) folder.add_item( label=label, path=plugin.url_for(func_or_url=change_channel, id=currow, type_tv_radio=type_tv_radio), playable=False, ) if type_tv_radio == 'live': folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=channel_picker_menu, type_tv_radio='replay', save_all=1)) elif type_tv_radio == 'replay': folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=order_picker_menu, type_tv_radio='live')) else: folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=order_picker_menu, type_tv_radio='radio')) return folder
def url_for_func(func, **kwargs): for url in _routes: if _routes[url].__name__ == func.__name__: return build_url(url, **kwargs) raise RouterError(_(_.ROUTER_NO_URL, function_name=func.__name__))
def _download(url, dst, dst_path, arch, md5=None): filename = url.split('/')[-1] tmp = ADDON_PROFILE + "tmp" + os.sep + "widevine" downloaded = 0 if os.path.exists(dst_path): if md5 and md5sum(dst_path) == md5: #log.debug('MD5 of local file {} same. Skipping download'.format(filename)) return True elif not gui.yes_no(_.NEW_IA_VERSION): return False else: if os.path.exists(dst_path): os.remove(dst_path) with gui.progress(_(_.IA_DOWNLOADING_FILE, url=filename), heading=_.IA_WIDEVINE_DRM) as progress: resp = Session().get(url, stream=True) if resp.status_code != 200: raise InputStreamError( _(_.ERROR_DOWNLOADING_FILE, filename=filename)) total_length = float(resp.headers.get('content-length', 1)) with open(tmp, 'wb') as f: for chunk in resp.iter_content(chunk_size=SESSION_CHUNKSIZE): f.write(chunk) downloaded += len(chunk) downloadperc = int(downloaded) * 100 downloadperc2 = int(downloadperc) // int(total_length) percent = int(downloadperc2) if progress.iscanceled(): progress.close() resp.close() progress.update(percent) if os.path.isfile(tmp): if 'arm' in arch: with open(tmp, "rb") as encoded_file: import base64 decoded_string = base64.b64decode(encoded_file.read()) with open(dst_path, "wb") as decoded_file: decoded_file.write(decoded_string) else: from zipfile import ZipFile with ZipFile(tmp, 'r') as zipObj: zipObj.extractall(ADDON_PROFILE + "tmp" + os.sep) if os.path.isfile(ADDON_PROFILE + "tmp" + os.sep + dst): shutil.copy(ADDON_PROFILE + "tmp" + os.sep + dst, dst_path) for file in glob.glob(ADDON_PROFILE + "tmp" + os.sep + "*"): os.remove(file) if progress.iscanceled(): return False checksum = md5sum(dst_path) if checksum != md5: if os.path.exists(dst_path): os.remove(dst_path) raise InputStreamError( _(_.MD5_MISMATCH, filename=filename, local_md5=checksum, remote_md5=md5)) return True
def install_widevine(reinstall=False): ia_addon = get_ia_addon(required=True) system, arch = _get_system_arch() kodi_version = get_kodi_version() if kodi_version < 18: raise InputStreamError(_(_.IA_KODI18_REQUIRED, system=system)) elif system == 'Android': return True elif system == 'UWP': raise InputStreamError(_.IA_UWP_ERROR) elif 'aarch64' in arch or 'arm64' in arch: raise InputStreamError(_.IA_AARCH64_ERROR) last_check = int(ia_addon.getSetting('_last_check') or 0) ver_slug = system + arch + str(kodi_version) + ia_addon.getAddonInfo( 'version') if ver_slug != ia_addon.getSetting(IA_VERSION_KEY): reinstall = True if not reinstall and time.time() - last_check < 86400: return True ia_addon.setSetting(IA_VERSION_KEY, '') ia_addon.setSetting('_last_check', str(int(time.time()))) r = api_get_widevine() widevine = r['widevine'] wv_platform = widevine['platforms'].get(system + arch, None) if not wv_platform: raise InputStreamError( _(_.IA_NOT_SUPPORTED, system=system, arch=arch, kodi_version=kodi_version)) decryptpath = xbmc.translatePath(ia_addon.getSetting('DECRYPTERPATH')) if sys.version_info < (3, 0): decryptpath = decryptpath.decode("utf-8") if 'arm' in arch: url = wv_platform['zip'] else: url = widevine['base_url'] + wv_platform['zip'] wv_path = os.path.join(decryptpath, wv_platform['dst']) if not os.path.isdir(decryptpath): os.makedirs(decryptpath) if not os.path.isdir(ADDON_PROFILE + "tmp"): os.makedirs(ADDON_PROFILE + "tmp") if not _download(url, wv_platform['dst'], wv_path, arch, wv_platform['md5']): return False ia_addon.setSetting(IA_VERSION_KEY, ver_slug) if reinstall: gui.ok(_.IA_WV_INSTALL_OK) return True
def error(message, heading=None): heading = heading or _(_.PLUGIN_ERROR, addon=ADDON_NAME) return ok(message, heading)
def order_picker_menu(type_tv_radio, double=None, primary=None, **kwargs): type_tv_radio = unicode(type_tv_radio) save_all_order(type_tv_radio=type_tv_radio, double=double, primary=primary) folder = plugin.Folder(title=_.SELECT_ORDER) if type_tv_radio == 'live': profile_settings = load_profile(profile_id=1) if int(profile_settings['radio']) == 1: desc2 = _.NEXT_SETUP_RADIO path = plugin.url_for(func_or_url=channel_picker_menu, type_tv_radio='radio', save_all=1) else: desc2 = _.NEXT_SETUP_IPTV path = plugin.url_for(func_or_url=simple_iptv_menu) folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=path) prefs = load_prefs(profile_id=1) order = load_order(profile_id=1) else: desc2 = _.NEXT_SETUP_IPTV folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=simple_iptv_menu)) prefs = load_radio_prefs(profile_id=1) order = load_radio_order(profile_id=1) if order: for currow in order: row = prefs[currow] if int(row[type_tv_radio]) == 0: continue label = _(row['name'] + ": " + unicode(order[unicode(currow)]), _bold=True) folder.add_item( label=label, path=plugin.url_for(func_or_url=change_order, id=currow, type_tv_radio=type_tv_radio), playable=False, ) if type_tv_radio == 'live': folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=path) else: folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=simple_iptv_menu)) return folder