Example #1
0
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 LOGIN: %s' % result)
            control.infoDialog(control.lang(30497).encode('utf-8'),time=6000)
            control.dialog.ok(control.addonInfo('name') + ' - WIZJA TV',control.lang(30497).encode('utf-8'), '')
            raise Exception()
        elif  'lub hasło.</font>' in result: #zly login
            control.log('WIZJA.TV ZLY LOGIN: %s' % result)
            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' % result)
                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' % result)
            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' % result)
            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
Example #2
0
def getstream(id):
    try:
        pl_proxy = control.setting('pl_proxy')
        pl_proxy_port = control.setting('pl_proxy_port')

        url = 'https://api.videostar.pl/channels/get/%s?format_id=2' % id
        result = get(url, pl_proxy)
        control.log('Z %s' % result)
        result = json.loads(result)

        if result['status'] == 'ok':
            url = result['stream_channel']['url_base']
            result = client.request(
                url,
                headers=headers,
                cookie=control.get_setting('videostar.sess'),
                output='geturl')
            return result
        if result['status'] == 'error':
            control.infoDialog('%s' %
                               result['errors'][0]['msg'].encode('utf-8'))
            control.dialog.ok(control.addonInfo('name'),
                              result['errors'][0]['msg'].encode('utf-8'), '')

        raise Exception()
    except:
        #control.openSettings('6.1')
        control.log(
            'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ'
        )
Example #3
0
def getstream(id):
    try:
        pl_proxy = control.setting('pl_proxy')
        pl_proxy_port = control.setting('pl_proxy_port')


        url = 'https://api.videostar.pl/channels/get/%s?format_id=2' % id
        result = get(url,pl_proxy)
        control.log('Z %s' % result)
        result = json.loads(result)


        if result['status'] == 'ok':
            url = result['stream_channel']['url_base']
            result = client.request(url, headers=headers, cookie=control.get_setting('videostar.sess'), output='geturl')
            return result
        if result['status'] == 'error':
            if result['errors'][0]['code'] == 300:
                params = {'t':result['errors'][0]['data']['stream_token'] }
                res = get('/channels/close', headers=headers, cookie=control.get_setting('videostar.sess'), post=params)
                control.log('Z %s' % result)
                return getstream(id)

            else:
                control.infoDialog('%s' % result['errors'][0]['msg'].encode('utf-8'))
                control.dialog.ok(control.addonInfo('name'), result['errors'][0]['msg'].encode('utf-8'), '')

        raise Exception()
    except:
        #control.openSettings('6.1')
        control.log('ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ' )
Example #4
0
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
Example #5
0
def chanels():
    adult = control.get_setting('xxxmode')

    #if login() == False:
    #    control.log('Błędny login')
    #    raise ValueError('Błędny login')
    url = 'http://www.telewizjada.net/get_channels_cache.php'
    items = []
    try:
        result = client.request(url)
        result = json.loads(result)

        for i in result['channels']:
            try:
                if adult == 'false':
                    if i['isAdult'] == 1:
                        control.log('Adult telewizjada.chanels %s' %
                                    i['displayName'])
                        raise ValueError('Adult channel %s' % i['displayName'])
                item = {}
                item['img'] = urlparse.urljoin(base_url,
                                               i['bigThumb']).encode('utf-8')
                item['id'] = i['id']
                item['title'] = i['displayName'].upper().encode('utf-8')
                item['plot'] = i['description'].encode('utf-8')
                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': 'telewizjadanet',
                    'next': ''
                }
                items.append(item)
                #control.log('XXXXXXXXX %s' % i)

            except:
                pass
        return items

    except Exception as e:
        control.log('Error telewizjada.chanels %s' % e)
        control.dialog.ok(
            control.addonInfo('name') + ' - Telewizjada.net',
            control.lang(30602).encode('utf-8'), '')
        return
Example #6
0
File: yoy.py Project: undg/filmkodi
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
Example #7
0
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
Example #8
0
    def root(self):
        self.addDirectoryItem(40007, 'tv&url=eskago', 'eskago.png',
                              'DefaultMovies.png')
        self.addDirectoryItem(40009, 'tv&url=ipla', 'logoipla.png',
                              'DefaultMovies.png')
        self.addDirectoryItem(40006, 'tv&url=itivi', 'itivi.png',
                              'DefaultMovies.png')
        self.addDirectoryItem(40008, 'tv&url=looknij', 'looknij1.png',
                              'DefaultMovies.png')
        self.addDirectoryItem(40001, 'tv&url=videostar', 'videostar.pl.png',
                              'DefaultMovies.png')
        self.addDirectoryItem(40002, 'tv&url=weeb', 'weebtv.png',
                              'DefaultMovies.png')
        self.addDirectoryItem(40005, 'tv&url=wizja', 'wizjatv.png',
                              'DefaultMovies.png')
        self.addDirectoryItem(40004, 'tv&url=yoy', 'yoy.tv.png',
                              'DefaultMovies.png')

        #self.addDirectoryItem(30001, 'movieNavigator', 'movies.jpg', 'DefaultMovies.png')
        #self.addDirectoryItem(30002, 'tvNavigator', 'tvshows.jpg', 'DefaultTVShows.png')
        #self.addDirectoryItem(30003, 'channels', 'channels.jpg', 'DefaultMovies.png')
        #self.addDirectoryItem(30004, 'myNavigator', 'mymilenium.jpg', 'DefaultVideoPlaylists.png')

        #if not control.setting('movie_widget') == '0':
        #    self.addDirectoryItem(30005, 'movieWidget', 'moviesAdded.jpg', 'DefaultRecentlyAddedMovies.png')

        #if (traktMode == True and not control.setting('tv_alt_widget') == '0') or (traktMode == False and not control.setting('tv_widget') == '0'):
        #    self.addDirectoryItem(30006, 'tvWidget', 'calendarsAdded.jpg', 'DefaultRecentlyAddedEpisodes.png')

        #if not control.setting('calendar_widget') == '0':
        #    self.addDirectoryItem(30007, 'calendars', 'calendar.jpg', 'DefaultRecentlyAddedEpisodes.png')

        #self.addDirectoryItem(30033, 'tvFavourites', 'movieFavourites.jpg', 'DefaultMovies.png')

        self.addDirectoryItem(42008, 'toolNavigator', 'tools.jpg',
                              'DefaultAddonProgram.png')

        #self.addDirectoryItem(30009, 'searchNavigator', 'search.jpg', 'DefaultFolder.png')

        self.endDirectory()

        from resources.lib.lib import cache
        from resources.lib.lib import changelog
        cache.get(changelog.get,
                  600000000,
                  control.addonInfo('version'),
                  table='changelog')
Example #9
0
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
Example #10
0
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
Example #11
0
def chanels():
    adult = control.get_setting('xxxmode')

    #if login() == False:
    #    control.log('Błędny login')
    #    raise ValueError('Błędny login')
    url = 'http://www.telewizjada.net/get_channels_cache.php'
    items = []
    try:
        result = client.request(url)
        result = json.loads(result)

        for i in result['channels']:
            try:
                if adult == 'false':
                    if i['isAdult'] == 1:
                        control.log('Adult telewizjada.chanels %s' % i['displayName'])
                        raise ValueError('Adult channel %s' % i['displayName'])
                item={}
                item['img'] =  urlparse.urljoin(base_url, i['bigThumb']).encode('utf-8')
                item['id'] = i['id']
                item['title'] = control.trans(i['displayName'].upper().encode("utf-8"))
                item['plot'] = i['description'].encode('utf-8')
                item = {'title': item['title'],  'genre': '0', 'plot': item['plot'],
                        'name': item['title'], 'tagline': '0', 'poster': item['img'], 'fanart': '0', 'id': item['id'],
                        'service': 'telewizjadanet', 'next': ''}
                items.append(item)
                #control.log('XXXXXXXXX %s' % i)

            except:
                pass
        return items

    except Exception as e:
        control.log('Error telewizjada.chanels %s' % e)
        control.dialog.ok(control.addonInfo('name') + ' - Telewizjada.net', control.lang(30602).encode('utf-8'), '')
        return
Example #12
0
    def root(self):
        self.addDirectoryItem(40003, 'tv&url=pierwsza', 'pierwsza.tv.png', 'DefaultMovies.png')
        self.addDirectoryItem(40001, 'tv&url=videostar', 'videostar.pl.png', 'DefaultMovies.png')
        self.addDirectoryItem(40002, 'tv&url=weeb', 'weeb.tv.png', 'DefaultMovies.png')
        self.addDirectoryItem(40005, 'tv&url=wizja', 'wizja.tv.png', 'DefaultMovies.png')
        self.addDirectoryItem(40004, 'tv&url=yoy', 'yoy.tv.png', 'DefaultMovies.png')

        #self.addDirectoryItem(30001, 'movieNavigator', 'movies.jpg', 'DefaultMovies.png')
        #self.addDirectoryItem(30002, 'tvNavigator', 'tvshows.jpg', 'DefaultTVShows.png')
        #self.addDirectoryItem(30003, 'channels', 'channels.jpg', 'DefaultMovies.png')
        #self.addDirectoryItem(30004, 'myNavigator', 'mymilenium.jpg', 'DefaultVideoPlaylists.png')

        #if not control.setting('movie_widget') == '0':
        #    self.addDirectoryItem(30005, 'movieWidget', 'moviesAdded.jpg', 'DefaultRecentlyAddedMovies.png')

        #if (traktMode == True and not control.setting('tv_alt_widget') == '0') or (traktMode == False and not control.setting('tv_widget') == '0'):
        #    self.addDirectoryItem(30006, 'tvWidget', 'calendarsAdded.jpg', 'DefaultRecentlyAddedEpisodes.png')

        #if not control.setting('calendar_widget') == '0':
        #    self.addDirectoryItem(30007, 'calendars', 'calendar.jpg', 'DefaultRecentlyAddedEpisodes.png')



        #self.addDirectoryItem(30033, 'tvFavourites', 'movieFavourites.jpg', 'DefaultMovies.png')




        self.addDirectoryItem(42008, 'toolNavigator', 'tools.jpg', 'DefaultAddonProgram.png')

        #self.addDirectoryItem(30009, 'searchNavigator', 'search.jpg', 'DefaultFolder.png')

        self.endDirectory()

        from resources.lib.lib import cache
        from resources.lib.lib import changelog
        cache.get(changelog.get, 600000000, control.addonInfo('version'), table='changelog')
Example #13
0
def login():
    try:
        #clean cookies
        client2._clean_cookies('http://wizja.tv/users/index.php')
        control.sleep(300)
        params = {}
        url = 'http://wizja.tv/users/index.php'
        result = client2.http_get(url)
        params['login'] = '******'
        params['user_name'] = control.get_setting('wizja.user')
        params['user_password'] = control.get_setting('wizja.pass')

        #login to site
        result = client2.http_get(url, data=params)
        control.sleep(300)
        control.log('WIZJA %s' % result)

        #wrong login
        if '<font color="#FF0000">Błędne hasło..</font>' in result:  #zly login
            control.log('WIZJA.TV ZLY LOGIN: %s' % result)
            control.infoDialog(control.lang(30497).encode('utf-8'), time=6000)
            control.dialog.ok(
                control.addonInfo('name') + ' - WIZJA TV',
                control.lang(30497).encode('utf-8'), '')

            raise Exception()
        elif 'lub hasło.</font>' in result:  #zly login
            control.log('WIZJA.TV ZLY LOGIN: %s' % result)
            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' % result)
                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:
                #all ok, return True
                return True
        #account locked - wait 60 minutes
        elif '<font color="#FF0000">Wpisa' in result:
            control.log(
                'WIZJA.TV zbyt wiele razy pobowales - poczekaj 60 minut: %s' %
                result)
            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' % result)
            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
Example #14
0
    def addItem(self, name, title, year, imdb, tmdb, tvdb, service, season, episode, tvshowtitle, alter, date, meta):
        try:
            if imdb == '0': imdb = '0000000'
            imdb = 'tt' + re.sub('[^0-9]', '', str(imdb))

            content = 'movie' if tvshowtitle == None else 'episode'

            self.sources = self.getSources(name, title, year, imdb, tmdb, tvdb, service, season, episode, tvshowtitle, alter, date)
            if self.sources == []: raise Exception()
            self.progressDialog = control.progressDialog
            self.progressDialog.create(control.addonInfo('name'), '')
            self.progressDialog.update(0, control.lang(30515).encode('utf-8'), str(' '))

            self.sources = self.sourcesFilter()
            infoMenu = control.lang(30502).encode('utf-8') if content == 'movie' else control.lang(30503).encode('utf-8')

            sysmeta = urllib.quote_plus(meta)
            sysaddon = sys.argv[0]

            meta = json.loads(meta)

            poster = meta['poster'] if 'poster' in meta else '0'
            banner = meta['banner'] if 'banner' in meta else '0'
            thumb = meta['thumb'] if 'thumb' in meta else poster
            fanart = meta['fanart'] if 'fanart' in meta else '0'

            if poster == '0': poster = control.addonPoster()
            if banner == '0' and poster == '0': banner = control.addonBanner()
            elif banner == '0': banner = poster
            if thumb == '0' and fanart == '0': thumb = control.addonFanart()
            elif thumb == '0': thumb = fanart
            if control.setting('fanart') == 'true' and not fanart == '0': pass
            else: fanart = control.addonFanart()

            for i in range(len(self.sources)):
                try:
                    if self.progressDialog.iscanceled(): break

                    self.progressDialog.update(int((100 / float(len(self.sources))) * i))
                    url, label, provider = self.sources[i]['url'], self.sources[i]['label'], self.sources[i]['provider']


                    sysname, sysurl, sysimage, sysprovider = urllib.quote_plus(name), urllib.quote_plus(url), urllib.quote_plus(poster), urllib.quote_plus(provider)

                    syssource = urllib.quote_plus(json.dumps([self.sources[i]]))
                    if i == 0:
                        query = 'action=playItem&content=%s&name=%s&year=%s&imdb=%s&tvdb=%s&source=%s&meta=%s' % (content, sysname, year, imdb, tvdb, syssource, sysmeta)
                    else:
                        query = 'action=playItem&content=%s&name=%s&year=%s&imdb=%s&tvdb=%s&source=%s' % (content, sysname, year, imdb, tvdb, syssource)

                    cm = []
                    cm.append((control.lang(30504).encode('utf-8'), 'RunPlugin(%s?action=queueItem)' % sysaddon))
                    cm.append((control.lang(30505).encode('utf-8'), 'RunPlugin(%s?action=download&name=%s&image=%s&url=%s&provider=%s)' % (sysaddon, sysname, sysimage, sysurl, sysprovider)))
                    cm.append((infoMenu, 'Action(Info)'))
                    cm.append((control.lang(30506).encode('utf-8'), 'RunPlugin(%s?action=refresh)' % sysaddon))
                    cm.append((control.lang(30507).encode('utf-8'), 'RunPlugin(%s?action=openSettings)' % sysaddon))
                    cm.append((control.lang(30508).encode('utf-8'), 'RunPlugin(%s?action=openPlaylist)' % sysaddon))

                    item = control.item(label=label, iconImage='DefaultVideo.png', thumbnailImage=thumb)
                    try: item.setArt({'poster': poster, 'tvshow.poster': poster, 'season.poster': poster, 'banner': banner, 'tvshow.banner': banner, 'season.banner': banner})
                    except: pass
                    item.setInfo(type='Video', infoLabels = meta)
                    if not fanart == None: item.setProperty('Fanart_Image', fanart)
                    item.setProperty('Video', 'true')
                    #item.setProperty('IsPlayable', 'true')
                    item.addContextMenuItems(cm, replaceItems=True)

                    control.addItem(handle=int(sys.argv[1]), url='%s?%s' % (sysaddon, query), listitem=item, isFolder=False)
                except:
                    pass

            control.directory(int(sys.argv[1]), cacheToDisc=True)
            try: self.progressDialog.close()
            except: pass
        except:
            control.infoDialog(control.lang(30501).encode('utf-8'))
            try: self.progressDialog.close()
            except: pass
Example #15
0
    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
Example #16
0
    def getSources(self, name, title, year, imdb, tmdb, tvdb, service, season, episode, tvshowtitle, alter, date):
        sourceDict = []
        for package, name, is_pkg in pkgutil.walk_packages(__path__):
            sourceDict.append((name, is_pkg))
        sourceDict = [i[0] for i in sourceDict if i[1] == False]

        content = 'movie' if tvshowtitle == None else 'episode'


        if content == 'movie':
            sourceDict = [i for i in sourceDict if i.endswith(('_mv', '_mv_tv'))]
            try: sourceDict = [(i, control.setting(re.sub('_mv_tv$|_mv$|_tv$', '', i))) for i in sourceDict]
            except: sourceDict = [(i, 'true') for i in sourceDict]
        else:
            sourceDict = [i for i in sourceDict if i.endswith(('_tv', '_mv_tv'))]
            try: sourceDict = [(i, control.setting(re.sub('_mv_tv$|_mv$|_tv$', '', i) + '_tv')) for i in sourceDict]
            except: sourceDict = [(i, 'true') for i in sourceDict]

        threads = []

        control.makeFile(control.dataPath)
        self.sourceFile = control.sourcescacheFile

        sourceDict = [i[0] for i in sourceDict if i[1] == 'true']

        if content == 'movie':
            title = cleantitle.normalize(title)
            for source in sourceDict: threads.append(workers.Thread(self.getMovieSource, title, year, imdb, re.sub('_mv_tv$|_mv$|_tv$', '', source), __import__(source, globals(), locals(), [], -1).source()))
        else:
            tvshowtitle = cleantitle.normalize(tvshowtitle)
            season, episode = alterepisode.alterepisode().get(imdb, tmdb, tvdb, service, season, episode, alter, title, date)
            for source in sourceDict: threads.append(workers.Thread(self.getEpisodeSource, title, year, imdb, tvdb, season, episode, tvshowtitle, date, re.sub('_mv_tv$|_mv$|_tv$', '', source), __import__(source, globals(), locals(), [], -1).source()))


        try: timeout = int(control.setting('sources_timeout_40'))
        except: timeout = 40

        [i.start() for i in threads]

        control.idle()

        sourceLabel = [re.sub('_mv_tv$|_mv$|_tv$', '', i) for i in sourceDict]
        sourceLabel = [re.sub('v\d+$', '', i).upper() for i in sourceLabel]


        self.progressDialog = control.progressDialog
        self.progressDialog.create(control.addonInfo('name'), '')
        self.progressDialog.update(0)

        string1 = control.lang(30512).encode('utf-8')
        string2 = control.lang(30513).encode('utf-8')
        string3 = control.lang(30514).encode('utf-8')

        for i in range(0, timeout * 2):
            try:
                if xbmc.abortRequested == True: return sys.exit()

                try: info = [sourceLabel[int(re.sub('[^0-9]', '', str(x.getName()))) - 1] for x in threads if x.is_alive() == True]
                except: info = []

                if len(info) > 5: info = len(info)

                self.progressDialog.update(int((100 / float(len(threads))) * len([x for x in threads if x.is_alive() == False])), str('%s: %s %s' % (string1, int(i * 0.5), string2)), str('%s: %s' % (string3, str(info).translate(None, "[]'"))))

                if self.progressDialog.iscanceled(): break

                is_alive = [x.is_alive() for x in threads]
                if all(x == False for x in is_alive): break
                time.sleep(0.5)
            except:
                pass

        self.progressDialog.close()

        return self.sources
Example #17
0
    def playItem(self, content, name, year, imdb, tvdb, source):
        try:
            control.resolve(int(sys.argv[1]), True, control.item(path=''))
            control.execute('Dialog.Close(okdialog)')

            next = [] ; prev = [] ; total = []
            meta = None

            for i in range(1,10000):
                try:
                    u = control.infoLabel('ListItem(%s).FolderPath' % str(i))
                    if u in total: raise Exception()
                    total.append(u)
                    u = dict(urlparse.parse_qsl(u.replace('?','')))
                    if 'meta' in u: meta = u['meta']
                    u = json.loads(u['source'])[0]
                    next.append(u)
                except:
                    break
            for i in range(-10000,0)[::-1]:
                try:
                    u = control.infoLabel('ListItem(%s).FolderPath' % str(i))
                    if u in total: raise Exception()
                    total.append(u)
                    u = dict(urlparse.parse_qsl(u.replace('?','')))
                    if 'meta' in u: meta = u['meta']
                    u = json.loads(u['source'])[0]
                    prev.append(u)
                except:
                    break

            items = json.loads(source)

            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()

                    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()

                    try: self.progressDialog.close()
                    except: pass

                    control.sleep(200)

                    if control.setting('playback_info') == 'true':
                        control.infoDialog(items[i]['label'], heading=name)

                    from resources.lib.lib.player import player
                    player().run(content, name, self.url, year, imdb, tvdb, meta)

                    return self.url
                except:
                    pass

            try: self.progressDialog.close()
            except: pass

            raise Exception()

        except:
            control.infoDialog(control.lang(30501).encode('utf-8'))
            pass
Example #18
0
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
Example #19
0
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
Example #20
0
    def playItem(self, content, name, year, imdb, tvdb, source):
        try:
            control.resolve(int(sys.argv[1]), True, control.item(path=''))
            control.execute('Dialog.Close(okdialog)')

            next = []
            prev = []
            total = []
            meta = None

            for i in range(1, 10000):
                try:
                    u = control.infoLabel('ListItem(%s).FolderPath' % str(i))
                    if u in total: raise Exception()
                    total.append(u)
                    u = dict(urlparse.parse_qsl(u.replace('?', '')))
                    if 'meta' in u: meta = u['meta']
                    u = json.loads(u['source'])[0]
                    next.append(u)
                except:
                    break
            for i in range(-10000, 0)[::-1]:
                try:
                    u = control.infoLabel('ListItem(%s).FolderPath' % str(i))
                    if u in total: raise Exception()
                    total.append(u)
                    u = dict(urlparse.parse_qsl(u.replace('?', '')))
                    if 'meta' in u: meta = u['meta']
                    u = json.loads(u['source'])[0]
                    prev.append(u)
                except:
                    break

            items = json.loads(source)

            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()

                    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()

                    try:
                        self.progressDialog.close()
                    except:
                        pass

                    control.sleep(200)

                    if control.setting('playback_info') == 'true':
                        control.infoDialog(items[i]['label'], heading=name)

                    from resources.lib.lib.player import player
                    player().run(content, name, self.url, year, imdb, tvdb,
                                 meta)

                    return self.url
                except:
                    pass

            try:
                self.progressDialog.close()
            except:
                pass

            raise Exception()

        except:
            control.infoDialog(control.lang(30501).encode('utf-8'))
            pass
Example #21
0
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
Example #22
0
    def getSources(self, name, title, year, imdb, tmdb, tvdb, service, season,
                   episode, tvshowtitle, alter, date):
        sourceDict = []
        for package, name, is_pkg in pkgutil.walk_packages(__path__):
            sourceDict.append((name, is_pkg))
        sourceDict = [i[0] for i in sourceDict if i[1] == False]

        content = 'movie' if tvshowtitle == None else 'episode'

        if content == 'movie':
            sourceDict = [
                i for i in sourceDict if i.endswith(('_mv', '_mv_tv'))
            ]
            try:
                sourceDict = [
                    (i, control.setting(re.sub('_mv_tv$|_mv$|_tv$', '', i)))
                    for i in sourceDict
                ]
            except:
                sourceDict = [(i, 'true') for i in sourceDict]
        else:
            sourceDict = [
                i for i in sourceDict if i.endswith(('_tv', '_mv_tv'))
            ]
            try:
                sourceDict = [(i,
                               control.setting(
                                   re.sub('_mv_tv$|_mv$|_tv$', '', i) + '_tv'))
                              for i in sourceDict]
            except:
                sourceDict = [(i, 'true') for i in sourceDict]

        threads = []

        control.makeFile(control.dataPath)
        self.sourceFile = control.sourcescacheFile

        sourceDict = [i[0] for i in sourceDict if i[1] == 'true']

        if content == 'movie':
            title = cleantitle.normalize(title)
            for source in sourceDict:
                threads.append(
                    workers.Thread(
                        self.getMovieSource, title, year, imdb,
                        re.sub('_mv_tv$|_mv$|_tv$', '', source),
                        __import__(source, globals(), locals(), [],
                                   -1).source()))
        else:
            tvshowtitle = cleantitle.normalize(tvshowtitle)
            season, episode = alterepisode.alterepisode().get(
                imdb, tmdb, tvdb, service, season, episode, alter, title, date)
            for source in sourceDict:
                threads.append(
                    workers.Thread(
                        self.getEpisodeSource, title, year, imdb, tvdb, season,
                        episode, tvshowtitle, date,
                        re.sub('_mv_tv$|_mv$|_tv$', '', source),
                        __import__(source, globals(), locals(), [],
                                   -1).source()))

        try:
            timeout = int(control.setting('sources_timeout_40'))
        except:
            timeout = 40

        [i.start() for i in threads]

        control.idle()

        sourceLabel = [re.sub('_mv_tv$|_mv$|_tv$', '', i) for i in sourceDict]
        sourceLabel = [re.sub('v\d+$', '', i).upper() for i in sourceLabel]

        self.progressDialog = control.progressDialog
        self.progressDialog.create(control.addonInfo('name'), '')
        self.progressDialog.update(0)

        string1 = control.lang(30512).encode('utf-8')
        string2 = control.lang(30513).encode('utf-8')
        string3 = control.lang(30514).encode('utf-8')

        for i in range(0, timeout * 2):
            try:
                if xbmc.abortRequested == True: return sys.exit()

                try:
                    info = [
                        sourceLabel[int(re.sub('[^0-9]', '', str(x.getName())))
                                    - 1] for x in threads
                        if x.is_alive() == True
                    ]
                except:
                    info = []

                if len(info) > 5: info = len(info)

                self.progressDialog.update(
                    int((100 / float(len(threads))) *
                        len([x for x in threads if x.is_alive() == False])),
                    str('%s: %s %s' % (string1, int(i * 0.5), string2)),
                    str('%s: %s' %
                        (string3, str(info).translate(None, "[]'"))))

                if self.progressDialog.iscanceled(): break

                is_alive = [x.is_alive() for x in threads]
                if all(x == False for x in is_alive): break
                time.sleep(0.5)
            except:
                pass

        self.progressDialog.close()

        return self.sources
Example #23
0
    def addItem(self, name, title, year, imdb, tmdb, tvdb, service, season,
                episode, tvshowtitle, alter, date, meta):
        try:
            if imdb == '0': imdb = '0000000'
            imdb = 'tt' + re.sub('[^0-9]', '', str(imdb))

            content = 'movie' if tvshowtitle == None else 'episode'

            self.sources = self.getSources(name, title, year, imdb, tmdb, tvdb,
                                           service, season, episode,
                                           tvshowtitle, alter, date)
            if self.sources == []: raise Exception()
            self.progressDialog = control.progressDialog
            self.progressDialog.create(control.addonInfo('name'), '')
            self.progressDialog.update(0,
                                       control.lang(30515).encode('utf-8'),
                                       str(' '))

            self.sources = self.sourcesFilter()
            infoMenu = control.lang(30502).encode(
                'utf-8') if content == 'movie' else control.lang(30503).encode(
                    'utf-8')

            sysmeta = urllib.quote_plus(meta)
            sysaddon = sys.argv[0]

            meta = json.loads(meta)

            poster = meta['poster'] if 'poster' in meta else '0'
            banner = meta['banner'] if 'banner' in meta else '0'
            thumb = meta['thumb'] if 'thumb' in meta else poster
            fanart = meta['fanart'] if 'fanart' in meta else '0'

            if poster == '0': poster = control.addonPoster()
            if banner == '0' and poster == '0': banner = control.addonBanner()
            elif banner == '0': banner = poster
            if thumb == '0' and fanart == '0': thumb = control.addonFanart()
            elif thumb == '0': thumb = fanart
            if control.setting('fanart') == 'true' and not fanart == '0': pass
            else: fanart = control.addonFanart()

            for i in range(len(self.sources)):
                try:
                    if self.progressDialog.iscanceled(): break

                    self.progressDialog.update(
                        int((100 / float(len(self.sources))) * i))
                    url, label, provider = self.sources[i][
                        'url'], self.sources[i]['label'], self.sources[i][
                            'provider']

                    sysname, sysurl, sysimage, sysprovider = urllib.quote_plus(
                        name), urllib.quote_plus(url), urllib.quote_plus(
                            poster), urllib.quote_plus(provider)

                    syssource = urllib.quote_plus(json.dumps([self.sources[i]
                                                              ]))
                    if i == 0:
                        query = 'action=playItem&content=%s&name=%s&year=%s&imdb=%s&tvdb=%s&source=%s&meta=%s' % (
                            content, sysname, year, imdb, tvdb, syssource,
                            sysmeta)
                    else:
                        query = 'action=playItem&content=%s&name=%s&year=%s&imdb=%s&tvdb=%s&source=%s' % (
                            content, sysname, year, imdb, tvdb, syssource)

                    cm = []
                    cm.append((control.lang(30504).encode('utf-8'),
                               'RunPlugin(%s?action=queueItem)' % sysaddon))
                    cm.append((
                        control.lang(30505).encode('utf-8'),
                        'RunPlugin(%s?action=download&name=%s&image=%s&url=%s&provider=%s)'
                        % (sysaddon, sysname, sysimage, sysurl, sysprovider)))
                    cm.append((infoMenu, 'Action(Info)'))
                    cm.append((control.lang(30506).encode('utf-8'),
                               'RunPlugin(%s?action=refresh)' % sysaddon))
                    cm.append((control.lang(30507).encode('utf-8'),
                               'RunPlugin(%s?action=openSettings)' % sysaddon))
                    cm.append((control.lang(30508).encode('utf-8'),
                               'RunPlugin(%s?action=openPlaylist)' % sysaddon))

                    item = control.item(label=label,
                                        iconImage='DefaultVideo.png',
                                        thumbnailImage=thumb)
                    try:
                        item.setArt({
                            'poster': poster,
                            'tvshow.poster': poster,
                            'season.poster': poster,
                            'banner': banner,
                            'tvshow.banner': banner,
                            'season.banner': banner
                        })
                    except:
                        pass
                    item.setInfo(type='Video', infoLabels=meta)
                    if not fanart == None:
                        item.setProperty('Fanart_Image', fanart)
                    item.setProperty('Video', 'true')
                    #item.setProperty('IsPlayable', 'true')
                    item.addContextMenuItems(cm, replaceItems=True)

                    control.addItem(handle=int(sys.argv[1]),
                                    url='%s?%s' % (sysaddon, query),
                                    listitem=item,
                                    isFolder=False)
                except:
                    pass

            control.directory(int(sys.argv[1]), cacheToDisc=True)
            try:
                self.progressDialog.close()
            except:
                pass
        except:
            control.infoDialog(control.lang(30501).encode('utf-8'))
            try:
                self.progressDialog.close()
            except:
                pass
Example #24
0
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
Example #25
0
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 )
Example #26
0
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
Example #27
0
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
Example #28
0
    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
Example #29
0
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 LOGIN: %s' % result)
            control.infoDialog(control.lang(30497).encode('utf-8'), time=6000)
            control.dialog.ok(
                control.addonInfo('name') + ' - WIZJA TV',
                control.lang(30497).encode('utf-8'), '')
            raise Exception()
        elif 'lub hasło.</font>' in result:  #zly login
            control.log('WIZJA.TV ZLY LOGIN: %s' % result)
            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' % result)
                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' %
                result)
            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' % result)
            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
Example #30
0
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)