def set_controls(self): image = pyxbmct.Image(control.fanart(), aspectRatio=2) self.placeControl(image, 0, 0, 5, 3) # Note self.description = pyxbmct.Label(control.lang(30328), alignment=2) self.placeControl(self.description, 5, 0, 2, 3) # Click to open label # self.external_label = pyxbmct.Label(control.lang(30131), alignment=pyxbmct.ALIGN_CENTER_Y | pyxbmct.ALIGN_CENTER_X) # self.placeControl(self.external_label, 6, 0, 1, 1) # Twitter button self.twitter_button = pyxbmct.Button('Twitter') self.placeControl(self.twitter_button, 6, 0) self.connect(self.twitter_button, lambda: control.open_web_browser(TWITTER)) # Website self.website_button = pyxbmct.Button(control.lang(30333)) self.placeControl(self.website_button, 6, 1) self.connect(self.website_button, lambda: control.open_web_browser(WEBSITE)) # Facebook button self.facebook_button = pyxbmct.Button('Facebook') self.placeControl(self.facebook_button, 6, 2) self.connect(self.facebook_button, lambda: control.open_web_browser(FACEBOOK)) # Close button self.close_button = pyxbmct.Button(control.lang(30329)) self.placeControl(self.close_button, 7, 1) self.connect(self.close_button, self.close) # Changelog button self.changelog_button = pyxbmct.Button(control.lang(30110)) self.placeControl(self.changelog_button, 7, 0) self.connect(self.changelog_button, lambda: changelog()) # Disclaimer button self.disclaimer_button = pyxbmct.Button(control.lang(30129)) self.placeControl(self.disclaimer_button, 7, 2) self.connect(self.disclaimer_button, lambda: disclaimer())
def set_controls(self): image = pyxbmct.Image(control.fanart(), aspectRatio=2) self.placeControl(image, 0, 0, 5, 5) # Note self.description = pyxbmct.Label(control.lang(30328), alignment=2) self.placeControl(self.description, 5, 0, 2, 5) # Click to open label # self.external_label = pyxbmct.Label(control.lang(30131), alignment=pyxbmct.ALIGN_CENTER_Y | pyxbmct.ALIGN_CENTER_X) # self.placeControl(self.external_label, 6, 0, 1, 1) self.website_button = pyxbmct.Button(control.lang(30333)) self.placeControl(self.website_button, 6, 0, 1, 1) self.connect(self.website_button, lambda: control.open_web_browser('https://www.alivegr.net')) # Paypal button self.paypal_button = pyxbmct.Button(control.lang(30141)) self.placeControl(self.paypal_button, 6, 2, 1, 1) self.connect(self.paypal_button, lambda: control.open_web_browser('https://www.paypal.me/AliveGR')) # Patreon button self.patreon_button = pyxbmct.Button(control.lang(30142)) self.placeControl(self.patreon_button, 6, 1, 1, 1) self.connect(self.patreon_button, lambda: control.open_web_browser('https://www.patreon.com/twilight0')) # Facebook button self.facebook_button = pyxbmct.Button('Facebook') self.placeControl(self.facebook_button, 6, 3, 1, 1) self.connect(self.facebook_button, lambda: control.open_web_browser('https://www.facebook.com/alivegr/')) # Twitter button self.twitter_button = pyxbmct.Button('Twitter') self.placeControl(self.twitter_button, 6, 4, 1, 1) self.connect(self.twitter_button, lambda: control.open_web_browser('https://twitter.com/TwilightZer0')) # Close button self.close_button = pyxbmct.Button(control.lang(30329)) self.placeControl(self.close_button, 7, 2) self.connect(self.close_button, self.close) # Changelog button self.changelog_button = pyxbmct.Button(control.lang(30110)) self.placeControl(self.changelog_button, 7, 0, 1, 2) self.connect(self.changelog_button, lambda: changelog()) # Disclaimer button self.disclaimer_button = pyxbmct.Button(control.lang(30129)) self.placeControl(self.disclaimer_button, 7, 3, 1, 2) self.connect(self.disclaimer_button, lambda: disclaimer())
def set_controls(self): image = pyxbmct.Image(control.fanart(), aspectRatio=2) self.placeControl(image, 0, 0, 5, 3) # Note self.description = pyxbmct.Label(control.lang(30356).format(remote_version()), alignment=2) self.placeControl(self.description, 5, 0, 2, 3) # Yes button self.yes_button = pyxbmct.Button(control.lang(30357)) self.placeControl(self.yes_button, 6, 0) self.connect(self.yes_button, lambda: force_()) # No button self.no_button = pyxbmct.Button(control.lang(30358)) self.placeControl(self.no_button, 6, 1) self.connect(self.no_button, self.close) # Do not ask again button self.do_not_ask_again_button = pyxbmct.Button(control.lang(30359)) self.placeControl(self.do_not_ask_again_button, 6, 2) self.connect(self.do_not_ask_again_button, lambda: do_not_ask_again()) # Close button self.close_button = pyxbmct.Button(control.lang(30329)) self.placeControl(self.close_button, 7, 0, 1, 3) self.connect(self.close_button, self.close)
def recursive_list_items(url): page = 1 if url.startswith('https'): if BASE_API_LINK not in url: html = client.request(url) script = [ i for i in client.parseDOM(html, 'script') if 'INITIAL_STATE' in i ][0] script = re.sub(r'var _*?\w+_*? = ', '', script).replace(';</script>', '') if script.endswith(';'): script = script[:-1] _json = json.loads(script) else: _json = client.request(url, output='json') if '/list' in url: codename = split(url)[1].partition('=')[2] total_pages = _json['pages']['sectionsByCodename'][codename][ 'totalPages'] page = _json['pages']['sectionsByCodename'][codename][ 'fetchedPage'] tiles = _json['pages']['sectionsByCodename'][codename]['tilesIds'] tiles_post_list = [{'id': i} for i in tiles] else: tiles = [] if 'GetSeriesDetails' in url: episode_groups = _json['episodeGroups'] for group in episode_groups: episodes = group['episodes'] for episode in episodes: codename = episode['id'] tiles.append(codename) tiles_post_list = [{'id': i} for i in tiles] total_pages = 1 else: codenames = list(_json['pages']['sectionsByCodename'].keys()) for codename in codenames: tiles_list = _json['pages']['sectionsByCodename'][ codename]['tilesIds'] tiles.extend(tiles_list) tiles_post_list = [{'id': i} for i in tiles] total_pages = 1 else: if url.startswith('{"platformCodename":"www"'): collection_json = json.loads(url) url = collection_json['orCollectionCodenames'] page = collection_json['page'] filter_tiles = client.request(FILTER_TILES, post=collection_post(url, page), output='json') total_pages = filter_tiles['pagination']['totalPages'] page = filter_tiles['pagination']['page'] tiles = filter_tiles['tiles'] tiles_post_list = [{'id': i['id']} for i in tiles] if total_pages > 1 and page < total_pages: page = page + 1 next_post = collection_post(url, page) else: next_post = None get_tiles = client.request(GET_TILES, post=tiles_post(tiles_post_list), output='json') tiles_list = get_tiles['tiles'] self_list = [] for tile in tiles_list: if tile['isRegionRestrictionEnabled'] and not geo_detect: continue title = tile['title'] if 'subtitle' in tile: title = ' - '.join([title, tile['subtitle']]) try: if tile.get('isEpisode'): try: season = ' '.join([ control.lang(30063), str(tile['season']['seasonNumber']) ]) except KeyError: season = None if not season: subtitle = ' '.join( [control.lang(30064), str(tile['episodeNumber'])]) else: try: subtitle = ''.join([ season, ', ', control.lang(30064), ' ', str(tile['episodeNumber']) ]) except KeyError: subtitle = tile['publishDate'].partition('T')[0] subtitle = '/'.join(subtitle.split('-')[::-1]) title = '[CR]'.join([title, subtitle]) except Exception: pass images = tile['images'] fanart = control.fanart() if len(images) == 1: image = images[0]['url'] else: image_list = [ [i['url'] for i in images if i['isMain']], [i['url'] for i in images if i['role'] == 'hbbtv-icon'], [i['url'] for i in images if i['role'] == 'photo'], [i['url'] for i in images if i['role'] == 'hbbtv-background'] ] image = images[0]['url'] for i in image_list: if i: image = i[0] break fanart_list = [[ i['url'] for i in images if i['role'] == 'photo-details' ], [i['url'] for i in images if i['role'] == 'hbbtv-background'], [ i['url'] for i in images if i['role'] == 'photo' and 'ertflix-background' in i['url'] ]] for f in fanart_list: if f and len(f) > 1: fanart = f[1] break elif f and len(f) == 1: fanart = f[0] break codename = tile['codename'] vid = tile['id'] plots = [ tile.get('description'), tile.get('shortDescription'), tile.get('tinyDescription'), tile.get('subtitle'), tile.get('subTitle') ] plot = control.lang(30014) for p in plots: if p: plot = client.stripTags(p) plot = client.replaceHTMLCodes(plot) break year = tile.get('year') if not year: try: year = int(tile.get('productionYears')[:4]) except Exception: year = 2021 if tile.get('hasPlayableStream') and not tile.get('type') == 'ser': url = VOD_LINK.format('-'.join([vid, codename])) else: url = GET_SERIES_DETAILS.format(vid) data = { 'title': title, 'image': image, 'fanart': fanart, 'url': url, 'plot': plot, 'year': year } if tile.get('durationSeconds'): data.update({'duration': tile.get('durationSeconds')}) if next_post: data.update({ 'next': next_post, 'nextaction': 'listing', 'nextlabel': 30500, 'nexticon': control.addonmedia('next.jpg') }) if tile.get('hasPlayableStream') and not tile.get('type') == 'ser': data.update({'action': 'play', 'isFolder': 'False'}) else: data.update({'action': 'listing'}) self_list.append(data) return self_list
def image_generator(children_data): print(children_data) image = control.addonInfo('icon') fanart = control.fanart() try: try: m_thumb = children_data.get('media').get('oembed').get( 'thumbnail_url') except AttributeError: m_thumb = None try: s_thumb = children_data.get('secure_media').get( 'oembed').get('thumbnail_url') except AttributeError: s_thumb = None try: p_thumb = children_data.get('preview').get('oembed').get( 'thumbnail_url') except AttributeError: p_thumb = None try: u_thumb = children_data.get('preview').get( 'images')[0].get('source').get('url') except AttributeError: u_thumb = None images = [ children_data.get('community_icon'), children_data.get('icon_img'), children_data.get('header_img'), children_data.get('thumbnail'), children_data.get('icon_img'), children_data.get('header_img'), children_data.get('banner_img'), children_data.get('url') ] if m_thumb: images.insert(-2, m_thumb) if s_thumb: images.insert(-2, s_thumb) if p_thumb: images.insert(-2, p_thumb) if u_thumb: images.insert(-2, u_thumb) for i in images: if i in ['default', 'spoiler', 'image', 'self'] or not i: continue elif '.jpg' in i or '.png' in i: image = i break if '?' in image: image = image.partition('?')[0] except (KeyError, IndexError, TypeError): pass if 'embed.ly' in image: image = dict(parse_qsl(urlparse(image).query))['url'] try: try: p_fanart = children_data.get('preview').get( 'images')[0].get('source').get('url') except AttributeError: p_fanart = None try: s_fanart = children_data.get('secure_media').get( 'oembed').get('thumbnail_url') except AttributeError: s_fanart = None fanarts = [children_data.get('banner_background_image')] if p_fanart: fanarts.insert(0, p_fanart) if s_fanart: fanarts.insert(-1, s_fanart) for f in fanarts: if not f: continue elif f: fanart = f break if '?' in fanart: fanart = fanart.partition('?')[0] except (KeyError, IndexError): pass return image, fanart