def nhlResolve(url): try: try: url, selectGame, side = re.compile('(.+?)x0xe(.+?)x0xe(.+?)$').findall(url)[0] except: selectGame, side = None, None header = '|' + urllib.urlencode({'User-Agent': 'PS4 libhttp/1.76 (PlayStation 4)'}) base = re.compile('(.*/).+[.]m3u8').findall(url) if not url.endswith('m3u8'): return player().run(url + header, selectGame ,side) result = client.request(url) result = re.compile('BANDWIDTH=(\d*)\n(.+?[.]m3u8)').findall(result) result = [(int(int(i[0]) / 1000), i[1]) for i in result] result = sorted(result, reverse=True) result = [(str(i[0]), base[0] + i[1]) for i in result] q = [i[0] for i in result] u = [i[1] for i in result] select = control.selectDialog(q, control.lang(30756).encode('utf-8')) if select == -1: return url = u[select] player().run(url + header, selectGame ,side) except: return
def sourcesDialog(self): try: sources = [{'label': '00 | [B]%s[/B]' % control.lang(30509).encode('utf-8').upper()}] + self.sources labels = [i['label'] for i in sources] select = control.selectDialog(labels) if select == 0: return self.sourcesDirect() if select == -1: return 'close://' items = [self.sources[select-1]] source, quality = items[0]['source'], items[0]['quality'] next = [y for x,y in enumerate(self.sources) if x >= select] prev = [y for x,y in enumerate(self.sources) if x < select][::-1] items = [i for i in items+next+prev if i['quality'] == quality and i['source'] == source] items += [i for i in next+prev if i['quality'] == quality and not i['source'] == source] items = items[:30] for i in items: try: url = self.sourcesResolve(i['url'], i['provider']) if url == None: raise Exception() self.selectedSource = i['label'] return url except: pass except: return
def sourcesDialog(self): try: sources = [{'label': '00 | [B]%s[/B]' % control.lang(30509).encode('utf-8').upper()}] + self.sources labels = [i['label'] for i in sources] select = control.selectDialog(labels) if select == 0: return self.sourcesDirect() if select == -1: return 'close://' items = [self.sources[select-1]] next = [y for x,y in enumerate(self.sources) if x >= select] prev = [y for x,y in enumerate(self.sources) if x < select][::-1] source, quality = items[0]['source'], items[0]['quality'] items = [i for i in items+next+prev if i['quality'] == quality and i['source'] == source][:10] items += [i for i in next+prev if i['quality'] == quality and not i['source'] == source][:10] self.progressDialog = control.progressDialog self.progressDialog.create(control.addonInfo('name'), '') self.progressDialog.update(0) block = None for i in range(len(items)): try: self.progressDialog.update(int((100 / float(len(items))) * i), str(items[i]['label']), str(' ')) if items[i]['source'] == block: raise Exception() w = workers.Thread(self.sourcesResolve, items[i]['url'], items[i]['provider']) w.start() for x in range(0, 15 * 2): if self.progressDialog.iscanceled(): return self.progressDialog.close() if xbmc.abortRequested == True: return sys.exit() if w.is_alive() == False: break time.sleep(0.5) if w.is_alive() == True: block = items[i]['source'] if self.url == None: raise Exception() self.selectedSource = items[i]['label'] return self.url except: pass except: return
def sourcesDialog(self): try: l = '00 | [B]%s[/B]' % control.lang(30509).encode('utf-8').upper() sourceList = [l] ; urlList = [''] ; providerList = [''] for i in self.sources: sourceList.append(i['label']) ; urlList.append(i['url']) ; providerList.append(i['provider']) select = control.selectDialog(sourceList) if select == 0: return self.sourcesDirect() if select == -1: return 'close://' url = self.sourcesResolve(urlList[select], providerList[select]) self.selectedSource = self.sources[select-1]['label'] return url except: return
def manager(name, imdb, tvdb, content): try: user, password = getTraktCredentials() post = {"movies": [{"ids": {"imdb": imdb}}]} if content == 'movie' else {"shows": [{"ids": {"tvdb": tvdb}}]} items = [(control.lang(30472).encode('utf-8'), '/sync/collection')] items += [(control.lang(30473).encode('utf-8'), '/sync/collection/remove')] items += [(control.lang(30474).encode('utf-8'), '/sync/watchlist')] items += [(control.lang(30475).encode('utf-8'), '/sync/watchlist/remove')] items += [(control.lang(30476).encode('utf-8'), '/users/%s/lists/%s/items' % (user, '%s'))] result = getTrakt('/users/%s/lists' % user) result = json.loads(result) lists = [(i['name'], i['ids']['slug']) for i in result] lists = [lists[i//2] for i in range(len(lists)*2)] for i in range(0, len(lists), 2): lists[i] = ((control.lang(30477) + ' ' + lists[i][0]).encode('utf-8'), '/users/%s/lists/%s/items' % (user, lists[i][1])) for i in range(1, len(lists), 2): lists[i] = ((control.lang(30478) + ' ' + lists[i][0]).encode('utf-8'), '/users/%s/lists/%s/items/remove' % (user, lists[i][1])) items += lists select = control.selectDialog([i[0] for i in items], control.lang(30471).encode('utf-8')) if select == -1: return elif select == 4: t = control.lang(30476).encode('utf-8') k = control.keyboard('', t) ; k.doModal() new = k.getText() if k.isConfirmed() else None if (new == None or new == ''): return url = '/users/%s/lists' % user result = getTrakt('/users/%s/lists' % user, post={"name": new, "privacy": "private"}) try: slug = json.loads(result)['ids']['slug'] except: return control.infoDialog('Failed', heading=name) result = getTrakt(items[select][1] % slug, post=post) else: result = getTrakt(items[select][1], post=post) info = 'Successful' if not result == None else 'Failed' control.infoDialog(info, heading=name) except: return
def manager(name, imdb, tvdb, content): try: post = {"movies": [{"ids": {"imdb": imdb}}]} if content == 'movie' else {"shows": [{"ids": {"tvdb": tvdb}}]} items = [(control.lang(32516).encode('utf-8'), '/sync/collection')] items += [(control.lang(32517).encode('utf-8'), '/sync/collection/remove')] items += [(control.lang(32518).encode('utf-8'), '/sync/watchlist')] items += [(control.lang(32519).encode('utf-8'), '/sync/watchlist/remove')] items += [(control.lang(32520).encode('utf-8'), '/users/me/lists/%s/items')] result = getTrakt('/users/me/lists') result = json.loads(result) lists = [(i['name'], i['ids']['slug']) for i in result] lists = [lists[i//2] for i in range(len(lists)*2)] for i in range(0, len(lists), 2): lists[i] = ((control.lang(32521) % lists[i][0]).encode('utf-8'), '/users/me/lists/%s/items' % lists[i][1]) for i in range(1, len(lists), 2): lists[i] = ((control.lang(32522) % lists[i][0]).encode('utf-8'), '/users/me/lists/%s/items/remove' % lists[i][1]) items += lists select = control.selectDialog([i[0] for i in items], control.lang(32515).encode('utf-8')) if select == -1: return elif select == 4: t = control.lang(32520).encode('utf-8') k = control.keyboard('', t) ; k.doModal() new = k.getText() if k.isConfirmed() else None if (new == None or new == ''): return result = getTrakt('/users/me/lists', post={"name": new, "privacy": "private"}) try: slug = json.loads(result)['ids']['slug'] except: return control.infoDialog(control.lang(32515).encode('utf-8'), heading=str(name), sound=True, icon='ERROR') result = getTrakt(items[select][1] % slug, post=post) else: result = getTrakt(items[select][1], post=post) icon = control.infoLabel('ListItem.Icon') if not result == None else 'ERROR' control.infoDialog(control.lang(32515).encode('utf-8'), heading=str(name), sound=True, icon=icon) except: return
def CCstream(url): try: control.idle() url = urlparse.urljoin('http://kisscartoon.me', url) result = cloudflare.request(url) items = client.parseDOM(result,'select', attrs={'id':'selectQuality'}) items = client.parseDOM(items, 'option', ret='value') url = [] for item in items: try: u = base64.b64decode(item) u = u.encode('utf-8') if u[-3:] == 'm37': q = '1080P' elif u[-3:] == 'm22': q = '720P' elif u[-3:] == 'm18': q = '360P' else: q = 'UNKNOWN' url.append({'q': q, 'u': u}) except: pass if len(url) > 1: q = [i['q'] for i in url] u = [i['u'] for i in url] select = control.selectDialog(q) if select == -1: return url = u[select] else: url = url[0]['u'] player().run(url) except: return
def sourcesDialog(self): try: sources = [{'label': '00 | [B]%s[/B]' % control.lang(30509).encode('utf-8').upper()}] + self.sources labels = [i['label'] for i in sources] select = control.selectDialog(labels) if select == 0: return self.sourcesDirect() if select == -1: return 'close://' items = [self.sources[select-1]] next = [y for x,y in enumerate(self.sources) if x >= select] prev = [y for x,y in enumerate(self.sources) if x < select][::-1] source, quality = items[0]['source'], items[0]['quality'] items = [i for i in items+next+prev if i['quality'] == quality and i['source'] == source][:15] items += [i for i in next+prev if i['quality'] == quality and not i['source'] == source][:35] block = None for i in items: try: if i['source'] == block: raise Exception() w = workers.Thread(self.sourcesResolve, i['url'], i['provider']) w.start() ; time.sleep(20) if w.is_alive() == True: block = i['source'] if self.url == None: raise Exception() self.selectedSource = i['label'] return self.url except: pass except: return
def sourcesDialog(self): try: l = "00 | [B]%s[/B]" % control.lang(30509).encode("utf-8").upper() sourceList = [l] urlList = [""] providerList = [""] for i in self.sources: sourceList.append(i["label"]) urlList.append(i["url"]) providerList.append(i["provider"]) select = control.selectDialog(sourceList) if select == 0: return self.sourcesDirect() if select == -1: return "close://" url = self.sourcesResolve(urlList[select], providerList[select]) self.selectedSource = self.sources[select - 1]["label"] return url except: return
def resolveUrl(name, url, audio, image, fanart, playable, content): try: if '.f4m'in url: label = cleantitle(name) ext = url.split('?')[0].split('&')[0].split('|')[0].rsplit('.')[-1].replace('/', '').lower() if not ext == 'f4m': raise Exception() from resources.lib.libraries.f4mproxy.F4mProxy import f4mProxyHelper return f4mProxyHelper().playF4mLink(url, label, None, None,'',image) #legacy issue, will be removed later if 'afdah.org' in url and not '</source>' in url: url += '<source>afdah</source>' if '</source>' in url: source = re.compile('<source>(.+?)</source>').findall(url)[0] url = re.compile('(.+?)<source>').findall(url)[0] for i in ['_mv', '_tv', '_mv_tv']: try: call = __import__('resources.lib.sources.%s%s' % (source, i), globals(), locals(), ['object'], -1).source() except: pass from resources.lib import sources ; d = sources.sources() url = call.get_sources(url, d.hosthdfullDict, d.hostsdfullDict, d.hostlocDict) if type(url) == list and len(url) == 1: url = url[0]['url'] elif type(url) == list: url = sorted(url, key=lambda k: k['quality']) for i in url: i.update((k, '720p') for k, v in i.iteritems() if v == 'HD') for i in url: i.update((k, '480p') for k, v in i.iteritems() if v == 'SD') q = [i['quality'].upper() for i in url] u = [i['url'] for i in url] select = control.selectDialog(q) if select == -1: return url = u[select] url = call.resolve(url) from resources.lib import resolvers url = resolvers.request(url) if type(url) == list and len(url) == 1: url = url[0]['url'] elif type(url) == list: url = sorted(url, key=lambda k: k['quality']) for i in url: i.update((k, '720p') for k, v in i.iteritems() if v == 'HD') for i in url: i.update((k, '480p') for k, v in i.iteritems() if v == 'SD') q = [i['quality'].upper() for i in url] u = [i['url'] for i in url] select = control.selectDialog(q) if select == -1: return url = u[select] if url == None: raise Exception() except: return control.infoDialog('Unplayable stream') pass if playable == 'true': item = control.item(path=url) return control.resolve(int(sys.argv[1]), True, item) else: label = cleantitle(name) item = control.item(path=url, iconImage=image, thumbnailImage=image) item.setInfo( type='Video', infoLabels = {'title': label} ) control.playlist.clear() control.player.play(url, item)
def manager(name, imdb, tvdb, content): try: post = { "movies": [{ "ids": { "imdb": imdb } }] } if content == 'movie' else { "shows": [{ "ids": { "tvdb": tvdb } }] } items = [(control.lang(32516).encode('utf-8'), '/sync/collection')] items += [(control.lang(32517).encode('utf-8'), '/sync/collection/remove')] items += [(control.lang(32518).encode('utf-8'), '/sync/watchlist')] items += [(control.lang(32519).encode('utf-8'), '/sync/watchlist/remove')] items += [(control.lang(32520).encode('utf-8'), '/users/me/lists/%s/items')] result = getTrakt('/users/me/lists') result = json.loads(result) lists = [(i['name'], i['ids']['slug']) for i in result] lists = [lists[i // 2] for i in range(len(lists) * 2)] for i in range(0, len(lists), 2): lists[i] = ((control.lang(32521) % lists[i][0]).encode('utf-8'), '/users/me/lists/%s/items' % lists[i][1]) for i in range(1, len(lists), 2): lists[i] = ((control.lang(32522) % lists[i][0]).encode('utf-8'), '/users/me/lists/%s/items/remove' % lists[i][1]) items += lists select = control.selectDialog([i[0] for i in items], control.lang(32515).encode('utf-8')) if select == -1: return elif select == 4: t = control.lang(32520).encode('utf-8') k = control.keyboard('', t) k.doModal() new = k.getText() if k.isConfirmed() else None if (new == None or new == ''): return result = getTrakt('/users/me/lists', post={ "name": new, "privacy": "private" }) try: slug = json.loads(result)['ids']['slug'] except: return control.infoDialog(control.lang(32515).encode('utf-8'), heading=str(name), sound=True, icon='ERROR') result = getTrakt(items[select][1] % slug, post=post) else: result = getTrakt(items[select][1], post=post) icon = control.infoLabel( 'ListItem.Icon') if not result == None else 'ERROR' control.infoDialog(control.lang(32515).encode('utf-8'), heading=str(name), sound=True, icon=icon) except: return
def sourcesDialog(self): try: sources = [{'label': '00 | [B]%s[/B]' % control.lang(30509).encode('utf-8').upper()}] + self.sources labels = [i['label'] for i in sources] select = control.selectDialog(labels) if select == 0: return self.sourcesDirect() if select == -1: return 'close://' items = [self.sources[select-1]] next = [y for x,y in enumerate(self.sources) if x >= select] prev = [y for x,y in enumerate(self.sources) if x < select][::-1] source, quality = items[0]['source'], items[0]['quality'] items = [i for i in items+next+prev if i['quality'] == quality and i['source'] == source][:10] items += [i for i in next+prev if i['quality'] == quality and not i['source'] == source][:10] self.progressDialog = control.progressDialog self.progressDialog.create(control.addonInfo('name'), '') self.progressDialog.update(0) block = None for i in range(len(items)): try: if self.progressDialog.iscanceled(): break self.progressDialog.update(int((100 / float(len(items))) * i), str(items[i]['label']), str(' ')) if items[i]['source'] == block: raise Exception() w = workers.Thread(self.sourcesResolve, items[i]['url'], items[i]['provider']) w.start() m = '' for x in range(3600): if self.progressDialog.iscanceled(): return self.progressDialog.close() if xbmc.abortRequested == True: return sys.exit() k = control.condVisibility('Window.IsActive(virtualkeyboard)') if k: m += '1'; m = m[-1] if (w.is_alive() == False or x > 30) and not k: break time.sleep(1) for x in range(30): if m == '': break if self.progressDialog.iscanceled(): return self.progressDialog.close() if xbmc.abortRequested == True: return sys.exit() if w.is_alive() == False: break time.sleep(1) if w.is_alive() == True: block = items[i]['source'] if self.url == None: raise Exception() self.selectedSource = items[i]['label'] self.progressDialog.close() return self.url except: pass try: self.progressDialog.close() except: pass except: try: self.progressDialog.close() except: pass
def manager(name, imdb, tvdb, content): try: post = { "movies": [{ "ids": { "imdb": imdb } }] } if content == 'movie' else { "shows": [{ "ids": { "tvdb": tvdb } }] } items = [(control.lang(30472).encode('utf-8'), '/sync/collection')] items += [(control.lang(30473).encode('utf-8'), '/sync/collection/remove')] items += [(control.lang(30474).encode('utf-8'), '/sync/watchlist')] items += [(control.lang(30475).encode('utf-8'), '/sync/watchlist/remove')] items += [(control.lang(30476).encode('utf-8'), '/users/me/lists/%s/items')] result = getTrakt('/users/me/lists') result = json.loads(result) lists = [(i['name'], i['ids']['slug']) for i in result] lists = [lists[i // 2] for i in range(len(lists) * 2)] for i in range(0, len(lists), 2): lists[i] = ((control.lang(30477) + ' ' + lists[i][0]).encode('utf-8'), '/users/me/lists/%s/items' % lists[i][1]) for i in range(1, len(lists), 2): lists[i] = ((control.lang(30478) + ' ' + lists[i][0]).encode('utf-8'), '/users/me/lists/%s/items/remove' % lists[i][1]) items += lists select = control.selectDialog([i[0] for i in items], control.lang(30471).encode('utf-8')) if select == -1: return elif select == 4: t = control.lang(30476).encode('utf-8') k = control.keyboard('', t) k.doModal() new = k.getText() if k.isConfirmed() else None if (new == None or new == ''): return result = getTrakt('/users/me/lists', post={ "name": new, "privacy": "private" }) try: slug = json.loads(result)['ids']['slug'] except: return control.infoDialog('Failed', heading=name) result = getTrakt(items[select][1] % slug, post=post) else: result = getTrakt(items[select][1], post=post) info = 'Successful' if not result == None else 'Failed' control.infoDialog(info, heading=name) except: return
def sourcesDialog(self): try: sources = [{"label": "00 | [B]%s[/B]" % control.lang(30509).encode("utf-8").upper()}] + self.sources labels = [i["label"] for i in sources] select = control.selectDialog(labels) if select == 0: return self.sourcesDirect() if select == -1: return "close://" items = [self.sources[select - 1]] next = [y for x, y in enumerate(self.sources) if x >= select] prev = [y for x, y in enumerate(self.sources) if x < select][::-1] source, quality = items[0]["source"], items[0]["quality"] items = [i for i in items + next + prev if i["quality"] == quality and i["source"] == source][:10] items += [i for i in next + prev if i["quality"] == quality and not i["source"] == source][:10] import xbmc dialog = control.progressDialog dialog.create(control.addonInfo("name"), "") dialog.update(0) block = None for i in range(len(items)): try: dialog.update(int((100 / float(len(items))) * i), str(items[i]["label"])) if items[i]["source"] == block: raise Exception() w = workers.Thread(self.sourcesResolve, items[i]["url"], items[i]["provider"]) w.start() for x in range(0, 15 * 2): if dialog.iscanceled(): return dialog.close() if xbmc.abortRequested == True: return sys.exit() if w.is_alive() == False: break time.sleep(0.5) if w.is_alive() == True: block = items[i]["source"] if self.url == None: raise Exception() try: dialog.close() except: pass self.selectedSource = items[i]["label"] return self.url except: pass try: dialog.close() except: pass except: return
def resolveUrl(name, url, audio, image, fanart, playable, content): try: if '.f4m' in url: label = cleantitle(name) ext = url.split('?')[0].split('&')[0].split('|')[0].rsplit( '.')[-1].replace('/', '').lower() if not ext == 'f4m': raise Exception() from resources.lib.libraries.f4mproxy.F4mProxy import f4mProxyHelper return f4mProxyHelper().playF4mLink(url, label, None, None, '', image) # legacy issue, will be removed later if 'afdah.org' in url and not '</source>' in url: url += '<source>afdah</source>' if '</source>' in url: source = re.compile('<source>(.+?)</source>').findall(url)[0] url = re.compile('(.+?)<source>').findall(url)[0] for i in ['_mv', '_tv', '_mv_tv']: try: call = __import__( 'resources.lib.sources.%s%s' % (source, i), globals(), locals(), ['object'], -1).source() except: pass from resources.lib import sources d = sources.sources() url = call.get_sources(url, d.hosthdfullDict, d.hostsdfullDict, d.hostlocDict) if type(url) == list and len(url) == 1: url = url[0]['url'] elif type(url) == list: url = sorted(url, key=lambda k: k['quality']) for i in url: i.update( (k, '720p') for k, v in i.iteritems() if v == 'HD') for i in url: i.update( (k, '480p') for k, v in i.iteritems() if v == 'SD') q = [ '[B]%s[/B] | %s' % (i['source'].upper(), i['quality'].upper()) for i in url ] u = [i['url'] for i in url] select = control.selectDialog(q) if select == -1: return url = u[select] url = call.resolve(url) from resources.lib import resolvers host = (urlparse.urlparse(url).netloc).rsplit('.', 1)[0].rsplit('.')[-1] url = resolvers.request(url) if type(url) == list and len(url) == 1: url = url[0]['url'] elif type(url) == list: url = sorted(url, key=lambda k: k['quality']) for i in url: i.update((k, '720p') for k, v in i.iteritems() if v == 'HD') for i in url: i.update((k, '480p') for k, v in i.iteritems() if v == 'SD') q = [ '[B]%s[/B] | %s' % (host.upper(), i['quality'].upper()) for i in url ] u = [i['url'] for i in url] select = control.selectDialog(q) if select == -1: return url = u[select] if url == None: raise Exception() except: return control.infoDialog(control.lang(30705).encode('utf-8')) pass if playable == 'true': item = control.item(path=url) return control.resolve(int(sys.argv[1]), True, item) else: label = cleantitle(name) item = control.item(path=url, iconImage=image, thumbnailImage=image) item.setInfo(type='Video', infoLabels={'title': label}) control.playlist.clear() control.player.play(url, item)