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 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 persons_index(self, url, post, get_list=True): if CACHE_DEBUG: self.list = self.persons_listing(url, post) else: self.list = cache.get(self.persons_listing, 48, url, post) if self.list is None: return for item in self.list: item.update({'action': 'listing', 'icon': iconname('user')}) bookmark = dict( (k, v) for k, v in iteritems(item) if not k == 'next') bookmark['bookmark'] = item['url'] bookmark_cm = { 'title': 30080, 'query': { 'action': 'addBookmark', 'url': json.dumps(bookmark) } } refresh_cm = {'title': 30054, 'query': {'action': 'refresh'}} item.update({'cm': [bookmark_cm, refresh_cm]}) if get_list: return self.list else: directory.add(self.list)
def techno_choices(self, url): self.list = cache.get(youtube.youtube(key=thgiliwt(api_keys['api_key']), replace_url=replace_url).playlist, 12, url) if self.list is None: return for i in self.list: i['label'] = i.pop('title') # process stupid descriptions/comments put up by uploaders on labels i['label'] = re.sub(r'PREMIERE ?:|\(full version\)\.mp4|\(?(?:Un)?Official.*\)? ?(?:HD)?|\[?HD (?:108|72)0p\]?', '', i['label'], flags=re.IGNORECASE) for count, i in list(enumerate(self.list, start=1)): if '–' in i['label']: sep = '–' elif ':' in i['label'] and not '-' in i['label']: sep = ':' elif '-' in i['label']: sep = '-' else: sep = ' ' artist, separator, title = i['label'].partition(sep) if '&' in artist: artists_separator = '&' elif ',' in artist: artists_separator = ',' elif 'feat.' in artist: artists_separator = 'feat.' elif 'feat' in artist: artists_separator = 'feat' elif 'Feat' in artist: artists_separator = 'Feat' else: artists_separator = None if artists_separator: artist = [a.strip() for a in artist.split(artists_separator)] on_label = ' / '.join(artist) else: on_label = artist.strip() artist = [artist.strip()] i.update( { 'action': 'play', 'isFolder': 'False', 'title': title, 'label': ' '.join([on_label, separator , title]), 'album': control.lang(30292), 'fanart': 'https://i.ytimg.com/vi/vtjL9IeowUs/maxresdefault.jpg', 'tracknumber': count, 'count': count, 'artist': artist } ) if control.setting('audio_only') == 'true' and control.condVisibility('Window.IsVisible(music)'): i['artist'] = on_label control.sortmethods('tracknum', mask='%A') directory.add(self.list, content=self.content, infotype=self.infotype, argv=self.argv)
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 archive(self): self.list = cache.get( youtube.youtube(key=self.yt_key).playlists, 12, self.yt_channel) if self.list is None: return for i in self.list: i['title'] = client.replaceHTMLCodes(i['title']) i.update({'action': 'episodes'}) bookmark = dict((k, v) for k, v in iteritems(i) if not k == 'next') bookmark['bookmark'] = i['url'] i.update({ 'cm': [{ 'title': 32501, 'query': { 'action': 'addBookmark', 'url': json.dumps(bookmark) } }] }) control.sortmethods('title') directory.add(self.list, content='videos')
def shows(self, url): self.list = cache.get(self.generic_listing, 24, url) if self.list is None: return for i in self.list: i.update({'action': 'episodes'}) bookmark = dict((k, v) for k, v in iteritems(i) if not k == 'next') bookmark['bookmark'] = i['url'] i.update({ 'cm': [{ 'title': 32501, 'query': { 'action': 'addBookmark', 'url': json.dumps(bookmark) } }] }) directory.add(self.list, content='videos')
def directory_picker(url, argv): params = dict(parse_qsl(argv[2].replace('?', ''))) items = cache.get(items_directory, 12, url, params) if items is None: return for i in items: add_to_playlist = { 'title': 30226, 'query': { 'action': 'add_to_playlist' } } clear_playlist = { 'title': 30227, 'query': { 'action': 'clear_playlist' } } i.update({ 'cm': [add_to_playlist, clear_playlist], 'action': 'play', 'isFolder': 'False' }) directory.add(items, content='movies', argv=argv)
def playlist(plid): ilist = cache.get(youtube.youtube(key=key).playlist, 12, plid) if ilist is None: return for i in ilist: i.update({'action': 'play', 'isFolder': 'False'}) for item in ilist: bookmark = dict((k, v) for k, v in item.iteritems() if not k == 'next') bookmark['bookmark'] = item['url'] bm_cm = { 'title': 30006, 'query': { 'action': 'addBookmark', 'url': json.dumps(bookmark) } } refresh = {'title': 30008, 'query': {'action': 'refresh'}} cache_clear = {'title': 30005, 'query': {'action': 'cache_clear'}} item.update({'cm': [refresh, cache_clear, bm_cm]}) directory.add(ilist, content='videos')
def podcasts(self, url=None): if url is None: url = self.podcasts_link self.list = cache.get(self.pod_listing, 24, url) if self.list is None: return for i in self.list: i.update({'action': 'episodes'}) bookmark = dict((k, v) for k, v in iteritems(i) if not k == 'next') bookmark['bookmark'] = i['url'] i.update({ 'cm': [{ 'title': 32501, 'query': { 'action': 'addBookmark', 'url': json.dumps(bookmark) } }] }) directory.add(self.list, content='music')
def gk_filler(url): items = [] if CACHE_DEBUG: sources = gk_debris(url) else: sources = cache.get(gk_debris, 6, url) lists = list(zip(sources['hosts'], sources['links'])) t = sources['title'] y = sources['year'] i = sources['image'] d = sources['duration'] for h, l in lists: label = SEPARATOR.join([t, h]) data = { 'label': label, 'title': '{0} ({1})'.format(t, y), 'url': l, 'image': i, 'year': y, 'duration': d } items.append(data) return items
def events(self, url): self.list = cache.get(self.event_list, 12, url) if self.list is None: log_debug( 'Events section failed to load, try resetting indexer methods') return for item in self.list: bookmark = dict( (k, v) for k, v in iteritems(item) if not k == 'next') bookmark['bookmark'] = item['url'] bookmark_cm = { 'title': 30080, 'query': { 'action': 'addBookmark', 'url': json.dumps(bookmark) } } item.update({ 'cm': [bookmark_cm], 'action': 'play', 'isFolder': 'False' }) directory.add(self.list)
def mgreekz_top10(self): self.list = cache.get(self._mgreekz_top10, 24) if self.list is None: log_debug('Mad Greekz top 10 section failed to load') return for item in self.list: item.update({'action': 'play', 'isFolder': 'False'}) for count, item in list(enumerate(self.list, start=1)): add_to_playlist = {'title': 30226, 'query': {'action': 'add_to_playlist'}} clear_playlist = {'title': 30227, 'query': {'action': 'clear_playlist'}} item.update( { 'cm': [add_to_playlist, clear_playlist], 'album': control.lang(30127), 'fanart': control.addonmedia( addonid=art_id, theme='networks', icon='mgz_fanart.jpg', media_subfolder=False ), 'tracknumber': count, 'code': count } ) control.sortmethods('tracknum', mask='%A') directory.add(self.list, content=self.content, infotype=self.infotype, argv=self.argv)
def download(self, path, url): try: cookie = None anonymous = (self.user == '' or self.password == '') code, result = client.request(url, output='response', error=True) if code == '429' and anonymous is True: control.dialog.ok(str('xsubs.tv'), str(result), str('')) return elif anonymous is False: cookie = cache.get(self.cookie, 6) result, headers, content, cookie = client.request( url, cookie=cookie, output='extended') subtitle = content['Content-Disposition'] subtitle = re.findall('"(.+?)"', subtitle)[0] subtitle = os.path.join(path, subtitle.decode('utf-8')) if not subtitle.endswith('.srt'): raise Exception() with open(subtitle, 'wb') as subFile: subFile.write(result) return subtitle except: pass
def archive(self): self.list = cache.get(self.items_list, 24, self.archive_link) if self.list is None: return for i in self.list: i.update({'action': 'reverseEpisodes'}) for i in self.list: bookmark = dict( (k, v) for k, v in i.iteritems() if not k == 'next') bookmark['bookmark'] = i['url'] i.update({ 'cm': [{ 'title': 32501, 'query': { 'action': 'addBookmark', 'url': json.dumps(bookmark) } }] }) self.list = sorted(self.list, key=lambda k: k['title'].lower()) directory.add(self.list, content='videos')
def spoofer(headers=None, _agent=True, age_str=None, referer=False, ref_str='', url=None): if age_str is None: from tulip import cache age_str = cache.get(randomagent, 12) pipe = '|' if not headers: headers = {} if _agent and age_str and not headers: headers.update({'User-Agent': age_str}) if referer and ref_str: headers.update({'Referer': ref_str}) if headers: string = pipe + urlencode(headers) if url: url += string return url else: return string else: return ''
def gm_sports(self): if CACHE_DEBUG: html = root(SPORTS) else: html = cache.get(root, 48, SPORTS) options = re.compile('(<option value.+?</option>)', re.U).findall(html) icons = [ 'https://www.shareicon.net/data/256x256/2015/11/08/157712_sport_512x512.png', 'https://www.shareicon.net/data/256x256/2015/12/07/196797_ball_256x256.png' ] items = zip(options, icons) for item, image in items: title = client.parseDOM(item, 'option')[0] url = client.parseDOM(item, 'option', ret='value')[0] url = client.replaceHTMLCodes(url) index = urljoin(GM_BASE, url) data = { 'title': title, 'action': 'listing', 'url': index, 'image': image } self.list.append(data) directory.add(self.list)
def episodes(self, url): if CACHE_DEBUG: self.list = self.epeisodia(url) else: self.list = cache.get(self.epeisodia, 12, url) if self.list is None: log_debug( 'Episode section failed to load, try resetting indexer methods' ) return for item in self.list: item.update({'action': 'play', 'isFolder': 'False'}) for item in self.list: refresh_cm = {'title': 30054, 'query': {'action': 'refresh'}} item.update({'cm': [refresh_cm]}) if control.setting('episodes_reverse') == 'true': self.list = sorted( self.list, key=lambda k: k['group'] if k['group'] in ['1bynumber', '2bydate'] else k['title'], reverse=True)[::-1] else: self.list = sorted(self.list, key=lambda k: k['group']) if len(self.list) > int( control.setting('pagination_integer')) and control.setting( 'paginate_items') == 'true': try: pages = list_divider( self.list, int(control.setting('pagination_integer'))) self.list = pages[int(control.setting('page'))] reset = False except Exception: pages = list_divider( self.list, int(control.setting('pagination_integer'))) self.list = pages[0] reset = True self.list.insert(0, page_menu(len(pages), reset=reset)) control.sortmethods() # control.sortmethods('title') # control.sortmethods('year') directory.add(self.list, content='episodes')
def music_list(self, url): html = client.request(url) try: html = html.decode('utf-8') except Exception: pass if 'albumlist' in html: artist = [client.parseDOM(html, 'h4')[0].partition(' <a')[0]] else: artist = None if control.setting('audio_only') == 'true' and control.condVisibility('Window.IsVisible(music)') and artist is not None: artist = ''.join(artist) if 'songlist' in html: songlist = client.parseDOM(html, 'div', attrs={'class': 'songlist'})[0] items = client.parseDOM(songlist, 'li') elif 'albumlist' in html: albumlist = client.parseDOM(html, 'div', attrs={'class': 'albumlist'})[0] items = client.parseDOM(albumlist, 'li') else: artistlist = client.parseDOM(html, 'div', attrs={'class': 'artistlist'})[0] items = client.parseDOM(artistlist, 'li') if 'icon/music' in html: icon = client.parseDOM(html, 'img', attrs={'class': 'img-responsive'}, ret='src')[-1] icon = urljoin(gm.GM_BASE, icon) else: icon = iconname('music') for item in items: title = client.parseDOM(item, 'a')[0] link = client.parseDOM(item, 'a', ret='href')[0] link = urljoin(gm.GM_BASE, link) if 'gapi.client.setApiKey' in html: if CACHE_DEBUG: link = gm.source_maker(url)['links'][0] else: link = cache.get(gm.source_maker, 48, url)['links'][0] data = {'title': title, 'url': link, 'image': icon} if artist: data.update({'artist': artist}) self.list.append(data) return self.list
def programs(self): self.list = cache.get(self.item_list_1, 24, self.programs_link, self.lang) if self.list == None: return for i in self.list: i.update({'action': 'videos'}) directory.add(self.list, content='videos') return self.list
def videos(self, url): self.list = cache.get(self.item_list_2, 1, url, self.lang) if self.list == None: return for i in self.list: i.update({'action': 'play', 'isFolder': 'False'}) directory.add(self.list, content='videos') return self.list
def episodes(self, url): if self.base_link in url: self.list = cache.get(self.episodes_listing, 3, url) elif self.radio_base in url: self.list = cache.get(self.pod_episodes, 3, url) else: self.list = cache.get( youtube.youtube(key=self.yt_key).playlist, 3, url) if self.list is None: return for i in self.list: i.update({'action': 'play', 'isFolder': 'False'}) directory.add(self.list, content='videos')
def meta_viewer(url): heading = control.infoLabel('Listitem.Label') if control.setting('debug') == 'false': plot = cache.get(_plot, 96, url) else: plot = _plot(url) control.dialog.textviewer(heading=heading, text=plot)
def download(self, path, url): try: cookie = None anonymous = (self.user == '' or self.password == '') code, result = client.request(url, output='response', error=True) if code == '429' and anonymous is True: control.dialog.ok(str('xsubs.tv'), str(result), str('')) return elif anonymous is False: cookie = cache.get(self.cookie, 12) result, headers, content, cookie = client.request( url, cookie=cookie, output='extended') subtitle = content['Content-Disposition'] subtitle = re.findall('"(.+?)"', subtitle)[0] try: subtitle = subtitle.decode('utf-8') except Exception: pass subtitle = control.join(path, subtitle) if not subtitle.endswith('.srt'): raise Exception() with open(subtitle, 'wb') as subFile: subFile.write(result) fileparts = os_split(subtitle)[1].split('.') result = control.join( os_split(subtitle)[0], 'subtitles.' + fileparts[len(fileparts) - 1]) rename(subtitle, result) return result except Exception as e: log.log( 'Xsubstv subtitle download failed for the following reason: ' + str(e)) return
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 videos(self, url): self.list = cache.get(self.video_listing, 3, url) if self.list is None: return for i in self.list: i.update({'action': 'play', 'isFolder': 'False'}) directory.add(self.list)
def miscellany(self): if control.setting('debug') == 'true': self.data = cache.get(self.misc_list, int(control.setting('cache_period'))) else: self.data = cache.get(self.misc_list, 24) if self.data is None: log_debug('Misc channels list did not load successfully') return 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(self.syshandle, self.list) control.directory(self.syshandle)
def wrapper(url): if url.endswith('/live'): if CACHE_DEBUG: url = generic(url) else: url = cache.get(generic, 6, 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] 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 kineskop(url): """Deprecated method""" html = client.request(url) stream = re.search(r"getURLParam\('src','(.+?)'", html).group(1) headers = {'User-Agent': cache.get(randomagent, 12), 'Origin': 'http://kineskop.tv', 'Referer': url} output = stream + spoofer(headers=headers) return output
def episodes(self, url, reverse=False): self.list = cache.get(self.items_list, 1, url) if self.list is None: return for i in self.list: i.update({'action': 'play', 'isFolder': 'False'}) if reverse is True: self.list = self.list[::-1] directory.add(self.list, content='videos')