def home(**kwargs): if settings.getBool(key='_first_boot') == True: first_boot() folder = plugin.Folder() if not plugin.logged_in: folder.add_item(label=_(_.LOGIN, _bold=True), path=plugin.url_for(func_or_url=login)) else: 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') == True: folder.add_item(label=_(_.SERIES, _bold=True), path=plugin.url_for(func_or_url=vod, file='series', label=_.SERIES, kids=0, start=0)) folder.add_item(label=_(_.MOVIES, _bold=True), path=plugin.url_for(func_or_url=vod, file='movies', label=_.MOVIES, kids=0, start=0)) folder.add_item(label=_(_.HBO_SERIES, _bold=True), path=plugin.url_for(func_or_url=vod, file='hboseries', label=_.HBO_SERIES, kids=0, start=0)) folder.add_item(label=_(_.HBO_MOVIES, _bold=True), path=plugin.url_for(func_or_url=vod, file='hbomovies', label=_.HBO_MOVIES, kids=0, start=0)) folder.add_item(label=_(_.KIDS_SERIES, _bold=True), path=plugin.url_for(func_or_url=vod, file='kids', label=_.KIDS_SERIES, kids=1, start=0)) folder.add_item(label=_(_.KIDS_MOVIES, _bold=True), path=plugin.url_for(func_or_url=vod, file='kids', label=_.KIDS_MOVIES, kids=2, start=0)) 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=_.SETTINGS, path=plugin.url_for(func_or_url=settings_menu)) return folder
def download_epg(): settings.setInt(key='_epgrun', value=1) settings.setInt(key='_epgruntime', value=time.time()) if settings.getBool(key="minimalChannels"): url = CONST_MINIMALEPG else: url = CONST_EPG if ADDON_ID == "plugin.video.ziggo" and settings.getBool(key='_base_v3') == True: url = url.replace('epg.xml.', 'epg.xml.v3.') resp = requests.get(url=url) settings.set(key='_epg_md5', value=hashlib.md5(resp.content).hexdigest()) zipfile = ZipFile(BytesIO(resp.content)) zipfile.extractall(ADDON_PROFILE) zipfile.close() for file in glob.glob(ADDON_PROFILE + "*_replay.xml"): if is_file_older_than_x_days(file=file, days=7): os.remove(file) for file in glob.glob(ADDON_PROFILE + "*_replay.json"): if is_file_older_than_x_days(file=file, days=7): os.remove(file) settings.setInt("_epgrun", 0)
def do_GET(self): URL = settings.get(key='_stream_hostname') + str(self.path).replace( 'WIDEVINETOKEN', settings.get(key='_drm_token')) if "manifest.mpd" in self.path or "Manifest" in self.path: HEADERS = CONST_BASE_HEADERS for header in self.headers: if self.headers[ header] is not None and header in CONST_ALLOWED_HEADERS: HEADERS[header] = self.headers[header] self._session = Session(headers=HEADERS) r = self._session.get(URL) xml = r.text xml = set_duration(xml=xml) if settings.getBool(key='force_highest_bandwidth'): xml = force_highest_bandwidth(xml=xml) if settings.getBool(key="disableac3") == True: xml = remove_ac3(xml=xml) self.send_response(r.status_code) r.headers['Content-Length'] = len(xml) for header in r.headers: if not 'Content-Encoding' in header and not 'Transfer-Encoding' in header: self.send_header(header, r.headers[header]) self.end_headers() try: xml = xml.encode('utf-8') except: pass try: self.wfile.write(xml) except: pass else: self._now_playing = time.time() try: if self._last_playing + 60 < self._now_playing: self._last_playing = time.time() settings.setInt(key='_last_playing', value=self._last_playing) except: self._last_playing = time.time() settings.setInt(key='_last_playing', value=self._last_playing) self.send_response(302) self.send_header('Location', URL) self.end_headers()
def vod_seasons(self, id): profile_settings = load_profile(profile_id=1) seasons = [] program_url = '{api_url}/CONTENT/DETAIL/GROUP_OF_BUNDLES/{id}'.format( api_url=profile_settings['api_url'], id=id) file = "cache" + os.sep + "vod_seasons_" + unicode(id) + ".json" if settings.getBool( key='enable_cache') and not is_file_older_than_x_minutes( file=ADDON_PROFILE + file, minutes=10): data = load_file(file=file, isJSON=True) else: if not self.get_session(): return None download = self.download(url=program_url, type='get', headers=None, data=None, json_data=True, return_json=True) data = download['data'] resp = download['resp'] if resp and resp.status_code == 200 and data and check_key( data, 'resultCode') and data['resultCode'] == 'OK' and check_key( data, 'resultObj') and check_key( data['resultObj'], 'containers') and settings.getBool( key='enable_cache'): write_file(file=file, data=data, isJSON=True) if not data or not check_key(data['resultObj'], 'containers'): return None for row in data['resultObj']['containers']: for currow in row['containers']: if check_key(currow, 'metadata') and check_key( currow['metadata'], 'season' ) and currow['metadata']['contentSubtype'] == 'SEASON': seasons.append({ 'id': currow['metadata']['contentId'], 'seriesNumber': currow['metadata']['season'], 'desc': currow['metadata']['shortDescription'], 'image': currow['metadata']['pictureUrl'] }) return seasons
def download_settings(): resp = requests.get(url=CONST_SETTINGS) write_file(file='settings.json', data=resp.text, isJSON=False) if settings.getBool(key='showMoviesSeries') == True: resp = requests.get(url=CONST_VOD) write_file(file='vod.json', data=resp.text, isJSON=False) if settings.getBool(key='enable_radio') == True: resp = requests.get(url=CONST_RADIO) write_file(file='radio.m3u8', data=resp.text, isJSON=False) combine_playlist()
def renew_vod(): if settings.getBool(key='showMoviesSeries') == True: md5JSON = load_file(file='md5.json', isJSON=True) try: if ADDON_ID == "plugin.video.ziggo" and settings.getBool(key='_base_v3') == True: key = 'vod.v3.json' else: key = 'vod.json' if settings.get(key='_vod_md5') != md5JSON[key]: download_vod() except: download_vod()
def startup(): system, arch = get_system_arch() settings.set(key="_system", value=system) settings.set(key="_arch", value=arch) settings.setInt(key='_proxyserver_port', value=find_free_port()) hourly() daily() change_icon() if settings.getBool(key='enable_simple_iptv') == True: try: IPTV_SIMPLE = xbmcaddon.Addon(id="pvr.iptvsimple") if IPTV_SIMPLE.getSetting("epgPath") == ( ADDON_PROFILE + "epg.xml") and IPTV_SIMPLE.getSetting("m3uPath") == ( ADDON_PROFILE + "playlist.m3u8"): user_agent = settings.get(key='_user_agent') if IPTV_SIMPLE.getSetting("userAgent") != user_agent: IPTV_SIMPLE.setSetting("userAgent", user_agent) xbmc.executeJSONRPC( '{{"jsonrpc":"2.0","id":1,"method":"Addons.SetAddonEnabled","params":{{"addonid":"{}","enabled":false}}}}' .format(IPTV_SIMPLE_ADDON_ID)) xbmc.sleep(2000) xbmc.executeJSONRPC( '{{"jsonrpc":"2.0","id":1,"method":"Addons.SetAddonEnabled","params":{{"addonid":"{}","enabled":true}}}}' .format(IPTV_SIMPLE_ADDON_ID)) except: pass
def do_GET(self): try: self._stream_url except: profile_settings = load_profile(profile_id=1) self._stream_url = profile_settings['stream_hostname'] try: self._last_playing except: self._last_playing = 0 if ".mpd" in self.path: profile_settings = load_profile(profile_id=1) self._stream_url = profile_settings['stream_hostname'] session = Session(cookies_key='cookies', save_cookies=False) r = session.get(self._stream_url + str(self.path)) xml = r.text xml = set_duration(xml=xml) if settings.getBool(key='force_highest_bandwidth'): xml = force_highest_bandwidth(xml=xml) self.send_response(r.status_code) r.headers['Content-Length'] = len(xml) for header in r.headers: if not 'Content-Encoding' in header and not 'Transfer-Encoding' in header: self.send_header(header, r.headers[header]) self.end_headers() try: xml = xml.encode('utf-8') except: pass try: self.wfile.write(xml) except: pass else: self._now_playing = int(time.time()) if self._last_playing + 60 < self._now_playing: self._last_playing = int(time.time()) query = "UPDATE `vars` SET `last_playing`='{last_playing}' WHERE profile_id={profile_id}".format( last_playing=self._last_playing, profile_id=1) query_settings(query=query, return_result=False, return_insert=False, commit=True) self.send_response(302) self.send_header('Location', self._stream_url + str(self.path)) self.end_headers()
def online_search(query=None, **kwargs): if not query: query = gui.input(message=_.SEARCH, default='').strip() if not query: return for x in reversed(list(range(2, 10))): settings.set(key='_search' + unicode(x), value=settings.get(key='_search' + unicode(x - 1))) settings.set(key='_search_type' + unicode(x), value=settings.get(key='_search_type' + unicode(x - 1))) settings.set(key='_search1', value=query) settings.set(key='_search_type1', value=' (Online)') folder = plugin.Folder(title=_(_.SEARCH_FOR, query=query)) data = api.online_search(search=query, vod=settings.getBool('showMoviesSeries')) if data: processed = process_online_search(data=data) if processed: folder.add_items(processed) return folder
def update_settings(): settingsJSON = load_file(file='settings.json', isJSON=True) try: base = settingsJSON['settings']['urls']['base'] if settings.getBool(key='_base_v3'): basethree = settingsJSON['settings']['urls']['alternativeAjaxBase'] else: basethree = base complete_base_url = '{base_url}/{country_code}/{language_code}'.format(base_url=basethree, country_code=settingsJSON['settings']['countryCode'], language_code=settingsJSON['settings']['languageCode']) settings.set(key='_base_url', value=complete_base_url + '/web') settings.set(key='_search_url', value=settingsJSON['settings']['routes']['search'].replace(base, basethree)) settings.set(key='_session_url', value=settingsJSON['settings']['routes']['session'].replace(base, basethree)) #settings.set(key='_token_url', value=settingsJSON['settings']['routes']['refreshToken'].replace(base, basethree)) settings.set(key='_channels_url', value=settingsJSON['settings']['routes']['channels'].replace(base, basethree)) settings.set(key='_token_url', value='{complete_base_url}/web/license/token'.format(complete_base_url=complete_base_url)) settings.set(key='_widevine_url', value='{complete_base_url}/web/license/eme'.format(complete_base_url=complete_base_url)) settings.set(key='_listings_url', value=settingsJSON['settings']['routes']['listings'].replace(base, basethree)) settings.set(key='_mediaitems_url', value=settingsJSON['settings']['routes']['mediaitems'].replace(base, basethree)) settings.set(key='_mediagroupsfeeds_url', value=settingsJSON['settings']['routes']['mediagroupsfeeds'].replace(base, basethree)) settings.set(key='_watchlist_url', value=settingsJSON['settings']['routes']['watchlist'].replace(base, basethree)) except: pass try: client_id = settingsJSON['client_id'] except: client_id = CONST_DEFAULT_CLIENTID settings.set(key='_client_id', value=client_id)
def search(query=None, **kwargs): items = [] if not query: query = gui.input(message=_.SEARCH, default='').strip() if not query: return db_query = "UPDATE `vars` SET `search10`=`search9`, `search9`=`search8`, `search8`=`search7`, `search7`=`search6`, `search6`=`search5`, `search5`=`search4`, `search4`=`search3`, `search3`=`search2`, `search2`=`search1`, `search1`='{search1}' WHERE profile_id={profile_id}".format(search1=query, profile_id=1) query_settings(query=db_query, return_result=False, return_insert=False, commit=False) folder = plugin.Folder(title=_(_.SEARCH_FOR, query=query)) processed = process_replaytv_search(search=query) items += processed['items'] if settings.getBool('showMoviesSeries'): processed = process_vod_content(data='series', start=0, search=query, type=_.SERIES) items += processed['items'] processed = process_vod_content(data='film1', start=0, search=query, type=_.MOVIES) items += processed['items'] processed = process_vod_content(data='videoshop', start=0, search=query, type=_.VIDEOSHOP) items += processed['items'] items[:] = sorted(items, key=_sort_replay_items, reverse=True) items = items[:25] folder.add_items(items) return folder
def download_files(): resp = requests.get(url=CONST_MD5) write_file(file='md5.json', data=resp.text, isJSON=False) profile_settings = load_profile(profile_id=1) if is_file_older_than_x_days(file=ADDON_PROFILE + "settings.json", days=1): download_settings() md5JSON = load_file(file='md5.json', isJSON=True) if int(profile_settings['epgrun']) == 0 or int(profile_settings['epgruntime']) < (int(time.time()) - 300): try: if settings.getBool(key="minimalChannels"): if ADDON_ID == "plugin.video.ziggo" and int(profile_settings['base_v3']) == 1: key = 'epg.db.v3.minimal.zip' else: key = 'epg.db.minimal.zip' else: if ADDON_ID == "plugin.video.ziggo" and int(profile_settings['base_v3']) == 1: key = 'epg.db.v3.zip' else: key = 'epg.db.zip' if len(profile_settings['epg_md5']) == 0 or profile_settings['epg_md5'] != md5JSON[key]: download_epg() except: download_epg() try: if len(profile_settings['images_md5']) == 0 or profile_settings['images_md5'] != md5JSON['images.zip']: download_images() except: download_images()
def download_epg(): query = "UPDATE `vars` SET `epgrun`='{epgrun}', `epgruntime`='{epgruntime}' WHERE profile_id={profile_id}".format(epgrun=1, epgruntime=int(time.time()), profile_id=1) query_settings(query=query, return_result=False, return_insert=False, commit=True) if settings.getBool(key="minimalChannels"): url = CONST_MINIMALEPG else: url = CONST_EPG if ADDON_ID == "plugin.video.ziggo": profile_settings = load_profile(profile_id=1) if int(profile_settings['base_v3']) == 1: url = url.replace('epg.db.', 'epg.db.v3.') resp = requests.get(url=url) zipfile = ZipFile(BytesIO(resp.content)) zipfile.extractall(ADDON_PROFILE) zipfile.close() for file in glob.glob(ADDON_PROFILE + "*_replay.xml"): if is_file_older_than_x_days(file=file, days=7): os.remove(file) for file in glob.glob(ADDON_PROFILE + "*_replay.json"): if is_file_older_than_x_days(file=file, days=7): os.remove(file) query = "UPDATE `vars` SET `epgrun`='{epgrun}', `epg_md5`='{epg_md5}' WHERE profile_id={profile_id}".format(epgrun=0, epg_md5=hashlib.md5(resp.content).hexdigest(), profile_id=1) query_settings(query=query, return_result=False, return_insert=False, commit=True)
def get_play_url(content): if settings.getBool(key='_base_v3') and check_key(content, 'url') and check_key(content, 'contentLocator'): return {'play_url': content['url'], 'locator': content['contentLocator']} else: for stream in content: if 'streamingUrl' in stream and 'contentLocator' in stream and 'assetTypes' in stream and 'Orion-DASH' in stream['assetTypes']: return {'play_url': stream['streamingUrl'], 'locator': stream['contentLocator']} return {'play_url': '', 'locator': ''}
def download_vod(): url = CONST_VOD if ADDON_ID == "plugin.video.ziggo" and settings.getBool(key='_base_v3') == True: url = url.replace('vod.', 'vod.v3.') resp = requests.get(url=url) write_file(file='vod.json', data=resp.text, isJSON=False) settings.set(key='_vod_md5', value=hashlib.md5(resp.content).hexdigest())
def renew_epg(): md5JSON = load_file(file='md5.json', isJSON=True) if settings.getInt(key='_epgrun') == 0 or settings.getInt(key='_epgruntime') < (int(time.time()) - 300): try: if settings.getBool(key="minimalChannels"): if ADDON_ID == "plugin.video.ziggo" and settings.getBool(key='_base_v3') == True: key = 'epg.xml.v3.minimal.zip' else: key = 'epg.xml.minimal.zip' else: if ADDON_ID == "plugin.video.ziggo" and settings.getBool(key='_base_v3') == True: key = 'epg.xml.v3.zip' else: key = 'epg.xml.zip' if settings.get(key='_epg_md5') != md5JSON[key]: download_epg() except: download_epg()
def do_GET(self): try: self._stream_url except: self._stream_url = settings.get(key='_stream_hostname') if ".mpd" in self.path: self._stream_url = settings.get(key='_stream_hostname') session = Session(cookies_key='_cookies') r = session.get(self._stream_url + str(self.path)) xml = r.text xml = set_duration(xml=xml) if settings.getBool(key='force_highest_bandwidth'): xml = force_highest_bandwidth(xml=xml) self.send_response(r.status_code) r.headers['Content-Length'] = len(xml) for header in r.headers: if not 'Content-Encoding' in header and not 'Transfer-Encoding' in header: self.send_header(header, r.headers[header]) self.end_headers() try: xml = xml.encode('utf-8') except: pass try: self.wfile.write(xml) except: pass else: self._now_playing = time.time() try: if self._last_playing + 60 < self._now_playing: self._last_playing = time.time() settings.setInt(key='_last_playing', value=self._last_playing) except: self._last_playing = time.time() settings.setInt(key='_last_playing', value=self._last_playing) self.send_response(302) self.send_header('Location', self._stream_url + str(self.path)) self.end_headers()
def search(query=None, **kwargs): items = [] if not query: query = gui.input(message=_.SEARCH, default='').strip() if not query: return for x in reversed(list(range(2, 10))): settings.set(key='_search' + unicode(x), value=settings.get(key='_search' + unicode(x - 1))) settings.set(key='_search1', value=query) folder = plugin.Folder(title=_(_.SEARCH_FOR, query=query)) data = load_file(file='list_replay.json', isJSON=True) processed = process_replaytv_search(data=data, start=0, search=query) items += processed['items'] if settings.getBool('showMoviesSeries') == True: processed = process_vod_content(data=load_file(file='vod.json', isJSON=True)['series'], start=0, search=query, type=_.SERIES) items += processed['items'] processed = process_vod_content(data=load_file(file='vod.json', isJSON=True)['movies'], start=0, search=query, type=_.MOVIES) items += processed['items'] processed = process_vod_content(data=load_file( file='vod.json', isJSON=True)['kidsseries'], start=0, search=query, type=_.KIDS_SERIES) items += processed['items'] processed = process_vod_content(data=load_file( file='vod.json', isJSON=True)['kidsmovies'], start=0, search=query, type=_.KIDS_MOVIES) items += processed['items'] items[:] = sorted(items, key=_sort_replay_items, reverse=True) items = items[:25] folder.add_items(items) return folder
def live_tv(**kwargs): folder = plugin.Folder(title=_.LIVE_TV) for row in get_live_channels(addon=settings.getBool(key='enable_simple_iptv')): folder.add_item( label = row['label'], info = {'plot': row['description']}, art = {'thumb': row['image']}, path = row['path'], playable = row['playable'], ) return folder
def check_iptv_link(): if settings.getBool(key='enable_simple_iptv'): try: IPTV_SIMPLE = xbmcaddon.Addon(id="pvr.iptvsimple") if not IPTV_SIMPLE.getSetting("epgPath") == (ADDON_PROFILE + "epg.xml") or not IPTV_SIMPLE.getSetting("m3uPath") == (ADDON_PROFILE + "playlist.m3u8"): settings.setBool(key='enable_simple_iptv', value=False) else: profile_settings = load_profile(profile_id=1) if IPTV_SIMPLE.getSetting("userAgent") != profile_settings['user_agent']: IPTV_SIMPLE.setSetting("userAgent", profile_settings['user_agent']) except: pass
def login(self, username, password, channels=False): settings.remove(key='_cookies') self._session = Session(cookies_key='_cookies') session_url = '{api_url}/USER/SESSIONS/'.format(api_url=settings.get(key='_api_url')) session_post_data = { "credentialsStdAuth": { 'username': username, 'password': password, 'remember': 'Y', 'deviceRegistrationData': { 'deviceId': settings.get(key='_devicekey'), 'accountDeviceIdType': 'DEVICEID', 'deviceType' : 'PCTV', 'vendor' : settings.get(key='_browser_name'), 'model' : settings.get(key='_browser_version'), 'deviceFirmVersion' : settings.get(key='_os_name'), 'appVersion' : settings.get(key='_os_version') } }, } resp = self._session.post(session_url, json=session_post_data) if resp.status_code != 200: gui.ok(message=_.LOGIN_ERROR, heading=_.LOGIN_ERROR_TITLE) self.clear_session() return try: data = resp.json() except: return if not data or not check_key(data, 'resultCode') or data['resultCode'] == 'KO': gui.ok(message=_.LOGIN_ERROR, heading=_.LOGIN_ERROR_TITLE) self.clear_session() return if channels == True or settings.getInt(key='_channels_age') < int(time.time() - 86400): self.get_channels_for_user() self.vod_subscription() if settings.getBool(key='save_password', default=False): set_credentials(username=username, password=password) else: set_credentials(username=username, password='') self.logged_in = True
def check_iptv_link(): if settings.getBool(key='enable_simple_iptv') == True: try: IPTV_SIMPLE = xbmcaddon.Addon(id="pvr.iptvsimple") if not IPTV_SIMPLE.getSetting("epgPath") == (ADDON_PROFILE + "epg.xml") or not IPTV_SIMPLE.getSetting("m3uPath") == (ADDON_PROFILE + "playlist.m3u8"): settings.setBool(key='enable_simple_iptv', value=False) else: user_agent = settings.get(key='_user_agent') if IPTV_SIMPLE.getSetting("userAgent") != user_agent: IPTV_SIMPLE.setSetting("userAgent", user_agent) except: pass
def combine_playlist(): tv = load_file(file='tv.m3u8', isJSON=False) if not tv: tv = u'#EXTM3U\n' radio = None if settings.getBool(key='enable_radio') == True: radio = load_file(file='radio.m3u8', isJSON=False) if not radio: radio = '' write_file(file='playlist.m3u8', data=tv + radio, isJSON=False)
def download_settings(): resp = requests.get(url=CONST_SETTINGS) write_file(file='settings.json', data=resp.text, isJSON=False) if settings.getBool(key='enable_radio') == True: resp = requests.get(url=CONST_RADIO) write_file(file='radio.m3u8', data=resp.text, isJSON=False) combine_playlist() settingsJSON = load_file(file='settings.json', isJSON=True) try: settings.set(key='_user_agent', value=settingsJSON['user_agent']) except: settings.set(key='_user_agent', value=DEFAULT_USER_AGENT)
def play(self): try: if 'seekTime' in self.properties or sys.argv[3] == 'resume:true': self.properties.pop('ResumeTime', None) self.properties.pop('TotalTime', None) except: pass result = True li = self.get_li() handle = _handle() if handle > 0: xbmcplugin.setResolvedUrl(handle, result, li) elif result: xbmc.Player().play(self.path, li) if settings.getBool(key='disable_subtitle'): counter = 0 while not xbmc.Player().isPlayingVideo() and not counter == 4: if xbmc.Monitor().waitForAbort(0.25): break counter += 1 if xbmc.Player().isPlayingVideo(): xbmc.executeJSONRPC( '{"jsonrpc":"2.0","id":1,"method":"Player.SetSubtitle","params":{"playerid":1,"subtitle":"off"}}' ) if 'seekTime' in self.properties and sys.argv[3] != 'resume:true': counter = 0 while not xbmc.Player().isPlayingVideo() and not counter == 4: if xbmc.Monitor().waitForAbort(0.25): break counter += 1 if xbmc.Player().isPlayingVideo(): xbmc.Player().seekTime(int(self.properties['seekTime'])) xbmc.executeJSONRPC( '{"jsonrpc":"2.0", "method":"Player.Seek", "params": { "playerid":1, "value":{ "seconds": 1 } }, "id":1}' )
def download_settings(): resp = requests.get(url=CONST_SETTINGS) write_file(file='settings.json', data=resp.text, isJSON=False) if settings.getBool(key='enable_radio'): resp = requests.get(url=CONST_RADIO) write_file(file='radio.m3u8', data=resp.text, isJSON=False) combine_playlist() settingsJSON = load_file(file='settings.json', isJSON=True) try: user_agent = settingsJSON['user_agent'] except: user_agent = DEFAULT_USER_AGENT query = "UPDATE `vars` SET `user_agent`='{user_agent}' WHERE profile_id={profile_id}".format(user_agent=user_agent, profile_id=1) query_settings(query=query, return_result=False, return_insert=False, commit=True)
def login(self, username, password, channels=False): settings.remove(key='_access_token') user_agent = settings.get(key='_user_agent') HEADERS = { 'User-Agent': user_agent, 'X-Client-Id': settings.get(key='_client_id') + "||" + user_agent, 'X-OESP-Token': '', 'X-OESP-Username': username, } self._session = Session(headers=HEADERS) data = self.download(url=settings.get(key='_session_url'), type="post", code=[200], data={ "username": username, "password": password }, json_data=True, data_return=True, return_json=True, retry=True, check_data=False) if not data or not check_key(data, 'oespToken'): gui.ok(message=_.LOGIN_ERROR, heading=_.LOGIN_ERROR_TITLE) return settings.set(key='_access_token', value=data['oespToken']) self._session.headers.update({'X-OESP-Token': data['oespToken']}) if channels == True or settings.getInt( key='_channels_age') < int(time.time() - 86400): self.get_channels_for_user(location=data['locationId']) if settings.getBool(key='save_password', default=False): set_credentials(username=username, password=password) else: set_credentials(username=username, password='') self.logged_in = True
def home(**kwargs): if settings.getBool(key='_first_boot') == True: first_boot() folder = plugin.Folder() if not plugin.logged_in: folder.add_item(label=_(_.LOGIN, _bold=True), path=plugin.url_for(func_or_url=login)) else: 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)) folder.add_item(label=_(_.SEARCH, _bold=True), path=plugin.url_for(func_or_url=search_menu)) folder.add_item(label=_.SETTINGS, path=plugin.url_for(func_or_url=settings_menu)) return folder
def download_epg(): settings.setInt(key='_epgrun', value=1) settings.setInt(key='_epgruntime', value=time.time()) if settings.getBool(key="minimalChannels"): resp = requests.get(url=CONST_MINIMALEPG) else: resp = requests.get(url=CONST_EPG) zipfile = ZipFile(BytesIO(resp.content)) zipfile.extractall(ADDON_PROFILE) zipfile.close() for file in glob.glob(ADDON_PROFILE + os.sep + "*_replay.xml"): if is_file_older_than_x_days(file=file, days=7): os.remove(file) for file in glob.glob(ADDON_PROFILE + os.sep + "*_replay.json"): if is_file_older_than_x_days(file=file, days=7): os.remove(file) settings.setInt("_epgrun", 0)
def home(**kwargs): profile_settings = load_profile(profile_id=1) if profile_settings['first_boot'] == 1: first_boot() folder = plugin.Folder() if len(profile_settings['pswd']) > 0 and len(profile_settings['devicekey']) > 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'): folder.add_item(label=_(_.SERIES, _bold=True), path=plugin.url_for(func_or_url=vod, file='series', label=_.SERIES, start=0)) folder.add_item(label=_(_.MOVIES, _bold=True), path=plugin.url_for(func_or_url=vod, file='film1', label=_.MOVIES, start=0)) folder.add_item(label=_(_.VIDEOSHOP, _bold=True), path=plugin.url_for(func_or_url=vod, file='videoshop', label=_.VIDEOSHOP, start=0)) 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