def start(): if not control.setting('local') and not control.setting('remote'): if control.yesnoDialog(heading=control.lang(30008), line1=control.lang(30009)): control.openSettings() else: control.infoDialog(control.lang(30014)) else: choices = [ control.lang(30020), control.lang(30016), control.lang(30019) ] selection = control.selectDialog(choices) if selection == 0: seq() elif selection == 1: control.openSettings() elif selection == 2: control.openSettings(id='plugin.video.youtube')
def setup(credentials): def call(): plugin_call = 'plugin://plugin.video.youtube/api/update/?enable=true' route = '{0}&client_id={1}&client_secret={2}&api_key={3}'.format( plugin_call, credentials[0], credentials[2], credentials[1]) control.execute('RunPlugin({0})'.format(route)) if int(YT_VERSION) >= 550 and control.setting('route543') == 'true': call() elif int(YT_VERSION) >= 543 and control.setting( 'route543') == 'true' and 'English' in control.infoLabel( 'System.Language'): call() else: if int(YT_VERSION) < 670: control.addon('plugin.video.youtube').setSetting( 'youtube.api.enable', 'true') control.addon('plugin.video.youtube').setSetting( 'youtube.api.id', credentials[0]) control.addon('plugin.video.youtube').setSetting( 'youtube.api.key', credentials[1]) control.addon('plugin.video.youtube').setSetting( 'youtube.api.secret', credentials[2]) control.infoDialog(message=control.lang(30015), time=3000)
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 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 mini_picker(links): if len(links) == 1: stream = links[0][1] return stream elif control.setting('action_type') == '2' or skip_directory: try: if control.setting('check_streams') == 'false': stream = random_choice([link[1] for link in links]) else: stream = check_stream(links) except Exception: return return stream else: choice = control.selectDialog(heading=control.lang(30064), list=[link[0] for link in links]) if choice == -1: return elif control.setting('check_streams') == 'false': return [link[1] for link in links][choice] else: return check_stream(links, False, start_from=choice, show_pd=True, cycle_list=False)
def root(self): self.menu = [{ 'title': control.lang(30029) + ' ' + active_mode()[0], 'action': 'mode_change', 'boolean': control.setting('show.mode') == 'true' }, { 'title': 'Reddit: ' + control.lang(30120), 'action': 'listing', 'url': base_link() + '/hot/', 'icon': 'hot.png', 'boolean': control.setting('show.hot') == 'true' }, { 'title': 'Reddit: ' + control.lang(30121), 'action': 'listing', 'url': base_link() + '/new/', 'icon': 'new.png', 'boolean': control.setting('show.new') == 'true' }, { 'title': control.lang(30001), 'action': 'search', 'url': 'media', 'icon': 'search_media_files.png', 'boolean': control.setting('show.media') == 'true' }, { 'title': control.lang(30012), 'action': 'search', 'url': 'subreddits', 'icon': 'search_reddit.png', 'boolean': control.setting('show.subreddits') == 'true' }, { 'title': control.lang(30002), 'action': 'saved_subreddits', 'icon': 'saved_subreddits.png', 'boolean': control.setting('show.saved') == 'true' }, { 'title': control.lang(30027), 'action': 'bookmarks', 'icon': 'bookmarks.png', 'boolean': control.setting('show.bookmarks') == 'true' }, { 'title': control.lang(30028), 'action': 'tools', 'icon': 'settings_tools.png', 'boolean': control.setting('show.tools') == 'true' }] my_account = { 'title': control.lang(30090), 'action': 'my_account', 'icon': 'my_account.png', 'boolean': control.setting('show.account') == 'true' } if len(control.setting('access.token')) > 0: self.menu.insert(5, my_account) self.list = [i for i in self.menu if i['boolean']] directory.add(self.list, content='addons')
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 listing(self, url=None, return_list=False, query=None): if url: self.data = cache.get(self.items_list, int(control.setting('cache.size')), url) else: self.data = cache.get(self.replies_viewer, int(control.setting('cache.size')), query) if self.data is None: return self.list = action_updater(self.data) self.menu = cm_updater(self.list, url) if return_list: return self.menu else: if active_mode()[1] == 'pictures': directory.add(self.menu, infotype='pictures') else: directory.add(self.menu, content='movies')
def news_episodes(self, query): self.list = self.news_episodes_listing(query) if self.list is None: return for i in self.list: i.update({'action': 'play', 'isFolder': 'False'}) if len(self.list) > int(control.setting('pagination_integer')) and control.setting('paginate') == 'true': try: pages = utils.list_divider(self.list, int(control.setting('pagination_integer'))) self.list = pages[int(control.setting('page'))] reset = False except Exception: pages = utils.list_divider(self.list, int(control.setting('pagination_integer'))) self.list = pages[0] reset = True self.list.insert(0, self.page_menu(len(pages), reset=reset)) directory.add(self.list, content='videos')
def resolve_live(self, lang): result = client.request(self.live_link.format(lang), error=True) result = json.loads(result)['url'] if result.startswith('//'): result = 'http:' + result result = client.request(result, error=True) _json = json.loads(result) try: if _json.get('status') == 'ko': control.infoDialog(_json.get('msg').capitalize(), time=5000) log_debug(_json.get('msg').capitalize()) return except Exception: return if control.setting('backup_live') == 'false': stream = _json['primary'] else: stream = _json['backup'] if stream.startswith('//'): stream = ''.join(['http:', stream]) if control.setting('quality_live') in ['0', '2']: return stream else: from resources.lib.loader import m3u8_picker return m3u8_picker(stream)
def miscellany(self): self.data = self.misc_list() self.list = [] for item in self.data: if control.setting('lang_split') == '0': if 'Greek' in control.infoLabel('System.Language'): li = control.item(label=item['title'].partition(' - ')[2]) elif 'English' in control.infoLabel('System.Language'): li = control.item(label=item['title'].partition(' - ')[0]) else: li = control.item(label=item['title']) elif control.setting('lang_split') == '1': li = control.item(label=item['title'].partition(' - ')[0]) elif control.setting('lang_split') == '2': li = control.item(label=item['title'].partition(' - ')[2]) else: li = control.item(label=item['title']) li.setArt({ 'icon': item['icon'], 'fanart': control.addonInfo('fanart') }) url = item['url'] isFolder = True self.list.append((url, li, isFolder)) control.addItems(syshandle, self.list) control.directory(syshandle)
def resolve_live(self, lang): try: result = client.request(self.live_link.format(lang)) result = json.loads(result)['url'] if result.startswith('//'): result = 'http:' + result result = client.request(result) if control.setting('backup_live') == 'false': stream = json.loads(result)['primary'] else: stream = json.loads(result)['backup'] if stream.startswith('//'): stream = ''.join(['http:', stream]) if control.setting('quality_live') in ['0', '2']: return stream else: from resources.lib.loader import m3u8_picker return m3u8_picker(stream) except: pass
def action_updater(the_list): for i in the_list: if i['kind'] == 't3': if images_boolean(i['url']): i.update({'action': 'show_picture', 'isFolder': 'False', 'isPlayable': 'False'}) if 'gfycat.com' in i['url'] or 'instagram.com' in i['url'] and control.setting('single.button') == 'false': i.update({'isPlayable': 'True'}) elif i['selftext']: i.update({'action': 'text_viewer', 'isFolder': 'False', 'isPlayable': 'False'}) else: i.update({'action': 'play', 'isFolder': 'False'}) if control.setting('single.button') == 'true': i.update({'isPlayable': 'False'}) elif i['kind'] == 't1': i.update({'action': 'text_viewer', 'isFolder': 'False', 'isPlayable': 'False'}) elif i['kind'] == 'more': i.update({'action': 'listing', 'query': i['replies_urls']}) else: i.update({'action': 'listing'}) for i in the_list: i.update({'nextlabel': 30043, 'nextaction': 'listing'}) return the_list
def kids_songs(self): self.data = [ { 'title': u'Zouzounia TV kids songs - Παιδικά Τραγούδια από τα Ζουζούνια', 'url': 'plugin://plugin.video.zouzounia.tv/', 'icon': 'https://yt3.ggpht.com/-zhH35bOsqec/AAAAAAAAAAI/AAAAAAAAAAA/LxUO6o-ZHPc/s256-c-k-no-mo-rj-c0xffffff/photo.jpg' } , { 'title': u'Greek songs with lyrics No.1 - Ελληνικά παιδικά τραγούδια με στίχους No.1', 'url': '{0}/channel/UCUmGu9Ncu5NeaEjwpLXW0PQ/'.format(YT_ADDON), 'icon': 'https://yt3.ggpht.com/-MVbyrB7DJrY/AAAAAAAAAAI/AAAAAAAAAAA/WjLUCzyX3zI/s256-c-k-no-mo-rj-c0xffffff/photo.jpg' } , { 'title': u'Greek songs with lyrics No.2 - Ελληνικά παιδικά τραγούδια με στίχους No.2', 'url': '{0}/channel/UCyENiZwRYzfXzbwP-Mxk9oA/'.format(YT_ADDON), 'icon': 'https://yt3.ggpht.com/-Jdrq5I2r5Tc/AAAAAAAAAAI/AAAAAAAAAAA/z7IPqFS7jqA/s256-c-k-no-mo-rj-c0xffffff/photo.jpg' } , { 'title': u'Greek Karaoke - Ελληνικό Καραόκε', 'url': '{0}/channel/UCp_0VMwvn5LeJMhtreBFIcA/playlist/PLP25S0MkvCeRlD0w1GXbitRL6sbyMscVi/'.format(YT_ADDON), 'icon': 'https://i.ytimg.com/vi/Iz5P8xJel-U/mqdefault.jpg' } , { 'title': u'Karaoke for English Learning - Μαθαίνω Αγγλικά με καραόκε', 'url': '{0}/channel/UCp_0VMwvn5LeJMhtreBFIcA/playlist/PLP25S0MkvCeSL-M5Q0qG3Eszj0I1O98bT/'.format(YT_ADDON), 'icon': 'https://i.ytimg.com/vi/L2atYpQ7Zbg/mqdefault.jpg' } , { 'title': u'Learning Music for Kids - Μαθαίνω Μουσική, για παιδιά', 'url': '{0}/channel/UCp_0VMwvn5LeJMhtreBFIcA/playlist/PLP25S0MkvCeRr5VH-HylSX89MHXQ_KyS0/'.format(YT_ADDON), 'icon': 'https://i.ytimg.com/vi/w5tF5J_BNfI/mqdefault.jpg' } ] for item in self.data: if control.setting('lang_split') == '0': if 'Greek' in control.infoLabel('System.Language'): li = control.item(label=item['title'].partition(' - ')[2]) elif 'English' in control.infoLabel('System.Language'): li = control.item(label=item['title'].partition(' - ')[0]) else: li = control.item(label=item['title']) elif control.setting('lang_split') == '1': li = control.item(label=item['title'].partition(' - ')[0]) elif control.setting('lang_split') == '2': li = control.item(label=item['title'].partition(' - ')[2]) else: li = control.item(label=item['title']) li.setArt({'icon': item['icon'], 'fanart': control.addonInfo('fanart')}) self.list.append((item['url'], li, True)) control.addItems(syshandle, self.list) control.directory(syshandle)
def refresh_access(): if control.setting('refresh.token') and control.setting('auto.refresh') == 'true': if float(control.setting('expiration.stamp')) < time.time(): from .reddit import get_tokens get_tokens(refresh=True)
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 wrapper(url): if url.endswith('/live'): url = generic(url) if not url: return streams = youtube_resolver.resolve(url) try: addon_enabled = control.addon_details('inputstream.adaptive').get( 'enabled') except KeyError: addon_enabled = False if not addon_enabled: streams = [s for s in streams if 'dash' not in s['title'].lower()] if control.condVisibility('Window.IsVisible(music)') and control.setting( 'audio_only') == 'true': audio_choices = [ u for u in streams if 'dash/audio' in u and 'dash/video' not in u ] if control.setting('yt_quality_picker') == '0': resolved = audio_choices[0]['url'] else: qualities = [i['title'] for i in audio_choices] urls = [i['url'] for i in audio_choices] links = list(zip(qualities, urls)) resolved = stream_picker(links) return resolved elif control.setting('yt_quality_picker') == '1': qualities = [i['title'] for i in streams] urls = [i['url'] for i in streams] links = list(zip(qualities, urls)) resolved = stream_picker(links) return resolved else: resolved = streams[0]['url'] return resolved
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 listing(self, url): if control.setting('debug') == 'false': self.list = cache.get(self._listing, 6, url) else: self.list = self._listing(url) if self.list is None: return for i in self.list: if 'paidikes-tainies' in i['url'] or 'archeio' in i['url']: i.update({'action': 'play', 'isFolder': 'False'}) elif i.get('playable') == 'false': i.update({'action': 'listing'}) else: i.update({'action': 'play', 'isFolder': 'False'}) try: del i['playable'] except KeyError: pass bookmark = dict((k, v) for k, v in iteritems(i) if not k == 'next') bookmark['bookmark'] = i['url'] bookmark_cm = {'title': 30501, 'query': {'action': 'addBookmark', 'url': json.dumps(bookmark)}} if 'enimerosi-24' in url or 'meta_url' not in i: i.update({'cm': [bookmark_cm]}) else: info_cm = {'title': 30043, 'query': {'action': 'info', 'url': i['meta_url']}} i.update({'cm': [bookmark_cm, info_cm]}) if control.setting('pagination') == 'true': for i in self.list: i.update({'nextaction': 'listing', 'nextlabel': 30500, 'nexticon': control.addonmedia('next.jpg')}) if 'tainies' in url or 'seires' in url or 'docs' in url or 'pedika' in url: control.sortmethods() control.sortmethods('title') control.sortmethods('production_code') if 'tainies' in url: content = 'movies' elif 'category' in url or 'arxeio' in url and not 'enimerosi-24' in url: content = 'tvshows' else: content = 'videos' directory.add(self.list, content=content)
def changelog(): if control.setting('changelog_lang') == '0' and 'Greek' in control.infoLabel('System.Language'): change_txt = 'changelog.el.txt' elif (control.setting('changelog_lang') == '0' and 'Greek' not in control.infoLabel('System.Language')) or control.setting('changelog_lang') == '1': change_txt = 'changelog.txt' else: change_txt = 'changelog.el.txt' change_txt = control.join(control.addonPath, change_txt) control.dialog.textviewer(control.addonInfo('name') + ', ' + control.lang(30110), file_to_text(change_txt))
def bookmarks(self): self.data = bookmarks.get() if not self.data: log_debug('Bookmarks list is empty') na = [{'title': 30033, 'action': None, 'icon': iconname('empty')}] directory.add(na) else: for i in self.data: if i['url'].startswith( (movies_link, theater_link, shortfilms_link)): if control.setting('action_type') == '1': try: del i['isFolder'] except: pass action = 'directory' elif control.setting( 'action_type') == '2' and control.setting( 'auto_play') == 'false': try: del i['isFolder'] except: pass action = i['action'] else: action = i['action'] else: action = i['action'] i['action'] = action item = dict((k, v) for k, v in iteritems(i) if not k == 'next') item['delbookmark'] = i['url'] i.update({ 'cm': [{ 'title': 30081, 'query': { 'action': 'deleteBookmark', 'url': json.dumps(item) } }] }) self.list = sorted(self.data, key=lambda k: k['title'].lower()) directory.add(self.list, argv=self.argv)
def _top50(self, url): if control.setting('debug') == 'false': playlists = client.request(thgiliwt(url), headers={ 'User-Agent': 'AliveGR, version: ' + control.version() }) else: if control.setting('local_remote') == '0': local = control.setting('top50_local') try: with open(local, encoding='utf-8') as xml: playlists = xml.read() except Exception: with open(local) as xml: playlists = xml.read() elif control.setting('local_remote') == '1': playlists = client.request(control.setting('top50_remote')) else: playlists = client.request(url) self.data = client.parseDOM(playlists, 'item') for item in self.data: title = client.parseDOM(item, 'title')[0] genre = client.parseDOM(item, 'genre')[0] url = client.parseDOM(item, 'url')[0] image = thumb_maker(url.rpartition('=')[2]) plot = client.parseDOM(item, 'description')[0] duration = client.parseDOM(item, 'duration')[0].split(':') duration = (int(duration[0]) * 60) + int(duration[1]) item_data = ({ 'label': title, 'title': title.partition(' - ')[2], 'image': image, 'url': url, 'plot': plot, 'comment': plot, 'duration': duration, 'genre': genre }) self.list.append(item_data) return self.list
def wrapper(url): if replace_url: result = re.sub( r'''https?://(?:[0-9A-Z-]+\.)?(?:(youtu\.be|youtube(?:-nocookie)?\.com)/?\S*?[^\w\s-])([\w-]{11})(?=[^\w-]|$)(?![?=&+%\w.-]*(?:['"][^<>]*>|</a>))[?=&+%\w.-]*''', yt_prefix + r'\2', url, flags=re.I ) if url != result: return result streams = youtube_resolver.resolve(url) try: addon_enabled = control.addon_details('inputstream.adaptive').get('enabled') except KeyError: addon_enabled = False if not addon_enabled: streams = [s for s in streams if 'dash' not in s['title'].lower()] if control.condVisibility('Window.IsVisible(music)') and control.setting('audio_only') == 'true': audio_choices = [u for u in streams if 'dash/audio' in u and 'dash/video' not in u] if control.setting('yt_quality_picker') == '0': resolved = audio_choices[0]['url'] else: qualities = [i['title'] for i in audio_choices] urls = [i['url'] for i in audio_choices] resolved = stream_picker(qualities, urls) return resolved elif control.setting('yt_quality_picker') == '1': qualities = [i['title'] for i in streams] urls = [i['url'] for i in streams] resolved = stream_picker(qualities, urls) return resolved else: resolved = streams[0]['url'] return resolved
def sl_hosts(url): return any([ 'dailymotion' in url and control.setting('dm_resolve') == '1', 'twitch' in url, 'facebook' in url, 'ttvnw' in url, 'periscope' in url and not 'search' in url, 'pscp' in url, 'ant1.com.cy' in url and 'web-tv-live' in url, 'gr.euronews.com' in url and not 'watchlive.json' in url, 'filmon.com' in url, 'ellinikosfm.com' in url, 'kineskop.tv' in url, 'player.vimeo.com' in url, 'antenna.gr' in url and 'Live' in url, 'star.gr/tv/live-stream/' in url, 'omegatv' in url and 'live' in url, control.setting('ol_resolve') == '1' and re.search(openload_regex, url) ])
def geo_loc(): json_obj = client.request('http://extreme-ip-lookup.com/json/') if not json_obj or 'error' in json_obj: json_obj = client.request('http://ip-api.com/json/') if control.setting('geoloc_override') == '0': country = json.loads(json_obj)['country'] return country elif control.setting('geoloc_override') == '1': return 'Greece' else: return 'Worldwide'
def seq(): conditions = [ bool( control.addon('plugin.video.youtube').getSetting( 'youtube.api.id')), bool( control.addon('plugin.video.youtube').getSetting( 'youtube.api.key')), bool( control.addon('plugin.video.youtube').getSetting( 'youtube.api.secret')) ] if int(YT_VERSION) >= 670: conditions.insert( 0, control.addon('plugin.video.youtube').getSetting( 'youtube.api.enable') == 'true') if any(conditions) and bool(control.setting('local')) or bool( control.setting('remote')): control.okDialog(control.addonInfo('name'), control.lang(30017)) if not bool(control.setting('local')) and not bool( control.setting('remote')): result = None elif control.setting('local_or_remote') == '0': result = local(control.setting('local')) else: result = remote(control.setting('remote')) if not result: control.okDialog(control.lang(30010), control.lang(30011)) else: if control.yesnoDialog(line1=control.lang(30012), line2='', line3='', yeslabel=control.lang(30013), nolabel=control.lang(30014)): setup(result) if control.setting('wizard') == 'true': wizard() else: pass else: control.infoDialog(control.lang(30014))
def reset_idx(notify=True, force=False): if control.setting('reset_idx') == 'true' or force: if control.setting('reset_live') == 'true' or force: control.setSetting('live_group', '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 mini_picker(hl, sl, params): try: image = params.get('image').encode('latin-1') title = params.get('title').encode('latin-1') except (UnicodeEncodeError, UnicodeDecodeError, AttributeError): image = params.get('image') title = params.get('title') if len(hl) == 1: stream = cache.get(gm_debris, 12, sl[0]) if control.setting('action_type') == '2': if control.setting('auto_play') == 'true': play_url = sysaddon + play_action + quote( stream) + '&image=' + quote(image) + '&title=' + quote( title) control.execute('PlayMedia("{0}")'.format(play_url)) else: m3u_file = playlist_maker(hl, sl, title, image) control.playlist().load(m3u_file) control.openPlaylist() else: control.infoDialog(hl[0]) return stream elif control.setting('action_type') == '2': m3u_file = playlist_maker(hl, sl, title, image) control.playlist().load(m3u_file) if control.setting('auto_play') == 'true': control.execute('Action(Play)') else: control.openPlaylist() return else: choice = control.selectDialog(heading=control.lang(30064), list=hl) if choice <= len(sl) and not choice == -1: popped = sl[choice] return cache.get(gm_debris, 12, popped) else: return
def trim_history(): """ Trims history to what is set in settings :return: """ history_size = int(control.setting('history_size')) if is_py3: f = open(HISTORY, 'r', encoding='utf-8') else: f = codecs.open(HISTORY, 'r', encoding='utf-8') text = [i.rstrip('\n') for i in f.readlines()][::-1] f.close() if len(text) > history_size: if is_py3: f = open(HISTORY, 'w', encoding='utf-8') else: f = codecs.open(HISTORY, 'w', encoding='utf-8') dif = history_size - len(text) result = text[:dif][::-1] f.write('\n'.join(result) + '\n') f.close()
def text_viewer(text, title=None, permalink=None): if control.setting('single.button') == 'true': choice = control.selectDialog( [control.lang(30158), control.lang(30100), control.lang(30159)]) if choice == 0: view_text(text, title) elif choice == 1: if permalink.startswith('http'): window_activate(url=permalink, jump=True) else: window_activate(query=permalink, jump=True) elif choice == 2: control.execute('Action(ContextMenu)') else: view_text(text, title)