def get(url, params={}): try: if getVideostarCredentialsInfo() == False: if control.yesnoDialog( control.lang(40001).encode('utf-8'), control.lang(30481).encode('utf-8'), '', 'Trakt', control.lang(30483).encode('utf-8'), control.lang(30482).encode('utf-8')): control.openSettings('2.3') raise Exception() url = urlparse.urljoin('https://api.videostar.pl', url) result = client.request(url, headers=headers, cookie=control.get_setting('videostar.sess')) r = json.loads(result) if r['status'] == "error" or result == None: if r['errors'][0]['code'] == 1: login() control.sleep(500) mycookie = control.get_setting('videostar.sess') result = client.source( url, headers=headers, cookie=control.get_setting('videostar.sess')) return result except Exception as e: control.log('Error videostar.get %s' % e) pass
def wizjachanels(): try: if getWizjaCredentialsInfo() == False: if control.yesnoDialog(control.lang(40005).encode('utf-8'), control.lang(30481).encode('utf-8'), '', 'Wizja', control.lang(30483).encode('utf-8'), control.lang(30482).encode('utf-8')): control.openSettings('2.3') raise Exception() login() items = [] url = 'http://wizja.tv/' result = client2.http_get(url) result = client.parseDOM(result, 'td') for i in result: item = {} try: result2 = [(client.parseDOM(i, 'a', ret='href')[0], client.parseDOM(i, 'img', ret='src')[0])] #control.log('Dalina %s' % result2) item['img'] = 'http://wizja.tv/' + result2[0][1] item['img'] = item['img'].encode('utf-8') item['id'] = result2[0][0].replace('watch.php?id=','') item['id'] = item['id'].encode('utf-8') item['title'] = result2[0][1].replace('ch_logo/','').replace('.png','') item['title'] = item['title'].upper().encode('utf-8') # control.log('Calina %s' % item) items.append(item) except Exception as e: control.log(' Error wizja.wizjachanels for %s' % e) pass return items except Exception as e: control.log('Error wizja.wizjachanels %s' % e)
def getchanels(): try: if getYoyCredentialsInfo() == False: if control.yesnoDialog(control.lang(40004).encode('utf-8'), control.lang(30481).encode('utf-8'), '', 'YOY', control.lang(30483).encode('utf-8'), control.lang(30482).encode('utf-8')): control.openSettings('2.5') raise Exception() login() items = [] for j in range(1,10): url = 'http://yoy.tv/channels?live=1&country=140&page=%s' % j result = client2.http_get(url) result = client.parseDOM(result, 'a', attrs = {'class': 'thumb-info team'}) result = [(client.parseDOM(i, 'img', ret='src')[0], client.parseDOM(i, 'img', ret='alt')[0]) for i in result] for i in result: item = {} item['id'] = i[0].replace('http://yoy.tv/channel/covers/','').replace('.jpg?cache=32','') control.log('Alina %s' % item['id']) item['id']=item['id'].encode('utf-8') item['title'] = i[1].upper().encode('utf-8') items.append(item) return items except: #control.openSettings('6.1') control.log('ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ' )
def login(): try: if getItiviCredentialsInfo() == False: if control.yesnoDialog( control.lang(40006).encode('utf-8'), control.lang(30481).encode('utf-8'), '', 'Itivi', control.lang(30483).encode('utf-8'), control.lang(30482).encode('utf-8')): control.openSettings('2.1') raise Exception() params = {} #url = 'http://itivi.pl/include/login.php' #params['log'] = control.get_setting('itivi.user') #params['pwd'] = control.get_setting('itivi.pass') #client2._clean_cookies(url) #result = client2.http_get(url, data=params) #myres = client.parseDOM(result,'div', attrs={'class': 'account_field_box'})[0] #myres = client.parseDOM(myres,'font') #premium = myres[0] + client.parseDOM(myres[1],'b')[0] + ' ' + control.lang(30493) #control.infoDialog(premium.encode('utf-8'), time=200) return True except Exception as e: control.infoDialog(control.lang(30485).encode('utf-8'), time=400) control.log('Error itivi.login %s' % e) return True
def login(): try: if getItiviCredentialsInfo() == False: if control.yesnoDialog(control.lang(40006).encode('utf-8'), control.lang(30481).encode('utf-8'), '', 'Itivi', control.lang(30483).encode('utf-8'), control.lang(30482).encode('utf-8')): control.openSettings('2.1') raise Exception() params = {} url = 'http://itivi.pl/include/login.php' params['log'] = control.get_setting('itivi.user') params['pwd'] = control.get_setting('itivi.pass') client2._clean_cookies(url) result = client2.http_get(url, data=params) myres = client.parseDOM(result,'div', attrs={'class': 'account_field_box'})[0] myres = client.parseDOM(myres,'font') premium = myres[0] + client.parseDOM(myres[1],'b')[0] + ' ' + control.lang(30493) control.infoDialog(premium.encode('utf-8'), time=200) return True except Exception as e: control.infoDialog(control.lang(30485).encode('utf-8'), time=400) control.log('Error itivi.login %s' % e) return True
def getchanels(): try: if getYoyCredentialsInfo() == False: if control.yesnoDialog( control.lang(40004).encode('utf-8'), control.lang(30481).encode('utf-8'), '', 'YOY', control.lang(30483).encode('utf-8'), control.lang(30482).encode('utf-8')): control.openSettings('1.21') raise Exception() #login() items = [] for j in range(1, 10): try: url = 'http://yoy.tv/channels?live=1&country=140&page=%s' % j result = client.request(url) result = client.parseDOM(result, 'a', attrs={'class': 'thumb-info team'}) result = [(client.parseDOM(i, 'img', ret='src')[0], client.parseDOM(i, 'img', ret='alt')[0]) for i in result] for i in result: item = {} item['id'] = i[0].replace('http://yoy.tv/channel/covers/', '').replace('.jpg?cache=32', '') control.log('YOY channel %s' % item['id']) item['id'] = item['id'].encode('utf-8') item['title'] = control.trans(i[1].upper().encode('utf-8')) items.append(item) except: control.log('YOY url: %s' % url) pass if 'true' == control.get_setting('xxxmode'): url = 'http://yoy.tv/channels?category=erotyka' result = client.request(url) result = client.parseDOM(result, 'a', attrs={'class': 'thumb-info team'}) result = [(client.parseDOM(i, 'img', ret='src')[0], client.parseDOM(i, 'img', ret='alt')[0]) for i in result] for i in result: control.log('XXX: %s' % i[0]) item = {} item['id'] = i[0].replace('http://yoy.tv/channel/covers/', '').replace('.jpg?cache=32', '') control.log('XXX Alina %s' % item['id']) item['id'] = item['id'].encode('utf-8') item['title'] = 'XXX ' + control.trans( i[1].upper().encode('utf-8')) items.append(item) return items except Exception as e: control.log('Error yoy.getchanels %s' % e)
def get(url, proxy=''): try: pl_proxy = control.setting('pl_proxy') pl_proxy_port = control.setting('pl_proxy_port') if getVideostarCredentialsInfo() == False: if control.yesnoDialog( control.lang(40001).encode('utf-8'), control.lang(30481).encode('utf-8'), '', 'Trakt', control.lang(30483).encode('utf-8'), control.lang(30482).encode('utf-8')): control.openSettings('1.11') raise Exception() url = urlparse.urljoin('https://api.videostar.pl', url) if proxy == '': result = client.request( url, headers=headers, cookie=control.get_setting('videostar.sess')) else: myproxy = pl_proxy if pl_proxy_port != '': myproxy = myproxy + ':' + pl_proxy_port myproxy_check = is_bad_proxy(myproxy) if not myproxy_check == '': control.dialog.ok( control.addonInfo('name'), control.lang(40013).encode('utf-8') + ' ' + myproxy_check.encode('utf-8'), '') control.openSettings('0.11') return None result = client.request( url, headers=headers, cookie=control.get_setting('videostar.sess'), proxy=myproxy) r = json.loads(result) if r['status'] == "error" or result == None: if r['errors'][0]['code'] == 1: login() control.sleep(500) mycookie = control.get_setting('videostar.sess') result = client.source( url, headers=headers, cookie=control.get_setting('videostar.sess')) return result except Exception as e: control.log('Error videostar.get %s' % e) pass
def yoylogin(): if getYoyCredentialsInfo() == False: raise ValueError('Brak ustawienia logiun lub hasła ') try: params = {} url = 'http://yoy.tv/signin' result, headers, content, cookie = client.request(url, output='extended') params['remember_me'] = '1' params['email'] = control.get_setting('yoytv.user') params['password'] = control.get_setting('yoytv.pass') params['_token'] = client.parseDOM(result, 'input', ret='value', attrs={'name': '_token'})[0] result1, headers, content, cookie = client.request(url, post=params, cookie=cookie, output='extended', redirect=False) mycookies = re.findall('Set-Cookie: (.*?);', '%s' % content) cookie = ";".join(mycookies) control.set_setting('yoytv.sess', cookie) control.log('##### cookie1: %s' % cookie) url = 'http://yoy.tv/' result = client.request(url, cookie=cookie) if not 'http://yoy.tv/signout' in result: control.log('BBBBB LOGIN %s' % 'yoy.tv') control.infoDialog(control.lang(30484).encode('utf-8')) control.dialog.ok( control.addonInfo('name') + ' - YOY TV', control.lang(30484).encode('utf-8'), '') control.openSettings('1.12') return False else: url = 'http://yoy.tv/user/settings' result = client.request(url, cookie=cookie) premium = re.findall('Aktywne do: ([0-9 :-]+)', result) if len(premium) > 0: control.log('CCCCC LOGIN %s' % premium) control.infoDialog( control.lang(30496) + premium[0].encode('utf-8')) return True except Exception as e: control.log('Yoylogin ERROR %s' % e) return False
def get(url, proxy='', retry=True): try: pl_proxy = control.setting('pl_proxy') pl_proxy_port = control.setting('pl_proxy_port') if getVideostarCredentialsInfo() == False: control.infoDialog('Enter credentials') if control.yesnoDialog( control.lang(40001).encode('utf-8'), control.lang(30481).encode('utf-8'), '', 'Trakt', control.lang(30483).encode('utf-8'), control.lang(30482).encode('utf-8')): control.openSettings('1.11') return None full_url = urlparse.urljoin('https://api-pilot.wp.pl', url) if proxy == '': result = client.request( full_url, headers=headers, cookie=control.get_setting('videostar.sess')) else: myproxy = pl_proxy if pl_proxy_port != '': myproxy = myproxy + ':' + pl_proxy_port myproxy_check = is_bad_proxy(myproxy) if not myproxy_check == '': control.dialog.ok( control.addonInfo('name'), control.lang(40013).encode('utf-8') + ' ' + myproxy_check.encode('utf-8'), '') control.openSettings('0.11') return None result = client.request( full_url, headers=headers, cookie=control.get_setting('videostar.sess'), proxy=myproxy) r = json.loads(result) if (r['status'] == "error" or result == None) and retry: login() result = get(url, proxy, False) return result except Exception as e: control.log('Error videostar.get %s' % e) pass
def getchanels(): try: if getYoyCredentialsInfo() == False: if control.yesnoDialog(control.lang(40004).encode('utf-8'), control.lang(30481).encode('utf-8'), '', 'YOY', control.lang(30483).encode('utf-8'), control.lang(30482).encode('utf-8')): control.openSettings('1.21') raise Exception() #login() items = [] for j in range(1,10): try: url = 'http://yoy.tv/channels?live=1&country=140&page=%s' % j result = client.request(url) result = client.parseDOM(result, 'a', attrs = {'class': 'thumb-info team'}) result = [(client.parseDOM(i, 'img', ret='src')[0], client.parseDOM(i, 'img', ret='alt')[0]) for i in result] for i in result: item = {} item['id'] = i[0].replace('http://yoy.tv/channel/covers/','').replace('.jpg?cache=32','') control.log('YOY channel %s' % item['id']) item['id']=item['id'].encode('utf-8') item['title'] = control.trans(i[1].upper().encode('utf-8')) items.append(item) except: control.log('YOY url: %s' % url) pass if 'true'== control.get_setting('xxxmode'): url = 'http://yoy.tv/channels?category=erotyka' result = client.request(url) result = client.parseDOM(result, 'a', attrs = {'class': 'thumb-info team'}) result = [(client.parseDOM(i, 'img', ret='src')[0], client.parseDOM(i, 'img', ret='alt')[0]) for i in result] for i in result: control.log('XXX: %s' %i[0]) item = {} item['id'] = i[0].replace('http://yoy.tv/channel/covers/','').replace('.jpg?cache=32','') control.log('XXX Alina %s' % item['id']) item['id']=item['id'].encode('utf-8') item['title'] = 'XXX '+ control.trans(i[1].upper().encode('utf-8')) items.append(item) return items except Exception as e: control.log('Error yoy.getchanels %s' % e)
def login(): try: if getLooknijCredentialsInfo() == False: if control.yesnoDialog(control.lang(40008).encode('utf-8'), control.lang(30481).encode('utf-8'), '', 'Looknij', control.lang(30483).encode('utf-8'), control.lang(30482).encode('utf-8')): control.openSettings('1.4') raise Exception() params = {} #url = 'http://itivi.pl/include/login.php' #params['log'] = control.get_setting('itivi.user') #params['pwd'] = control.get_setting('itivi.pass') #result = client2.http_get(url, data=params) return True except Exception as e: control.log('Error wizja.login %s' % e) return False
def login(): try: if getItiviCredentialsInfo() == False: if control.yesnoDialog(control.lang(40006).encode('utf-8'), control.lang(30481).encode('utf-8'), '', 'Itivi', control.lang(30483).encode('utf-8'), control.lang(30482).encode('utf-8')): control.openSettings('2.1') raise Exception() params = {} url = 'http://itivi.pl/include/login.php' params['log'] = control.get_setting('itivi.user') params['pwd'] = control.get_setting('itivi.pass') result = client2.http_get(url, data=params) return True except Exception as e: control.log('Error wizja.login %s' % e) return False
def yoylogin(): if getYoyCredentialsInfo() == False: raise ValueError('Brak ustawienia logiun lub hasła ') try: params = {} url = 'http://yoy.tv/signin' result, headers, content, cookie = client.request(url, output='extended') params['remember_me']='1' params['email'] = control.get_setting('yoytv.user') params['password'] = control.get_setting('yoytv.pass') params['_token']=client.parseDOM(result, 'input', ret='value', attrs={'name': '_token'})[0] result1, headers, content, cookie = client.request(url, post=params, cookie=cookie, output='extended', redirect=False) mycookies = re.findall('Set-Cookie: (.*?);', '%s' % content) cookie = ";".join(mycookies) control.set_setting('yoytv.sess', cookie) control.log('##### cookie1: %s' % cookie) url = 'http://yoy.tv/' result = client.request(url, cookie=cookie) if not 'http://yoy.tv/signout' in result: control.log('BBBBB LOGIN %s' % 'yoy.tv') control.infoDialog(control.lang(30484).encode('utf-8')) control.dialog.ok(control.addonInfo('name') + ' - YOY TV', control.lang(30484).encode('utf-8'), '') control.openSettings('1.12') return False else: url = 'http://yoy.tv/user/settings' result = client.request(url, cookie=cookie) premium = re.findall('Aktywne do: ([0-9 :-]+)',result) if len(premium)>0: control.log('CCCCC LOGIN %s' % premium) control.infoDialog(control.lang(30496) + premium[0].encode('utf-8') ) return True except Exception as e: control.log('Yoylogin ERROR %s' % e) return False
def get(url, params={}): try: if getVideostarCredentialsInfo() == False: if control.yesnoDialog(control.lang(40001).encode('utf-8'), control.lang(30481).encode('utf-8'), '', 'Trakt', control.lang(30483).encode('utf-8'), control.lang(30482).encode('utf-8')): control.openSettings('2.3') raise Exception() url = urlparse.urljoin('https://api.videostar.pl', url) result = client.request(url, headers=headers, cookie=control.get_setting('videostar.sess')) r = json.loads(result) if r['status'] =="error" or result==None: if r['errors'][0]['code'] == 1: login() control.sleep(500) mycookie = control.get_setting('videostar.sess') result = client.source(url, headers=headers, cookie=control.get_setting('videostar.sess')) return result except Exception as e: control.log('Error videostar.get %s' % e) pass
def getchanels(): try: if getYoyCredentialsInfo() == False: if control.yesnoDialog( control.lang(40004).encode('utf-8'), control.lang(30481).encode('utf-8'), '', 'YOY', control.lang(30483).encode('utf-8'), control.lang(30482).encode('utf-8')): control.openSettings('2.5') raise Exception() login() items = [] for j in range(1, 10): url = 'http://yoy.tv/channels?live=1&country=140&page=%s' % j result = client2.http_get(url) result = client.parseDOM(result, 'a', attrs={'class': 'thumb-info team'}) result = [(client.parseDOM(i, 'img', ret='src')[0], client.parseDOM(i, 'img', ret='alt')[0]) for i in result] for i in result: item = {} item['id'] = i[0].replace('http://yoy.tv/channel/covers/', '').replace('.jpg?cache=32', '') control.log('Alina %s' % item['id']) item['id'] = item['id'].encode('utf-8') item['title'] = i[1].upper().encode('utf-8') items.append(item) return items except: #control.openSettings('6.1') control.log( 'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ' )
def get(url, proxy=''): try: pl_proxy = control.setting('pl_proxy') pl_proxy_port = control.setting('pl_proxy_port') if getVideostarCredentialsInfo() == False: if control.yesnoDialog(control.lang(40001).encode('utf-8'), control.lang(30481).encode('utf-8'), '', 'Trakt', control.lang(30483).encode('utf-8'), control.lang(30482).encode('utf-8')): control.openSettings('1.11') raise Exception() url = urlparse.urljoin('https://api.videostar.pl', url) if proxy == '': result = client.request(url, headers=headers, cookie=control.get_setting('videostar.sess')) else: myproxy = pl_proxy if pl_proxy_port != '': myproxy = myproxy + ':' + pl_proxy_port myproxy_check = is_bad_proxy(myproxy) if not myproxy_check == '': control.dialog.ok(control.addonInfo('name'), control.lang(40013).encode('utf-8') + ' ' + myproxy_check.encode('utf-8'), '') control.openSettings('0.11') return None result = client.request(url, headers=headers, cookie=control.get_setting('videostar.sess'), proxy=myproxy) r = json.loads(result) if r['status'] =="error" or result==None: if r['errors'][0]['code'] == 1: login() control.sleep(500) mycookie = control.get_setting('videostar.sess') result = client.source(url, headers=headers, cookie=control.get_setting('videostar.sess')) return result except Exception as e: control.log('Error videostar.get %s' % e) pass
def getstream(id): try: control.set_setting('pierwszatv.tokenExpireIn', '') control.set_setting('pierwszatv.serverId', '') control.set_setting('pierwszatv.streamId', '') control.set_setting('pierwszatv.token', '') if getPierwszaCredentialsInfo() == False: if control.yesnoDialog(control.lang(40003).encode('utf-8'), control.lang(30481).encode('utf-8'), '', 'Trakt', control.lang(30483).encode('utf-8'), control.lang(30482).encode('utf-8')): control.set_setting('pierwszatv.user', '') control.set_setting('pierwszatv.password', '') control.openSettings('2.1') raise Exception() url = '/api/stream/create' params = {} params['id'] =id params['user'] =control.setting('pierwszatv.user').strip() params['password'] = urllib.quote_plus(control.setting('pierwszatv.password')) result = get(url, params) result = json.loads(result) if result['status'] == 'ok': #time.sleep(1) #control.log('x1x1x1: %s' % result['status']) expirein = int(int(result['tokenExpireIn'])*0.75) expirewhen = datetime.datetime.now() + datetime.timedelta(seconds=expirein) control.set_setting('pierwszatv.tokenExpireIn', str(int(time.mktime(expirewhen.timetuple())))) control.set_setting('pierwszatv.serverId', result['serverId']) control.set_setting('pierwszatv.streamId', result['streamId']) control.set_setting('pierwszatv.token', result['token']) for i in range(0, 5): try: r = get('/api/stream/status', {'serverId': result['serverId'] , 'streamId': result['streamId'], 'token': result['token']}) r = json.loads(r) if r['status'] == 'ok': #control.infoDialog(control.lang(30489).encode('utf-8'), time=6000) for j in range(0, 20): time.sleep(1) control.infoDialog(control.lang(30489).encode('utf-8'), time=500) try: result2 = client.request(r['source']+'?token='+result['token'],safe=True, timeout='2') control.log('Pierwsza link check nr: %s: result:%s' % (j,result2)) if result2 == None: raise Exception() else: return r['source']+'?token='+result['token'] except: pass return r['source']+'?token='+result['token'] time.sleep(3) except: pass if result['status'] == 'error': control.infoDialog('%s' % result['message'].encode('utf-8')) return None except Exception as e: control.log('Error pierwsza.getstream %s' % e )
from resources.lib.indexers import tvshows tvshows.tvshows().years() elif action == 'tvUserlists': from resources.lib.indexers import tvshows tvshows.tvshows().userlists() elif action == 'tvWidget': from resources.lib.indexers import episodes episodes.episodes().widget() elif action == 'openSettings': from resources.lib.lib import control control.openSettings(query) elif action == 'moviePlaycount': from resources.lib.libraries import playcount playcount.movies(title, year, imdb, query) elif action == 'episodePlaycount': from resources.lib.libraries import playcount playcount.episodes(imdb, tvdb, season, episode, query) elif action == 'tvPlaycount': from resources.lib.libraries import playcount playcount.tvshows(name, year, imdb, tvdb, season, query) elif action == 'clearCache': from resources.lib.libraries import cache
def getstream(id): try: control.set_setting('pierwszatv.tokenExpireIn', '') control.set_setting('pierwszatv.serverId', '') control.set_setting('pierwszatv.streamId', '') control.set_setting('pierwszatv.token', '') if getPierwszaCredentialsInfo() == False: if control.yesnoDialog(control.lang(40003).encode('utf-8'), control.lang(30481).encode('utf-8'), '', 'Trakt', control.lang(30483).encode('utf-8'), control.lang(30482).encode('utf-8')): control.set_setting('pierwszatv.user', '') control.set_setting('pierwszatv.password', '') control.openSettings('1.4') raise Exception() url = '/api/stream/create' params = {} params['id'] =id params['user'] =control.setting('pierwszatv.user').strip() params['password'] = urllib.quote_plus(control.setting('pierwszatv.password')) result = get(url, params) control.log('x1x1x1: %s' % result) result = json.loads(result) if result['status'] == 'ok': #time.sleep(1) expirein = int(int(result['tokenExpireIn'])*0.75) expirewhen = datetime.datetime.now() + datetime.timedelta(seconds=expirein) control.set_setting('pierwszatv.tokenExpireIn', str(int(time.mktime(expirewhen.timetuple())))) control.set_setting('pierwszatv.serverId', result['serverId']) control.set_setting('pierwszatv.streamId', result['streamId']) control.set_setting('pierwszatv.token', result['token']) for i in range(0, 5): try: r = get('/api/stream/status', {'serverId': result['serverId'] , 'streamId': result['streamId'], 'token': result['token']}) r = json.loads(r) if r['status'] == 'ok': #control.infoDialog(control.lang(30489).encode('utf-8'), time=6000) for j in range(0, 20): time.sleep(1) control.infoDialog(control.lang(30489).encode('utf-8'), time=500) try: result2 = client.request(r['source']+'?token='+result['token'],safe=True, timeout='2') control.log('Pierwsza link check nr: %s: result:%s' % (j,result2)) if result2 == None: raise Exception() else: return r['source']+'?token='+result['token'] except: pass return r['source']+'?token='+result['token'] time.sleep(3) except: pass if result['status'] == 'error': control.infoDialog('%s' % result['message'].encode('utf-8')) control.dialog.ok(control.addonInfo('name'), result['message'].encode('utf-8'), '') return None except Exception as e: control.log('Error pierwsza.getstream %s' % e )
def ipla_chanels(): control.log('Python version %s' % (sys.version)) #url10 = 'https://gm2.redefine.pl/rpc/system/' #headers10 = {'User-Agent': 'mipla_ios/122', 'Content-Type': 'application/x-www-form-urlencoded', # 'Accept-Language': 'pl-pl'} #post_init10 = {"jsonrpc": "2.0", "method": "getConfiguration", "id": 2, "params": { # "message": {"id": "CC3DFE81-1C70-403A-9C52-FC10EC51125A", "timestamp": "2016-10-16T00:08:57Z"}}} #data = requests.post(url10, data=post_init, headers=headers10) #print data.status_code, data.text #control.log('request %s|%s' % (data.status_code, data.text)) try: ipla_system_id() if getIplaCredentialsInfo() == False: if control.yesnoDialog(control.lang(40009).encode('utf-8'), control.lang(30481).encode('utf-8'), '', 'Ipla', control.lang(30483).encode('utf-8'), control.lang(30482).encode('utf-8')): control.set_setting('ipla.user', '') control.set_setting('ipla.pass', '') control.openSettings('1.1') raise ValueError('No login orr password') user = control.setting('ipla.user').strip() password = hashlib.md5(control.setting('ipla.pass').strip()).hexdigest() systemid = control.setting('ipla.systemid').strip() items = [] post_getTVChannels = json.loads( '{"jsonrpc":"2.0","method":"getTvChannels","id":5,"params":{"authData":{"login":"******"},"message":{"id":"4B737B56-A11D-4E65-BC86-47EA1E40EC4D","timestamp":"2016-10-15T17:03:21Z"}}}') url_auth = 'https://getmedia.redefine.pl/tv/menu.json?passwdmd5='+password+'&api_client=mipla_ios&login='******'&machine_id=iOS%'+systemid+'&outformat=2&api_build=122' result = _call_ipla(url_system, post_init, headers) control.log('request %s' % (result)) result = _call_ipla(url_preauth, post_preauth, headers) result = _call_ipla(url_auth, headers=headers1) moje = json.loads(result) loginstatus = ipla_check_login(moje) if loginstatus <> 'OK': control.log('Ipla Login Error %s ' % loginstatus) control.infoDialog(loginstatus.encode('utf-8'),time=6000) control.dialog.ok(control.addonInfo('name') + ' - IPLA',loginstatus.encode('utf-8'), '') return myperms = [] for i in moje['config']['access_groups']: #control.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> %s' % i) if 'sc:' in i['code']: myperms.append(str(i['code'])) if 'oth:' in i['code']: myperms.append(str(i['code'])) #if 'loc:' in i['code']: # myperms.append(str(i['code'])) #control.log('###################################' % moje['config']) control.set_setting('ipla.passwdmd5', moje['config']['user']['passwdmd5']) my_action1 = moje['config']['traffic_url'] + 'id=' + moje['config']['traffic_id'] + \ '&extra=GoalName%3DInterfejs/Login/Email%7Cc%3Dipla-ios/122/10.0.2/Apple/iPhone&et=action' my_action2 = moje['config']['traffic_url'] + 'id=' + moje['config']['traffic_id'] + \ '&extra=GoalName%3DIInterfejs/Start_Aplikacji/Kolejny%7Cc%3Dipla-ios/122/10.0.2/Apple/iPhone&et=action' my_action3 = moje['config']['traffic_url'] + 'id=' + moje['config']['traffic_id'] + \ '&extra=GoalName%3DInterfejs/Przegl%C4%85danie%7Cc%3Dipla-ios/122/10.0.2/Apple/iPhone&et=view' result = _call_ipla(my_action1, headers=headers2) control.log('Python version %s' % (result)) result = _call_ipla(my_action2, headers=headers2) result = _call_ipla(my_action3, headers=headers2) post_getCat = json.loads( '{"jsonrpc":"2.0","method":"getCategoryWithFlatNavigation","id":4,"params":{"catid":0,"authData":{"login":"******"},"message":{"id":"47B80EF0-19D0-4BD0-82FF-80BC50EDF2A9","timestamp":"2016-10-15T23:02:22Z"}}}') #result = _call_ipla(url_navigation, post_getCat, headers) result = _call_ipla(url_navigation, post_getTVChannels, headers) moje = json.loads(result) print "GETCAT", result for i in moje['result']['results']: item = {} channelperms = i['grantExpression'].split('*') channelperms = [w.replace('+plat:all', '') for w in channelperms] for j in myperms: #control.log('BB: %s AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA %s' % (i['title'].upper(), i['grantExpression'])) if j in channelperms: #print("OK", i['id'], i['title'], i['published'], i['grantExpression']) # control.log('Dalina %s' % result2) item['img'] = i['thumbnails'][-1]['src'].encode('utf-8') item['id'] = i['id'] item['title'] = i['title'].upper().encode('utf-8') item['plot'] = i['description'].encode('utf-8') #control.log('RESULT I %s' % dump(item)) # control.log('Calina %s' % item) item = {'title': item['title'], 'originaltitle': item['title'], 'genre': '0', 'plot': item['plot'], 'name':item['title'], 'tagline': '0', 'poster': item['img'], 'fanart': '0', 'id':item['id'], 'service':'ipla', 'next': ''} items.append(item) #Dupes dupes = [] filter = [] for entry in items: if not entry['id'] in dupes: filter.append(entry) dupes.append(entry['id']) items = filter return items except Exception as e: control.log('Ipla Error %s ' % e) return
def getstream(id): try: control.infoDialog(control.lang(30495).encode('utf-8'), time=200) if getIplaCredentialsInfo() == False: if control.yesnoDialog(control.lang(40003).encode('utf-8'), control.lang(30481).encode('utf-8'), '', 'Trakt', control.lang(30483).encode('utf-8'), control.lang(30482).encode('utf-8')): control.set_setting('ipla.user', '') control.set_setting('ipla.pass', '') control.openSettings('1.1') raise Exception() user = control.setting('ipla.user').strip() password = hashlib.md5(control.setting('ipla.pass').strip()).hexdigest() systemid = control.setting('ipla.systemid').strip() passwdmd5 = control.setting('ipla.passwdmd5').strip() url_auth = 'https://getmedia.redefine.pl/tv/menu.json?passwdmd5='+password+'&api_client=mipla_ios&login='******'&machine_id=iOS%'+systemid+'&outformat=2&api_build=122' post_getMedia = json.loads( '{"jsonrpc":"2.0","method":"getMedia","id":10,"params":{"cpid":0,"message":{"id":"F26642A8-8000-4C7A-B1CB-C2EADFD82E23","timestamp":"2016-10-16T00:53:25Z"},"authData":{"login":"******"},"mediaId":"'+str(id)+'"}}') post_perPlayData = json.loads( '{"jsonrpc":"2.0","method":"prePlayData","id":"-1864568404","params":{"mediaId":"'+str(id)+'","cpid":0,"authData":{"login":"******"}}}') #control.log('ipla1 %s' % id) result = _call_ipla(url_auth, headers=headers1) moje = json.loads(result) loginstatus = ipla_check_login(moje) if loginstatus <> 'OK': control.log('Ipla Login Error %s ' % loginstatus) control.infoDialog(loginstatus.encode('utf-8'),time=6000) control.dialog.ok(control.addonInfo('name') + ' - IPLA',loginstatus.encode('utf-8'), '') return my_action1 = moje['config']['traffic_url'] + 'id=' + moje['config']['traffic_id'] + \ '&extra=GoalName%3DInterfejs/Login/Email%7Cc%3Dipla-ios/122/10.0.2/Apple/iPhone&et=action' my_action2 = moje['config']['traffic_url'] + 'id=' + moje['config']['traffic_id'] + \ '&extra=GoalName%3DIInterfejs/Start_Aplikacji/Kolejny%7Cc%3Dipla-ios/122/10.0.2/Apple/iPhone&et=action' my_action3 = moje['config']['traffic_url'] + 'id=' + moje['config']['traffic_id'] + \ '&extra=GoalName%3DInterfejs/Przegl%C4%85danie%7Cc%3Dipla-ios/122/10.0.2/Apple/iPhone&et=view' result = _call_ipla(my_action1, headers=headers2) result = _call_ipla(my_action2, headers=headers2) result = _call_ipla(my_action3, headers=headers2) result = _call_ipla(url_navigation, post_getMedia, headers) result = _call_ipla(url_navigation, post_perPlayData, headers) moje = json.loads(result) url = moje['result']['mediaItem']['playback']['mediaSources'][-1]['authorizationServices']['pseudo']['url'] myid = moje['result']['mediaItem']['playback']['mediaId']['id'] url = url + '?cltype=mobile&cpid=0&id=' + myid + '&login='******'&passwdmd5='+passwdmd5+'&client_id=iOS%'+systemid+'&outformat=2' result = _call_ipla(url, headers=headers1) result = json.loads(result) url = result['resp']['license']['url'] + '|User-Agent='+urllib.quote_plus('IPLA/4.2.2.5 CFNetwork/808.0.2 Darwin/16.0.0') url = result['resp']['license']['url'] result = _call_ipla(url, headers=headers3) result = result.decode('utf-8') link = re.findall("BANDWIDTH=\d+\n(.*?m3u8)", result, re.MULTILINE)[0] if url_hls in link: url = link + '?userid=iOS%' + systemid + '&initial|User-Agent=' + urllib.quote_plus(headers2['User-Agent']) else: url = url_hls +link + '?userid=iOS%'+systemid+'&initial|User-Agent='+ urllib.quote_plus(headers2['User-Agent']) return url return None except Exception as e: control.log('Error ipla.getstream %s' % e ) return None
def login(): try: if getTelewizjadaCredentialsInfo() == False: if control.yesnoDialog( control.lang(40003).encode('utf-8'), control.lang(30481).encode('utf-8'), '', 'Trakt', control.lang(30483).encode('utf-8'), control.lang(30482).encode('utf-8')): control.set_setting('telewizjada.user', '') control.set_setting('telewizjada.password', '') control.openSettings('1.20') control.log('>>>> LOGIN()') expire = control.get_setting('telewizjada.expire') control.log('Expire1: %s' % expire) if expire != '': try: from datetime import datetime #d = datetime.strptime(expire, '%Y-%m-%d %H:%M:%S') d = datetime( *(time.strptime(expire, '%Y-%m-%d %H:%M:%S')[0:6])) control.log('Expire2: %s' % d) d2 = datetime.now() if d > d2: control.log('Expire OK: %s %s' % (d, d2)) return True except: pass url = 'http://www.deltamediaplayer.com/index.php?option=com_users&view=login&Itemid=116' result, h1, content, cookie1 = client.request(url, output='extended') headers = {'referer': url} result = client.parseDOM(result, 'div', attrs={'class': 'login'})[0] result = re.findall( '<input type="hidden" name="([^"]+)" value="([^"]+)"', result) params = { 'username': control.get_setting('telewizjada.user'), 'password': control.get_setting('telewizjada.pass'), 'remember': 'yes', str(result[0][0]): urllib.quote(str(result[0][1])), str(result[1][0]): urllib.quote(str(result[1][1])) } paramslog = { 'username': control.get_setting('telewizjada.user'), 'password': '', 'remember': 'yes', str(result[0][0]): urllib.quote(str(result[0][1])), str(result[1][0]): urllib.quote(str(result[1][1])) } control.log('>>>> PARAMS %s' % (paramslog)) url = 'http://www.deltamediaplayer.com/index.php?option=com_users&task=user.login' result, h2, content, cookie2 = client.request(url, redirect=False, post=params, headers=headers, cookie=cookie1, output='extended') if content[ 'Location'] != 'https://www.deltamediaplayer.com/index.php?option=com_users&view=profile': control.infoDialog(control.lang(30600).encode('utf-8'), time=6000) control.dialog.ok( control.addonInfo('name') + ' - Telewizzjada.net', control.lang(30600).encode('utf-8'), '') raise ValueError('Bledny login lub haslo.') url = 'http://www.deltamediaplayer.com/playercode/authorised/gethlsusers.php' headers[ 'referer'] = 'http://www.deltamediaplayer.com/index.php?option=com_acctexp&view=user&layout=subscriptiondetails&Itemid=119' headers['X-Requested-With'] = 'XMLHttpRequest' headers['Content-Type'] = 'application/json' headers['cookie'] = '%s; %s' % (cookie1, content['Set-Cookie'].split(';')[0]) params2 = json.dumps({'browser': 'Desktop;Windows;Chrome 54'}) result = client.request(url, post=params2, headers=headers) control.log('>>>> RES r:%s ' % (result)) r = json.loads(result) result = [i for i in r if i['registered'] != 0] if len(result) > 0: for i in result: control.log('I %s' % i) control.log('QQQQQQQQQQQQQQ %s' % r[0]['hash'], ) control.set_setting('telewizjada.token', r[0]['hash']) control.set_setting('telewizjada.os', r[0]['os']) control.set_setting('telewizjada.browser', r[0]['browser']) control.set_setting('telewizjada.device', r[0]['device']) control.log("Brovser: %s" % r[0]['browser'].split(' ')[0]) ua = 'Mozilla/5.0 (%s; %s; rv:%s) Gecko/20100101 %s/%s' % ( r[0]['os'], r[0]['device'], r[0]['browser'].split(' ')[-1], r[0]['browser'].split(' ')[0], r[0]['browser'].split(' ')[-1]) control.log('UA %s' % ua) control.set_setting('telewizjada.ua', ua) return True else: control.infoDialog(control.lang(30601).encode('utf-8'), time=6000) control.dialog.ok( control.addonInfo('name') + ' - Telewizzjada.net', control.lang(30601).encode('utf-8'), '') raise ValueError('Brak zarejestrowanych przeglądarek.') return False except Exception as e: control.log('Exception telewizjada.net login %s' % e) return False
def ipla_chanels(): control.log('Python version %s' % (sys.version)) #url10 = 'https://gm2.redefine.pl/rpc/system/' #headers10 = {'User-Agent': 'mipla_ios/122', 'Content-Type': 'application/x-www-form-urlencoded', # 'Accept-Language': 'pl-pl'} #post_init10 = {"jsonrpc": "2.0", "method": "getConfiguration", "id": 2, "params": { # "message": {"id": "CC3DFE81-1C70-403A-9C52-FC10EC51125A", "timestamp": "2016-10-16T00:08:57Z"}}} #data = requests.post(url10, data=post_init, headers=headers10) #print data.status_code, data.text #control.log('request %s|%s' % (data.status_code, data.text)) try: ipla_system_id() if getIplaCredentialsInfo() == False: if control.yesnoDialog( control.lang(40009).encode('utf-8'), control.lang(30481).encode('utf-8'), '', 'Ipla', control.lang(30483).encode('utf-8'), control.lang(30482).encode('utf-8')): control.set_setting('ipla.user', '') control.set_setting('ipla.pass', '') control.openSettings('1.1') raise ValueError('No login orr password') user = control.setting('ipla.user').strip() password = hashlib.md5( control.setting('ipla.pass').strip()).hexdigest() systemid = control.setting('ipla.systemid').strip() items = [] post_getTVChannels = json.loads( '{"jsonrpc":"2.0","method":"getTvChannels","id":5,"params":{"authData":{"login":"******"},"message":{"id":"4B737B56-A11D-4E65-BC86-47EA1E40EC4D","timestamp":"2016-10-15T17:03:21Z"}}}' ) url_auth = 'https://getmedia.redefine.pl/tv/menu.json?passwdmd5=' + password + '&api_client=mipla_ios&login='******'&machine_id=iOS%' + systemid + '&outformat=2&api_build=122' result = _call_ipla(url_system, post_init, headers) control.log('request %s' % (result)) result = _call_ipla(url_preauth, post_preauth, headers) result = _call_ipla(url_auth, headers=headers1) moje = json.loads(result) loginstatus = ipla_check_login(moje) if loginstatus <> 'OK': control.log('Ipla Login Error %s ' % loginstatus) control.infoDialog(loginstatus.encode('utf-8'), time=6000) control.dialog.ok( control.addonInfo('name') + ' - IPLA', loginstatus.encode('utf-8'), '') return myperms = [] for i in moje['config']['access_groups']: #control.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> %s' % i) if 'sc:' in i['code']: myperms.append(str(i['code'])) if 'oth:' in i['code']: myperms.append(str(i['code'])) #if 'loc:' in i['code']: # myperms.append(str(i['code'])) #control.log('###################################' % moje['config']) control.set_setting('ipla.passwdmd5', moje['config']['user']['passwdmd5']) my_action1 = moje['config']['traffic_url'] + 'id=' + moje['config']['traffic_id'] + \ '&extra=GoalName%3DInterfejs/Login/Email%7Cc%3Dipla-ios/122/10.0.2/Apple/iPhone&et=action' my_action2 = moje['config']['traffic_url'] + 'id=' + moje['config']['traffic_id'] + \ '&extra=GoalName%3DIInterfejs/Start_Aplikacji/Kolejny%7Cc%3Dipla-ios/122/10.0.2/Apple/iPhone&et=action' my_action3 = moje['config']['traffic_url'] + 'id=' + moje['config']['traffic_id'] + \ '&extra=GoalName%3DInterfejs/Przegl%C4%85danie%7Cc%3Dipla-ios/122/10.0.2/Apple/iPhone&et=view' result = _call_ipla(my_action1, headers=headers2) control.log('Python version %s' % (result)) result = _call_ipla(my_action2, headers=headers2) result = _call_ipla(my_action3, headers=headers2) post_getCat = json.loads( '{"jsonrpc":"2.0","method":"getCategoryWithFlatNavigation","id":4,"params":{"catid":0,"authData":{"login":"******"},"message":{"id":"47B80EF0-19D0-4BD0-82FF-80BC50EDF2A9","timestamp":"2016-10-15T23:02:22Z"}}}' ) #result = _call_ipla(url_navigation, post_getCat, headers) result = _call_ipla(url_navigation, post_getTVChannels, headers) moje = json.loads(result) print "GETCAT", result for i in moje['result']['results']: item = {} channelperms = i['grantExpression'].split('*') channelperms = [w.replace('+plat:all', '') for w in channelperms] for j in myperms: #control.log('BB: %s AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA %s' % (i['title'].upper(), i['grantExpression'])) if j in channelperms: #print("OK", i['id'], i['title'], i['published'], i['grantExpression']) # control.log('Dalina %s' % result2) item['img'] = i['thumbnails'][-1]['src'].encode('utf-8') item['id'] = i['id'] item['title'] = i['title'].upper().encode('utf-8') item['plot'] = i['description'].encode('utf-8') #control.log('RESULT I %s' % dump(item)) # control.log('Calina %s' % item) item = { 'title': item['title'], 'originaltitle': item['title'], 'genre': '0', 'plot': item['plot'], 'name': item['title'], 'tagline': '0', 'poster': item['img'], 'fanart': '0', 'id': item['id'], 'service': 'ipla', 'next': '' } items.append(item) #Dupes dupes = [] filter = [] for entry in items: if not entry['id'] in dupes: filter.append(entry) dupes.append(entry['id']) items = filter return items except Exception as e: control.log('Ipla Error %s ' % e) return
def wizjalogin(): try: params = {} url = 'http://wizja.tv/users/index.php' #result, headers, content, cookie = client.request(url, output='extended') params['login'] = '******' params['user_name'] = control.get_setting('wizja.user') params['user_password'] = control.get_setting('wizja.pass') #login to site result, headers, content, cookie = client.request(url, post=params, headers=HOST, output='extended') control.set_setting('wizja.token', cookie) #wrong login if '<font color="#FF0000">Błędne hasło..</font>' in result: #zly login control.log('WIZJA.TV ZLY LOGIN1: %s' % '') control.infoDialog(control.lang(30497).encode('utf-8'), time=6000) control.dialog.ok( control.addonInfo('name') + ' - WIZJA TV', control.lang(30497).encode('utf-8'), '') control.openSettings('0.1') raise Exception() elif 'lub hasło.</font>' in result: #zly login control.log('WIZJA.TV ZLY LOGIN2: %s' % '') control.infoDialog(control.lang(30486).encode('utf-8'), time=6000) control.dialog.ok( control.addonInfo('name') + ' - WIZJA TV', control.lang(30486).encode('utf-8'), '') raise Exception() elif 'Zalogowany jako :' in result: #no premium if '<font color=ff0000>Brak premium' in result: control.log('WIZJA.TV BRAK PREMIUM: %s' % '') control.infoDialog(control.lang(30490).encode('utf-8'), time=6000) control.dialog.ok( control.addonInfo('name') + ' - WIZJA TV', control.lang(30490).encode('utf-8'), '') raise Exception('NO premium') else: try: premium = re.findall( 'Premium aktywne do (\d{4}.*?)</font>', result)[0] control.set_setting('wizja.expire', premium) control.infoDialog('Premium Wizja.tv do: ' + premium.encode('utf-8'), time=2000) except: pass return True, cookie #account locked - wait 60 minutes elif '<font color="#FF0000">Wpisa' in result: control.log( 'WIZJA.TV zbyt wiele razy pobowales - poczekaj 60 minut: %s' % '') control.infoDialog(control.lang(30487).encode('utf-8'), time=6000) control.dialog.ok( control.addonInfo('name') + ' - WIZJA TV', control.lang(30487).encode('utf-8'), '') raise Exception('zbyt wiele razy pobowales - poczekaj 60 minut') #Other error else: control.log('WIZJA.TV inny blad: %s' % '') control.infoDialog(control.lang(30488).encode('utf-8'), time=6000) raise Exception('Inny bład: ' + result) return False except Exception as e: control.log('Error wizja.login %s' % e) return False
def getstream(id): try: control.infoDialog(control.lang(30495).encode('utf-8'), time=200) if getIplaCredentialsInfo() == False: if control.yesnoDialog( control.lang(40003).encode('utf-8'), control.lang(30481).encode('utf-8'), '', 'Trakt', control.lang(30483).encode('utf-8'), control.lang(30482).encode('utf-8')): control.set_setting('ipla.user', '') control.set_setting('ipla.pass', '') control.openSettings('1.1') raise Exception() user = control.setting('ipla.user').strip() password = hashlib.md5( control.setting('ipla.pass').strip()).hexdigest() systemid = control.setting('ipla.systemid').strip() passwdmd5 = control.setting('ipla.passwdmd5').strip() url_auth = 'https://getmedia.redefine.pl/tv/menu.json?passwdmd5=' + password + '&api_client=mipla_ios&login='******'&machine_id=iOS%' + systemid + '&outformat=2&api_build=122' post_getMedia = json.loads( '{"jsonrpc":"2.0","method":"getMedia","id":10,"params":{"cpid":0,"message":{"id":"F26642A8-8000-4C7A-B1CB-C2EADFD82E23","timestamp":"2016-10-16T00:53:25Z"},"authData":{"login":"******"},"mediaId":"' + str(id) + '"}}') post_perPlayData = json.loads( '{"jsonrpc":"2.0","method":"prePlayData","id":"-1864568404","params":{"mediaId":"' + str(id) + '","cpid":0,"authData":{"login":"******"}}}') #control.log('ipla1 %s' % id) result = _call_ipla(url_auth, headers=headers1) moje = json.loads(result) loginstatus = ipla_check_login(moje) if loginstatus <> 'OK': control.log('Ipla Login Error %s ' % loginstatus) control.infoDialog(loginstatus.encode('utf-8'), time=6000) control.dialog.ok( control.addonInfo('name') + ' - IPLA', loginstatus.encode('utf-8'), '') return my_action1 = moje['config']['traffic_url'] + 'id=' + moje['config']['traffic_id'] + \ '&extra=GoalName%3DInterfejs/Login/Email%7Cc%3Dipla-ios/122/10.0.2/Apple/iPhone&et=action' my_action2 = moje['config']['traffic_url'] + 'id=' + moje['config']['traffic_id'] + \ '&extra=GoalName%3DIInterfejs/Start_Aplikacji/Kolejny%7Cc%3Dipla-ios/122/10.0.2/Apple/iPhone&et=action' my_action3 = moje['config']['traffic_url'] + 'id=' + moje['config']['traffic_id'] + \ '&extra=GoalName%3DInterfejs/Przegl%C4%85danie%7Cc%3Dipla-ios/122/10.0.2/Apple/iPhone&et=view' result = _call_ipla(my_action1, headers=headers2) result = _call_ipla(my_action2, headers=headers2) result = _call_ipla(my_action3, headers=headers2) result = _call_ipla(url_navigation, post_getMedia, headers) result = _call_ipla(url_navigation, post_perPlayData, headers) moje = json.loads(result) url = moje['result']['mediaItem']['playback']['mediaSources'][-1][ 'authorizationServices']['pseudo']['url'] myid = moje['result']['mediaItem']['playback']['mediaId']['id'] url = url + '?cltype=mobile&cpid=0&id=' + myid + '&login='******'&passwdmd5=' + passwdmd5 + '&client_id=iOS%' + systemid + '&outformat=2' result = _call_ipla(url, headers=headers1) result = json.loads(result) url = result['resp']['license'][ 'url'] + '|User-Agent=' + urllib.quote_plus( 'IPLA/4.2.2.5 CFNetwork/808.0.2 Darwin/16.0.0') url = result['resp']['license']['url'] result = _call_ipla(url, headers=headers3) result = result.decode('utf-8') link = re.findall("BANDWIDTH=\d+\n(.*?m3u8)", result, re.MULTILINE)[0] if url_hls in link: url = link + '?userid=iOS%' + systemid + '&initial|User-Agent=' + urllib.quote_plus( headers2['User-Agent']) else: url = url_hls + link + '?userid=iOS%' + systemid + '&initial|User-Agent=' + urllib.quote_plus( headers2['User-Agent']) return url return None except Exception as e: control.log('Error ipla.getstream %s' % e) return None
def login(): try: if getTelewizjadaCredentialsInfo() == False: if control.yesnoDialog(control.lang(40003).encode('utf-8'), control.lang(30481).encode('utf-8'), '', 'Trakt', control.lang(30483).encode('utf-8'), control.lang(30482).encode('utf-8')): control.set_setting('telewizjada.user', '') control.set_setting('telewizjada.password', '') control.openSettings('1.20') control.log('>>>> LOGIN()' ) expire = control.get_setting('telewizjada.expire') control.log('Expire1: %s' % expire) if expire != '': try: from datetime import datetime #d = datetime.strptime(expire, '%Y-%m-%d %H:%M:%S') d = datetime(*(time.strptime(expire, '%Y-%m-%d %H:%M:%S')[0:6])) control.log('Expire2: %s' % d) d2 = datetime.now() if d>d2: control.log('Expire OK: %s %s' % (d,d2)) return True except: pass url = 'http://www.deltamediaplayer.com/index.php?option=com_users&view=login&Itemid=116' result, h1, content, cookie1 = client.request(url,output='extended') headers= {'referer':url} result = client.parseDOM(result, 'div', attrs={'class':'login'})[0] result = re.findall('<input type="hidden" name="([^"]+)" value="([^"]+)"',result) params = { 'username':control.get_setting('telewizjada.user'), 'password':control.get_setting('telewizjada.pass'), 'remember':'yes', str(result[0][0]): urllib.quote(str(result[0][1])), str(result[1][0]): urllib.quote(str(result[1][1])) } paramslog = { 'username':control.get_setting('telewizjada.user'), 'password':'', 'remember':'yes', str(result[0][0]): urllib.quote(str(result[0][1])), str(result[1][0]): urllib.quote(str(result[1][1])) } control.log('>>>> PARAMS %s' % (paramslog)) url='http://www.deltamediaplayer.com/index.php?option=com_users&task=user.login' result, h2, content, cookie2 = client.request(url, redirect=False, post=params, headers=headers, cookie=cookie1, output='extended') if content['Location'] != 'https://www.deltamediaplayer.com/index.php?option=com_users&view=profile': control.infoDialog(control.lang(30600).encode('utf-8'),time=6000) control.dialog.ok(control.addonInfo('name') + ' - Telewizzjada.net',control.lang(30600).encode('utf-8'), '') raise ValueError('Bledny login lub haslo.') url = 'http://www.deltamediaplayer.com/playercode/authorised/gethlsusers.php' headers['referer']='http://www.deltamediaplayer.com/index.php?option=com_acctexp&view=user&layout=subscriptiondetails&Itemid=119' headers['X-Requested-With']='XMLHttpRequest' headers['Content-Type'] = 'application/json' headers['cookie'] = '%s; %s' % (cookie1,content['Set-Cookie'].split(';')[0]) params2=json.dumps({'browser':'Desktop;Windows;Chrome 54'}) result = client.request(url, post=params2, headers=headers) control.log('>>>> RES r:%s ' % (result)) r = json.loads(result) result = [i for i in r if i['registered'] != 0] if len(result)>0: for i in result: control.log('I %s' %i) control.log('QQQQQQQQQQQQQQ %s' % r[0]['hash'], ) control.set_setting('telewizjada.token', r[0]['hash']) control.set_setting('telewizjada.os', r[0]['os']) control.set_setting('telewizjada.browser', r[0]['browser']) control.set_setting('telewizjada.device', r[0]['device']) control.log("Brovser: %s" % r[0]['browser'].split(' ')[0]) ua = 'Mozilla/5.0 (%s; %s; rv:%s) Gecko/20100101 %s/%s' % (r[0]['os'], r[0]['device'], r[0]['browser'].split(' ')[-1], r[0]['browser'].split(' ')[0], r[0]['browser'].split(' ')[-1]) control.log('UA %s' %ua) control.set_setting('telewizjada.ua', ua) return True else: control.infoDialog(control.lang(30601).encode('utf-8'), time=6000) control.dialog.ok(control.addonInfo('name') + ' - Telewizzjada.net',control.lang(30601).encode('utf-8'), '') raise ValueError('Brak zarejestrowanych przeglądarek.') return False except Exception as e: control.log('Exception telewizjada.net login %s' % e) return False