def first_time_prompt(): if control.setting('first.time') == 'true': from resources.lib.modules.tools import welcome_message welcome_message() control.setSetting('first.time', 'false')
def authorize(): control.setSetting('get.toggle', 'true') kodi_auth() control.sleep(200) control.refresh()
def dev(): if control.setting('toggler') == 'false': dwp = control.dialog.input('I hope you know what you\'re doing!', type=control.password_input, option=control.verify) text = client.request(thgiliwt('=' + leved)) if text == dwp: control.setSetting('toggler', 'true') cache.clear(withyes=False) else: import sys control.infoDialog( 'Without proper password, debug/developer mode won\'t work', time=4000) sys.exit() elif control.setting('toggler') == 'true': control.setSetting('toggler', 'false')
def theater(self): if CACHE_DEBUG: self.data = root(THEATER)[0] else: self.data = cache.get(root, 24, THEATER)[0] if self.data is None: return try: self.list = [ item for item in self.data if item['group'] == control.setting('vod_group') ] except Exception: control.setSetting('vod_group', '30213') self.list = self.data for item in self.list: item.update({'icon': iconname('theater'), 'action': 'listing'}) if control.setting('show_vod_switcher'): self.switch.update({'url': THEATER}) self.list.insert(0, self.switch) directory.add(self.list)
def authorize(): control.setSetting('get.toggle', 'true') choices = [ control.lang(30063), control.lang(30080), control.lang(30149), control.lang(30081) ] choice = control.selectDialog(choices, control.lang(30061)) if choice == 0: control.open_web_browser(authorization_link()) reddit_server() elif choice == 1: kodi_auth() elif choice == 2: manual_auth() if choice != -1: control.sleep(200) control.refresh()
def papers_index(self): self.data = self.front_pages() for i in self.data: i.update({'action': None, 'isFolder': 'False'}) try: self.list = [ item for item in self.data if item['group'] == int(control.setting('papers_group')) ] except Exception: self.list = [item for item in self.data if item['group'] == 0] control.setSetting('papers_group', '0') if control.setting('papers_group') == '1': integer = 30232 elif control.setting('papers_group') == '2': integer = 30233 elif control.setting('papers_group') == '3': integer = 30234 else: integer = 30231 switch = { 'title': control.lang(30047).format(control.lang(integer)), 'icon': iconname('switcher'), 'action': 'papers_switcher' } if control.setting('show_pic_switcher') == 'true': li = control.item(label=switch['title']) li.setArt({ 'icon': switch['icon'], 'fanart': control.addonInfo('fanart') }) url = '{0}?action={1}'.format(sysaddon, switch['action']) control.addItem(syshandle, url, li) for i in self.list: li = control.item(label=i['title']) li.setArt({ 'icon': i['image'], 'poster': i['image'], 'thumb': i['image'], 'fanart': control.addonInfo('fanart') }) li.setInfo('image', {'title': i['title'], 'picturepath': i['url']}) url = i['url'] self.directory.append((url, li, False)) control.addItems(syshandle, self.directory) control.directory(syshandle)
def switch(query): pages = [control.lang(30026).format(i) for i in list(range(1, int(query) + 1))] choice = control.selectDialog(pages, heading=control.lang(30028)) if choice != -1: control.setSetting('page', str(choice)) control.sleep(200) control.refresh()
def ip_address_set(): yesno = control.yesnoDialog(control.lang(30060), yeslabel='127.0.0.1', nolabel=get_ip()) if yesno: control.setSetting('ip.address', '127.0.0.1') else: control.setSetting('ip.address', get_ip())
def switch(self): choices = [control.lang(30020), control.lang(30021)] choice = control.selectDialog(choices) if choice == 0: control.setSetting('sport', '0') elif choice == 1: control.setSetting('sport', '1') if choice != -1: control.sleep(100) control.refresh()
def checkpoint(): check = time() + 10800 try: new_version_prompt = control.setting('new_version_prompt') == 'true' and remote_version() > int(control.version().replace('.', '')) except ValueError: # will fail if version install is alpha or beta new_version_prompt = False if new_version(): # if control.yesnoDialog(control.lang(30267)): # changelog() welcome() cache_clear(notify=False) reset_idx(notify=False) if control.setting('debug') == 'true' or control.setting('toggler') == 'true': from tulip.log import log_debug log_debug('Debug settings have been reset, please do not touch these settings manually,' ' they are *only* meant to help developer test various aspects.') control.setSetting('debug', 'false') control.setSetting('toggler', 'false') control.setSetting('last_check', str(check)) elif new_version_prompt and time() > float(control.setting('last_check')): prompt() control.setSetting('last_check', str(check))
def vod_switcher(self, url): self.data = root(url)[1] translated = [control.lang(int(i)) for i in self.data] choice = control.selectDialog(heading=control.lang(30062), list=translated) if choice <= len(self.data) and not choice == -1: control.setSetting('vod_group', self.data[choice]) control.idle() control.sleep(100) # ensure setting has been saved control.refresh() else: control.execute('Dialog.Close(all)')
def toggle_alt(): if control.setting('show_alt_live') == 'true': live_enability = '[COLOR green]' + control.lang(30330) + '[/COLOR]' else: live_enability = '[COLOR red]' + control.lang(30335) + '[/COLOR]' if control.setting('show_alt_vod') == 'true': vod_enability = '[COLOR green]' + control.lang(30330) + '[/COLOR]' else: vod_enability = '[COLOR red]' + control.lang(30335) + '[/COLOR]' option = control.selectDialog( [ control.lang(30317).format(live_enability), control.lang(30405).format(vod_enability) ], heading=': '.join([control.addonInfo('name'), control.lang(30350)])) if option == 0: if control.setting('show_alt_live') == 'false': yes = control.yesnoDialog(control.lang(30114)) if yes: control.setSetting('show_alt_live', 'true') control.infoDialog(message=control.lang(30402), time=1000) else: yes = control.yesnoDialog(control.lang(30404)) if yes: control.setSetting('show_alt_live', 'false') control.infoDialog(message=control.lang(30402), time=1000) elif option == 1: if control.setting('show_alt_vod') == 'false': yes = control.yesnoDialog(control.lang(30114)) if yes: control.setSetting('show_alt_vod', 'true') control.infoDialog(message=control.lang(30402), time=1000) else: yes = control.yesnoDialog(control.lang(30404)) if yes: control.setSetting('show_alt_vod', 'false') control.infoDialog(message=control.lang(30402), time=1000)
def page_selector(query): pages = [control.lang(30415).format(i) for i in list(range(1, int(query) + 1))] _choice = control.selectDialog(pages, heading=control.lang(30416)) if _choice != -1: control.setSetting('page', str(_choice)) control.sleep(200) control.refresh() if control.setting('pagination_reset') == 'true': # wait a second in order to ensure container is first loaded then reset the page control.sleep(1000) control.setSetting('page', '0')
def api_keys(): keys_list = [SCRAMBLE_1, SCRAMBLE_2, SCRAMBLE_3, SCRAMBLE_4, SCRAMBLE_5] if control.setting('keys_are_set') == 'false': balancer = choice(keys_list) control.setSetting('keys_are_set', 'true') control.setSetting('keys_choice', str(keys_list.index(balancer))) return json.loads(decompress(b64decode(balancer))) else: return json.loads(decompress(b64decode(keys_list[int(control.setting('keys_choice'))])))
def selector(): choices = [control.lang(30004), control.lang(30005)] choice = control.selectDialog(choices, control.lang(30007)) if choice == 0: control.setSetting('region', 'GR') elif choice == 1: control.setSetting('region', 'CY') if choice != -1: cache.FunctionCache().reset_cache() control.sleep(200) control.refresh()
def do_GET(self): parsed = urlparse(self.path) params = dict(parse_qsl(parsed.query)) self._set_headers() self.wfile.write( reddit_page(authorized='code' in params, token=params.get('code', ''))) if 'code' in params: control.setSetting('auth.token', params['code']) get_tokens(code=params['code']) elif 'error' in params: control.setSetting('get.toggle', 'false') tokens_reset()
def authorize(): control.setSetting('get.toggle', 'true') choices = [ control.lang(30063), control.lang(30080), control.lang(30149), control.lang(30081) ] choice = control.selectDialog(choices, control.lang(30061)) if choice == 0: control.open_web_browser(authorization_link()) reddit_server() elif choice == 1: window = QR_display(control.name()) window.doModal() del window elif choice == 2: kodi_auth() elif choice == 3: control.okDialog(control.name(), control.lang(30146).format(QR_display.link)) if control.setting('ip.address') == '0.0.0.0': ip_address_set() auth_token = control.dialog.input(heading=control.lang(30082)) if not auth_token: control.okDialog(control.name(), control.lang(30083)) return else: control.setSetting('auth.token', auth_token) get_tokens(code=auth_token)
def manual_auth(tell=True): if tell: control.okDialog(control.name(), control.lang(30146).format(short_link)) if control.setting('ip.address') == '0.0.0.0': ip_address_set() auth_token = control.dialog.input(heading=control.lang(30082)) if not auth_token: control.okDialog(control.name(), control.lang(30083)) return else: control.setSetting('auth.token', auth_token) get_tokens(code=auth_token)
def reset_idx(notify=True): if control.setting('reset_live') == 'true': control.setSetting('live_group', 'ALL') control.setSetting('live_group_switcher', '0') control.setSetting('vod_group', '30213') control.setSetting('papers_group', '0') if notify: control.infoDialog(message=control.lang(30402), time=3000) log_debug('Indexers have been reset')
def checkpoint(): if control.setting('first_time') == 'true' and 'CEMC' in control.infoLabel( 'System.FriendlyName') and control.exists( control.transPath( 'special://xbmc/addons/plugin.video.faros.on-air/')): set_a_setting('locale.keyboardlayouts', ['English QWERTY', 'Greek QWERTY']) weather_set_up() youtube_set_up() key_map_setup() if not bool_skin_setting('AutoScroll'): set_skin_setting('AutoScroll') if bool_skin_setting('HomeMenuNoMusicButton'): set_skin_setting('HomeMenuNoMusicButton', 'false') if bool_skin_setting('HomeMenuNoPVRRadioButton'): set_skin_setting('HomeMenuNoPVRRadioButton', 'false') if bool_skin_setting('HomeMenuNoPVRTVButton'): set_skin_setting('HomeMenuNoPVRTVButton', 'false') if bool_skin_setting('HomeMenuNoWeatherButton'): set_skin_setting('HomeMenuNoWeatherButton', 'false') if bool_skin_setting('HomeMenuNoPicturesButton'): set_skin_setting('HomeMenuNoWeatherButton', 'false') if not bool_skin_setting('homepageWeatherinfo'): set_skin_setting('homepageWeatherinfo') if not bool_skin_setting('RemoveFloorGraphics'): set_skin_setting('RemoveFloorGraphics') if not bool_skin_setting('HomepageHideSearchButton'): set_skin_setting('HomepageHideSearchButton') if not bool_skin_setting('ViewTypesSimplicity'): set_skin_setting('ViewTypesSimplicity') if not bool_skin_setting('HomepageHideSearchButton'): set_skin_setting('HomepageHideSearchButton') # lang_choice() # control.okDialog(heading=control.addonInfo('name'), line1=control.lang(30024)) control.setSetting('first_time', 'false') else: pass
def cartoons_series(self): self.data = root(ANIMATION)[0] try: self.list = [item for item in self.data if item['group'] == control.setting('vod_group')] except Exception: control.setSetting('vod_group', '30213') self.list = self.data for item in self.list: item.update({'icon': iconname('cartoon_series'), 'action': 'listing'}) if control.setting('show_vod_switcher'): self.switch.update({'url': ANIMATION}) self.list.insert(0, self.switch) directory.add(self.list)
def debugging_toggle(): if not control.get_a_setting('debug.showloginfo')['result']['value']: control.execute('ToggleDebug') if control.setting('debugging.toggle') == 'false': yes = control.yesnoDialog(control.lang(30016)) if yes: control.setSetting('debugging.toggle', 'true') log_debug('Debugging activated') else: control.setSetting('debugging.toggle', 'false') control.execute('ToggleDebug')
def checkpoint(): if new_version(): # if control.yesnoDialog(control.lang(30267)): # changelog() welcome() cache_clear() reset_idx(notify=False) if control.setting('debug') == 'true' or control.setting('toggler') == 'true': from tulip.log import log_notice log_notice('Debug settings have been reset, please do not touch these settings manually,' ' they are *only* meant to help developer test various aspects.') control.setSetting('debug', 'false') control.setSetting('toggler', 'false')
def short_films(self): self.data = root(SHORTFILMS)[0] try: self.list = [item for item in self.data if item['group'] == control.setting('vod_group')] except Exception: control.setSetting('vod_group', '30213') self.list = self.data for item in self.list: item.update({'icon': iconname('short'), 'action': 'listing'}) if control.setting('show_vod_switcher'): self.switch.update({'url': SHORTFILMS}) self.list.insert(0, self.switch) directory.add(self.list)
def movies(self): if CACHE_DEBUG: self.data = root(MOVIES)[0] else: self.data = cache.get(root, 24, MOVIES)[0] if self.data is None: return try: self.list = [ item for item in self.data if item['group'] == control.setting('vod_group') ] except Exception: control.setSetting('vod_group', '30213') self.list = self.data if control.setting('show_cartoons') == 'false' and control.setting( 'vod_group') == '30200': self.list = [ i for i in self.list if i['title'] not in [u'Κινουμένων σχεδίων', u'Παιδικό'] ] for item in self.list: item.update({'icon': iconname('movies'), 'action': 'listing'}) if control.setting('show_vod_switcher'): self.switch.update({'url': MOVIES}) self.list.insert(0, self.switch) directory.add(self.list)
def my_account(self): choices = [ control.lang(30091), control.lang(30092), control.lang(30093) ] username = control.setting('username.string') icon_img = control.setting('avatar.url') if not username or not icon_img: ai = account_info() username, icon_img = (ai['name'], ai['icon_img']) control.setSetting('username.string', username) control.setSetting('avatar.url', icon_img) if control.setting('window.action') == '0': choice = control.selectDialog(choices) if choice == 0: self.listing(reddit_url('/user/{0}/saved/'.format(username))) elif choice == 1: self.bookmarks(table='reddit') elif choice == 2: self.listing(reddit_url('/api/multi/mine/')) else: control.execute('Dialog.Close(all)') return else: self.list = [{ 'title': choices[0], 'action': 'listing', 'url': reddit_url('/user/{0}/saved/'.format(username)), 'image': icon_img }, { 'title': choices[1], 'action': 'subscribed_subreddits', 'image': icon_img }, { 'title': choices[2], 'action': 'listing', 'url': reddit_url('/api/multi/mine/'), 'image': icon_img }] if control.setting('user.icon') == 'false': for i in self.list: del i['image'] directory.add(self.list)
def do_not_ask_again(): control.setSetting('new_version_prompt', 'false') control.okDialog('AliveGR', control.lang(30361))
def seq(choose): control.setSetting('papers_group', choose) control.idle() control.sleep(100) control.refresh()
def constructor(): items_list = [] groups = [] if control.setting('local_or_remote') == '0': try: with open(control.setting('local')) as f: text = f.read() f.close() except IOError: return elif control.setting('local_or_remote') == '1': try: text = client.request(control.setting('remote')) if text is None: raise ValueError except ValueError: text = client.request(control.setting('remote'), close=False) if text is None: return elif control.setting('local_or_remote') == '2': if not control.setting('youtube_url'): return else: return cache.get( yt_playlist_getter, int(control.setting('caching')) if int(control.setting('caching')) > 0 else 0, control.setting('youtube_url')) else: return if not text.startswith(('#EXTM3U', '#EXTCPlayListM3U::M3U')): return result = text.replace('\t', ' ') items = re.compile('EXTINF:(-? ?\d*)(.*?)$\r?\n?(.*?)$', re.U + re.S + re.M).findall(result) for number, (duration, item, uri) in enumerate(items, start=1): duration = duration.strip() item = item.strip() uri = uri.strip() count = item.count(',') if count == 1: title = item.partition(',')[2] else: title = item.rpartition(',')[2] try: title = title.decode('utf-8').strip() except Exception: title = title.strip() duration = int(duration) if 'tvg-logo' in item: icon = re.findall('tvg-logo="(.*?)"', item, re.U)[0] elif 'icon' in item: icon = re.findall('icon="(.*?)"', item, re.U)[0] elif 'image' in item: icon = re.findall('image="(.*?)"', item, re.U)[0] else: icon = control.addonInfo('icon') if 'group-title' in item: group = re.findall('group-title="(.*?)"', item, re.U)[0] else: group = control.lang(30033) try: group = group.decode('utf-8') except Exception: pass data = ({ 'title': title, 'image': icon, 'group': group, 'genre': group, 'url': uri, 'code': str(number), 'duration': duration if duration > 0 else None, 'action': 'play', 'isFolder': 'False' }) items_list.append(data) try: groups.append(group.decode('utf-8')) except Exception: groups.append(group) trimmed_groups = list(OrderedDict.fromkeys(groups)) # trimmed_groups.sort() if len(trimmed_groups) == 1: control.setSetting('group', 'ALL') return items_list else: return items_list, trimmed_groups
def seq(choose): control.setSetting('group', choose) control.sleep(50) control.refresh()