Ejemplo n.º 1
0
    def milenium(self):
        if traktMode == True:
            self.addDirectoryItem(30081, 'movies&url=traktcollection', 'moviesTraktcollection.jpg', 'DefaultMovies.png', context=(30191, 'moviesToLibrary&url=traktcollection'))
            self.addDirectoryItem(30082, 'movies&url=traktwatchlist', 'moviesTraktwatchlist.jpg', 'DefaultMovies.png', context=(30191, 'moviesToLibrary&url=traktwatchlist'))
            self.addDirectoryItem(30083, 'movies&url=traktfeatured', 'movies.jpg', 'DefaultMovies.png')
            #self.addDirectoryItem(30084, 'movies&url=traktratings', 'movies.jpg', 'DefaultMovies.png')
            self.addDirectoryItem(30085, 'tvshows&url=traktcollection', 'tvshowsTraktcollection.jpg', 'DefaultTVShows.png', context=(30191, 'tvshowsToLibrary&url=traktcollection'))
            self.addDirectoryItem(30086, 'tvshows&url=traktwatchlist', 'tvshowsTraktwatchlist.jpg', 'DefaultTVShows.png', context=(30191, 'tvshowsToLibrary&url=traktwatchlist'))
            self.addDirectoryItem(30087, 'tvshows&url=traktfeatured', 'tvshows.jpg', 'DefaultTVShows.png')
            #self.addDirectoryItem(30088, 'tvshows&url=traktratings', 'tvshows.jpg', 'DefaultTVShows.png')
            self.addDirectoryItem(30089, 'calendar&url=progress', 'calendarsProgress.jpg', 'DefaultRecentlyAddedEpisodes.png')
            self.addDirectoryItem(30090, 'calendar&url=mycalendar', 'calendarsMycalendar.jpg', 'DefaultRecentlyAddedEpisodes.png')

        if imdbMode == True:
            self.addDirectoryItem(30091, 'movies&url=imdbwatchlist', 'moviesImdbwatchlist.jpg', 'DefaultMovies.png', context=(30191, 'moviesToLibrary&url=imdbwatchlist'))
            self.addDirectoryItem(30092, 'tvshows&url=imdbwatchlist', 'tvshowsImdbwatchlist.jpg', 'DefaultTVShows.png', context=(30191, 'tvshowsToLibrary&url=imdbwatchlist'))

        if traktMode == True or imdbMode == True:
            self.addDirectoryItem(30093, 'movieUserlists', 'movieUserlists.jpg', 'DefaultMovies.png')
            self.addDirectoryItem(30094, 'tvUserlists', 'tvUserlists.jpg', 'DefaultTVShows.png')

        self.addDirectoryItem(30095, 'movieFavourites', 'movieFavourites.jpg', 'DefaultMovies.png')
        self.addDirectoryItem(30096, 'episodeFavourites', 'tvFavourites.jpg', 'DefaultTVShows.png')
        self.addDirectoryItem(30097, 'tvFavourites', 'tvFavourites.jpg', 'DefaultTVShows.png')

        movie_downloads = control.setting('movie_downloads')
        tv_downloads = control.setting('tv_downloads')
        if len(control.listDir(movie_downloads)[0]) > 0 or len(control.listDir(tv_downloads)[0]) > 0:
            self.addDirectoryItem(30098, 'downloadNavigator', 'downloads.jpg', 'DefaultFolder.png')

        self.endDirectory()
Ejemplo n.º 2
0
def getVideostarCredentialsInfo():
    user = control.setting('videostar.user').strip()
    password = control.setting('videostar.pass')
    sess = control.setting('videostar.sess')

    if (user == '' or password == ''): return False
    return True
Ejemplo n.º 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':
            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'
        )
Ejemplo n.º 4
0
def getVideostarCredentialsInfo():
    user = control.setting('videostar.user').strip()
    password = control.setting('videostar.pass')
    sess = control.setting('videostar.sess')

    if (user == '' or password == ''): return False
    return True
Ejemplo n.º 5
0
    def milenium(self):
        if traktMode == True:
            self.addDirectoryItem(30081, 'movies&url=traktcollection', 'moviesTraktcollection.jpg', 'DefaultMovies.png', context=(30191, 'moviesToLibrary&url=traktcollection'))
            self.addDirectoryItem(30082, 'movies&url=traktwatchlist', 'moviesTraktwatchlist.jpg', 'DefaultMovies.png', context=(30191, 'moviesToLibrary&url=traktwatchlist'))
            self.addDirectoryItem(30083, 'movies&url=traktfeatured', 'movies.jpg', 'DefaultMovies.png')
            #self.addDirectoryItem(30084, 'movies&url=traktratings', 'movies.jpg', 'DefaultMovies.png')
            self.addDirectoryItem(30085, 'tvshows&url=traktcollection', 'tvshowsTraktcollection.jpg', 'DefaultTVShows.png', context=(30191, 'tvshowsToLibrary&url=traktcollection'))
            self.addDirectoryItem(30086, 'tvshows&url=traktwatchlist', 'tvshowsTraktwatchlist.jpg', 'DefaultTVShows.png', context=(30191, 'tvshowsToLibrary&url=traktwatchlist'))
            self.addDirectoryItem(30087, 'tvshows&url=traktfeatured', 'tvshows.jpg', 'DefaultTVShows.png')
            #self.addDirectoryItem(30088, 'tvshows&url=traktratings', 'tvshows.jpg', 'DefaultTVShows.png')
            self.addDirectoryItem(30089, 'calendar&url=progress', 'calendarsProgress.jpg', 'DefaultRecentlyAddedEpisodes.png')
            self.addDirectoryItem(30090, 'calendar&url=mycalendar', 'calendarsMycalendar.jpg', 'DefaultRecentlyAddedEpisodes.png')

        if imdbMode == True:
            self.addDirectoryItem(30091, 'movies&url=imdbwatchlist', 'moviesImdbwatchlist.jpg', 'DefaultMovies.png', context=(30191, 'moviesToLibrary&url=imdbwatchlist'))
            self.addDirectoryItem(30092, 'tvshows&url=imdbwatchlist', 'tvshowsImdbwatchlist.jpg', 'DefaultTVShows.png', context=(30191, 'tvshowsToLibrary&url=imdbwatchlist'))

        if traktMode == True or imdbMode == True:
            self.addDirectoryItem(30093, 'movieUserlists', 'movieUserlists.jpg', 'DefaultMovies.png')
            self.addDirectoryItem(30094, 'tvUserlists', 'tvUserlists.jpg', 'DefaultTVShows.png')

        self.addDirectoryItem(30095, 'movieFavourites', 'movieFavourites.jpg', 'DefaultMovies.png')
        self.addDirectoryItem(30096, 'episodeFavourites', 'tvFavourites.jpg', 'DefaultTVShows.png')
        self.addDirectoryItem(30097, 'tvFavourites', 'tvFavourites.jpg', 'DefaultTVShows.png')

        movie_downloads = control.setting('movie_downloads')
        tv_downloads = control.setting('tv_downloads')
        if len(control.listDir(movie_downloads)[0]) > 0 or len(control.listDir(tv_downloads)[0]) > 0:
            self.addDirectoryItem(30098, 'downloadNavigator', 'downloads.jpg', 'DefaultFolder.png')

        self.endDirectory()
Ejemplo n.º 6
0
 def __init__(self):
     movie_library = os.path.join(
         control.transPath(control.setting('movie_library')), '')
     tv_library = os.path.join(
         control.transPath(control.setting('tv_library')), '')
     tv_downloads = os.path.join(
         control.transPath(control.setting('tv_downloads')), '')
Ejemplo n.º 7
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' )
Ejemplo n.º 8
0
    def downloads(self):
        movie_downloads = control.setting('movie_downloads')
        tv_downloads = control.setting('tv_downloads')

        if len(control.listDir(movie_downloads)[0]) > 0:
            self.addDirectoryItem(30099, movie_downloads, 'movies.jpg', 'DefaultMovies.png', isAction=False)
        if len(control.listDir(tv_downloads)[0]) > 0:
            self.addDirectoryItem(30100, tv_downloads, 'tvshows.jpg', 'DefaultTVShows.png', isAction=False)

        self.endDirectory()
Ejemplo n.º 9
0
    def downloads(self):
        movie_downloads = control.setting('movie_downloads')
        tv_downloads = control.setting('tv_downloads')

        if len(control.listDir(movie_downloads)[0]) > 0:
            self.addDirectoryItem(30099, movie_downloads, 'movies.jpg', 'DefaultMovies.png', isAction=False)
        if len(control.listDir(tv_downloads)[0]) > 0:
            self.addDirectoryItem(30100, tv_downloads, 'tvshows.jpg', 'DefaultTVShows.png', isAction=False)

        self.endDirectory()
Ejemplo n.º 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
Ejemplo n.º 11
0
    def checkSources(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:
                control.log("SOURCE S2 %s" % source)
                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]

        for i in range(0, timeout * 2):
            try:
                if xbmc.abortRequested == True: return sys.exit()
                if len(self.sources) >= 10: 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

        if len(self.sources) >= 10: return True
        else: return False
Ejemplo n.º 12
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
Ejemplo n.º 13
0
def get(url, params={}):
    try:
        params['platform'] = HOST
        params['v'] = '0.2.0~beta'

        if getWeebCredentialsInfo():
            params['username'] = control.setting('weeb.user').strip()
            params['userpassword'] = control.setting('weeb.pass')

        url = urlparse.urljoin('http://weeb.tv', url)

        result = client.request(url, headers=headers, post=params)
        return result
    except:
        pass
Ejemplo n.º 14
0
def get(url, params={}):
    try:
        params['platform'] = HOST
        params['v'] = '0.2.0~beta'

        if getWeebCredentialsInfo():
            params['username'] = control.setting('weeb.user').strip()
            params['userpassword'] = control.setting('weeb.pass')

        url = urlparse.urljoin('http://weeb.tv', url)

        result = client.request(url, headers=headers, post=params)
        return result
    except:
        pass
Ejemplo n.º 15
0
def ipla_system_id():
    systemid = control.setting('ipla.systemid').strip()
    if (systemid == ''):
        myrand = gen_hex_code(10) + '-' + gen_hex_code(4) + '-' + gen_hex_code(
            4) + '-' + gen_hex_code(4) + '-' + gen_hex_code(12)
        control.set_setting('ipla.systemid', myrand)
    return True
Ejemplo n.º 16
0
    def sourcesReset(self):
        try:
            if control.setting('hosthd1') == '': return

            settingsFile = control.settingsFile
            file = control.openFile(settingsFile)
            read = file.read().splitlines()
            file.close()

            write = unicode('<settings>' + '\n', 'UTF-8')
            for line in read:
                if len(re.findall('<settings>', line)) > 0: continue
                elif len(re.findall('</settings>', line)) > 0: continue
                elif len(re.findall('id="(host|hosthd)500\d*"', line)) > 0:
                    pass
                elif len(re.findall('id="(host|hosthd)\d*"', line)) > 0:
                    continue
                write += unicode(line.rstrip() + '\n', 'UTF-8')
            write += unicode('</settings>' + '\n', 'UTF-8')

            file = control.openFile(settingsFile, 'w')
            file.write(str(write))
            file.close()
        except:
            return
Ejemplo n.º 17
0
def ipla_system_id():
    systemid = control.setting('ipla.systemid').strip()
    if (systemid == ''):
        myrand = gen_hex_code(10) + '-' + gen_hex_code(4) + '-' + gen_hex_code(4) + '-' + gen_hex_code(
            4) + '-' + gen_hex_code(12)
        control.set_setting('ipla.systemid', myrand)
    return True
Ejemplo n.º 18
0
    def library(self):
        self.addDirectoryItem(30131, 'openSettings&query=7.0', 'settings.jpg', 'DefaultAddonProgram.png')
        self.addDirectoryItem(30132, 'updateLibrary&query=tool', 'update.jpg', 'DefaultAddonProgram.png')
        self.addDirectoryItem(30133, control.setting('movie_library'), 'movies.jpg', 'DefaultMovies.png', isAction=False)
        self.addDirectoryItem(30134, control.setting('tv_library'), 'tvshows.jpg', 'DefaultTVShows.png', isAction=False)

        if traktMode == True:
            self.addDirectoryItem(30135, 'moviesToLibrary&url=traktcollection', 'moviesTraktcollection.jpg', 'DefaultMovies.png')
            self.addDirectoryItem(30136, 'moviesToLibrary&url=traktwatchlist', 'moviesTraktwatchlist.jpg', 'DefaultMovies.png')
            self.addDirectoryItem(30137, 'tvshowsToLibrary&url=traktcollection', 'tvshowsTraktcollection.jpg', 'DefaultTVShows.png')
            self.addDirectoryItem(30138, 'tvshowsToLibrary&url=traktwatchlist', 'tvshowsTraktwatchlist.jpg', 'DefaultTVShows.png')

        if imdbMode == True:
            self.addDirectoryItem(30139, 'moviesToLibrary&url=imdbwatchlist', 'moviesImdbwatchlist.jpg', 'DefaultMovies.png')
            self.addDirectoryItem(30140, 'tvshowsToLibrary&url=imdbwatchlist', 'tvshowsImdbwatchlist.jpg', 'DefaultTVShows.png')

        self.endDirectory()
Ejemplo n.º 19
0
    def library(self):
        self.addDirectoryItem(30131, 'openSettings&query=7.0', 'settings.jpg', 'DefaultAddonProgram.png')
        self.addDirectoryItem(30132, 'updateLibrary&query=tool', 'update.jpg', 'DefaultAddonProgram.png')
        self.addDirectoryItem(30133, control.setting('movie_library'), 'movies.jpg', 'DefaultMovies.png', isAction=False)
        self.addDirectoryItem(30134, control.setting('tv_library'), 'tvshows.jpg', 'DefaultTVShows.png', isAction=False)

        if traktMode == True:
            self.addDirectoryItem(30135, 'moviesToLibrary&url=traktcollection', 'moviesTraktcollection.jpg', 'DefaultMovies.png')
            self.addDirectoryItem(30136, 'moviesToLibrary&url=traktwatchlist', 'moviesTraktwatchlist.jpg', 'DefaultMovies.png')
            self.addDirectoryItem(30137, 'tvshowsToLibrary&url=traktcollection', 'tvshowsTraktcollection.jpg', 'DefaultTVShows.png')
            self.addDirectoryItem(30138, 'tvshowsToLibrary&url=traktwatchlist', 'tvshowsTraktwatchlist.jpg', 'DefaultTVShows.png')

        if imdbMode == True:
            self.addDirectoryItem(30139, 'moviesToLibrary&url=imdbwatchlist', 'moviesImdbwatchlist.jpg', 'DefaultMovies.png')
            self.addDirectoryItem(30140, 'tvshowsToLibrary&url=imdbwatchlist', 'tvshowsImdbwatchlist.jpg', 'DefaultTVShows.png')

        self.endDirectory()
Ejemplo n.º 20
0
    def getVideoInfo(self, content, name, year, imdb, tvdb):
        try:
            self.loadingTime = time.time()
            self.totalTime = 0
            self.currentTime = 0
            self.folderPath = control.infoLabel('Container.FolderPath')
            self.name = name
            self.year = year
            self.content = content
            self.file = self.name + '.strm'
            self.file = self.file.translate(None, '\/:*?"<>|').strip('.')
            self.imdb = 'tt' + imdb if imdb.isdigit() else imdb
            self.tvdb = tvdb if not tvdb == None else '0'
        except:
            pass

        try:
            if self.content == 'movie':
                self.title = re.compile('(.+?) [(]\d{4}[)]$').findall(
                    self.name)[0]
            elif self.content == 'episode':
                self.tvshowtitle, self.season, self.episode = re.compile(
                    '(.+?) S(\d*)E(\d*)$').findall(self.name)[0]
                self.season, self.episode = '%01d' % int(
                    self.season), '%01d' % int(self.episode)
                self.file2 = '%s (%s) S%02dE%02d.strm' % (
                    self.tvshowtitle.translate(None, '\/:*?"<>|'), self.year,
                    int(self.season), int(self.episode))
        except:
            pass

        try:
            if control.setting('resume_playback') == 'true':
                self.offset = bookmarks.getBookmark(self.name, self.imdb)
                if self.offset == '0': raise Exception()

                minutes, seconds = divmod(float(self.offset), 60)
                hours, minutes = divmod(minutes, 60)
                yes = control.yesnoDialog(
                    '%s %02d:%02d:%02d' % (control.lang(30461).encode('utf-8'),
                                           hours, minutes, seconds), '', '',
                    self.name,
                    control.lang(30463).encode('utf-8'),
                    control.lang(30462).encode('utf-8'))

                if yes: self.offset = '0'
        except:
            pass

        try:
            if self.content == 'movie':
                control.window.setProperty('script.trakt.ids',
                                           json.dumps({'imdb': self.imdb}))
            elif self.content == 'episode':
                control.window.setProperty('script.trakt.ids',
                                           json.dumps({'tvdb': self.tvdb}))
        except:
            pass
Ejemplo n.º 21
0
    def widget(self):
        setting = control.setting('movie_widget')

        if setting == '2':
            self.get(self.featured_link)
        elif setting == '3':
            self.get(self.trending_link)
        else:
            self.get(self.added_link)
Ejemplo n.º 22
0
    def alterSources(self, url, meta):
        try:
            setting = control.setting('autoplay')
            if setting == 'false': url += '&url=direct://'
            else: url += '&url=dialog://'

            control.execute('RunPlugin(%s)' % url)
        except:
            pass
Ejemplo n.º 23
0
    def alterSources(self, url, meta):
        try:
            setting = control.setting('autoplay')
            if setting == 'false': url += '&url=direct://'
            else: url += '&url=dialog://'

            control.execute('RunPlugin(%s)' % url)
        except:
            pass
Ejemplo n.º 24
0
def getstream(id):
    try:

        if wizjalogin():
            cookie = control.setting('wizja.token').strip()
            ref = 'http://wizja.tv/watch.php?id=%s' % id
            result = client.request(ref, headers=HOST, cookie=cookie)
            HOST['Referer'] = ref
            url = 'http://wizja.tv/porter.php?ch=%s' % id
            result = client.request(url, headers=HOST, cookie=cookie)
            mylink = re.compile('src: "(.*?)"').findall(result)
            mykill = re.compile('<a href="killme.php\?id=(.*?)" target="_top">'
                                ).findall(result)
            control.log('AMA %s|%s' % (mylink, mykill))
            if len(mylink) > 0:
                rtmp2 = urllib.unquote(mylink[0]).decode('utf8')
                rtmp1 = re.compile(
                    'rtmp://(.*?)/(.*?)/(.*?)\?(.*?)\&streamType').findall(
                        rtmp2)
                control.log('AMA1 %s' % (rtmp1))
                control.log('AMA2 %s' % (rtmp2))

                rtmp = 'rtmp://' + rtmp1[0][0] + '/' + rtmp1[0][
                    1] + '/' + rtmp1[0][2] + '?' + rtmp1[0][
                        3] + ' app=' + rtmp1[0][1] + '?' + rtmp1[0][
                            3] + ' swfVfy=1 flashver=WIN\\2020,0,0,306 timeout=25 swfUrl=http://wizja.tv/player/StrobeMediaPlayback.swf live=true pageUrl=' + ref
                control.log('AMA3 %s' % (rtmp))

                return rtmp
            #kill other sessions
            elif len(mykill) > 0:
                control.log('Error KILL %s' % mykill)
                urlkill = 'http://wizja.tv/killme.php?id=%s' % mykill[0]
                result = client.request(urlkill, headers=HOST, cookie=cookie)
                control.sleep(300)
                url = 'http://wizja.tv/porter.php?ch=%s' % id
                result = client.request(url, headers=HOST, cookie=cookie)
                mylink = re.compile('src: "(.*?)"').findall(result)
                if len(mylink) > 0:
                    rtmp2 = urllib.unquote(mylink[0]).decode('utf8')
                    rtmp1 = re.compile(
                        'rtmp://(.*?)/(.*?)/(.*?)\?(.*?)\&streamType').findall(
                            rtmp2)
                    rtmp = 'rtmp://' + rtmp1[0][0] + '/' + rtmp1[0][
                        1] + '/' + rtmp1[0][2] + '?' + rtmp1[0][
                            3] + ' app=' + rtmp1[0][1] + '?' + rtmp1[0][
                                3] + ' swfVfy=1 flashver=WIN\\2020,0,0,306 timeout=25 swfUrl=http://wizja.tv/player/StrobeMediaPlayback.swf live=true pageUrl=' + ref
                    return rtmp
            else:
                raise Exception('WWW: ' + result)
        else:
            return
    except Exception as e:
        control.log('Error wizja.getstream %s' % e)
Ejemplo n.º 25
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
Ejemplo n.º 26
0
    def sourcesReset(self):
        try:
            if control.setting('hosthd1') == '': return

            settingsFile = control.settingsFile
            file = control.openFile(settingsFile) ; read = file.read().splitlines() ; file.close()

            write = unicode( '<settings>' + '\n', 'UTF-8' )
            for line in read:
                if len(re.findall('<settings>', line)) > 0: continue
                elif len(re.findall('</settings>', line)) > 0: continue
                elif len(re.findall('id="(host|hosthd)500\d*"', line)) > 0: pass
                elif len(re.findall('id="(host|hosthd)\d*"', line)) > 0: continue
                write += unicode(line.rstrip() + '\n', 'UTF-8')
            write += unicode('</settings>' + '\n', 'UTF-8')

            file = control.openFile(settingsFile, 'w') ; file.write(str(write)) ; file.close()
        except:
            return
Ejemplo n.º 27
0
def getstream(id):
    try:

        if wizjalogin():
            cookie = control.setting('wizja.token').strip()
            ref='http://wizja.tv/watch.php?id=%s' % id
            result =  client.request(ref, headers=HOST, cookie=cookie)
            HOST['Referer']=ref
            url = 'http://wizja.tv/porter.php?ch=%s' % id
            result =  client.request(url, headers=HOST, cookie=cookie)
            mylink = re.compile('src: "(.*?)"').findall(result)
            mykill = re.compile('<a href="killme.php\?id=(.*?)" target="_top">').findall(result)
            control.log('AMA %s|%s' %(mylink,mykill))
            if len(mylink)>0:
                rtmp2 = urllib.unquote(mylink[0]).decode('utf8')
                rtmp1 = re.compile('rtmp://(.*?)/(.*?)/(.*?)\?(.*?)\&streamType').findall(rtmp2)
                control.log('AMA1 %s' % (rtmp1))
                control.log('AMA2 %s' % (rtmp2))

                rtmp = 'rtmp://' + rtmp1[0][0] + '/' + rtmp1[0][1] +'/' +rtmp1[0][2]+ '?'+ rtmp1[0][3]+ ' app=' + rtmp1[0][1] + '?' +rtmp1[0][3]+' swfVfy=1 flashver=WIN\\2020,0,0,306 timeout=25 swfUrl=http://wizja.tv/player/StrobeMediaPlayback.swf live=true pageUrl='+ref
                control.log('AMA3 %s' % (rtmp))

                return rtmp
            #kill other sessions
            elif len(mykill)>0:
                control.log('Error KILL %s' % mykill)
                urlkill = 'http://wizja.tv/killme.php?id=%s' % mykill[0]
                result = client.request(urlkill , headers=HOST, cookie=cookie)
                control.sleep(300)
                url = 'http://wizja.tv/porter.php?ch=%s' % id
                result = client.request(url, headers=HOST, cookie=cookie)
                mylink = re.compile('src: "(.*?)"').findall(result)
                if len(mylink)>0:
                    rtmp2 = urllib.unquote(mylink[0]).decode('utf8')
                    rtmp1 = re.compile('rtmp://(.*?)/(.*?)/(.*?)\?(.*?)\&streamType').findall(rtmp2)
                    rtmp = 'rtmp://' + rtmp1[0][0] + '/' + rtmp1[0][1] +'/' +rtmp1[0][2]+ '?'+ rtmp1[0][3]+ ' app=' + rtmp1[0][1] + '?' +rtmp1[0][3]+' swfVfy=1 flashver=WIN\\2020,0,0,306 timeout=25 swfUrl=http://wizja.tv/player/StrobeMediaPlayback.swf live=true pageUrl='+ref
                    return rtmp
            else:
                raise Exception('WWW: '+result)
        else:
            return
    except Exception as e:
        control.log('Error wizja.getstream %s' % e)
Ejemplo n.º 28
0
    def getVideoInfo(self, content, name, year, imdb, tvdb):
        try:
            self.loadingTime = time.time()
            self.totalTime = 0 ; self.currentTime = 0
            self.folderPath = control.infoLabel('Container.FolderPath')
            self.name = name ; self.year = year ; self.content = content
            self.file = self.name + '.strm'
            self.file = self.file.translate(None, '\/:*?"<>|').strip('.')
            self.imdb = 'tt' + imdb if imdb.isdigit() else imdb
            self.tvdb = tvdb if not tvdb == None else '0'
        except:
            pass

        try:
            if self.content == 'movie':
                self.title = re.compile('(.+?) [(]\d{4}[)]$').findall(self.name)[0]
            elif self.content == 'episode':
                self.tvshowtitle, self.season, self.episode = re.compile('(.+?) S(\d*)E(\d*)$').findall(self.name)[0]
                self.season, self.episode = '%01d' % int(self.season), '%01d' % int(self.episode)
                self.file2 = '%s (%s) S%02dE%02d.strm' % (self.tvshowtitle.translate(None, '\/:*?"<>|'), self.year, int(self.season), int(self.episode))
        except:
            pass

        try:
            if control.setting('resume_playback') == 'true':
                self.offset = bookmarks.getBookmark(self.name, self.imdb)
                if self.offset == '0': raise Exception()

                minutes, seconds = divmod(float(self.offset), 60) ; hours, minutes = divmod(minutes, 60)
                yes = control.yesnoDialog('%s %02d:%02d:%02d' % (control.lang(30461).encode('utf-8'), hours, minutes, seconds), '', '', self.name, control.lang(30463).encode('utf-8'), control.lang(30462).encode('utf-8'))

                if yes: self.offset = '0'
        except:
            pass

        try:
            if self.content == 'movie':
                control.window.setProperty('script.trakt.ids', json.dumps({'imdb': self.imdb}))
            elif self.content == 'episode':
                control.window.setProperty('script.trakt.ids', json.dumps({'tvdb': self.tvdb}))
        except:
            pass
Ejemplo n.º 29
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
Ejemplo n.º 30
0
    def sourcesFilter(self):
        self.sourcesReset()
        try:
            customhdDict = [
                control.setting('hosthd50001'),
                control.setting('hosthd50002'),
                control.setting('hosthd50003'),
                control.setting('hosthd50004'),
                control.setting('hosthd50005'),
                control.setting('hosthd50006'),
                control.setting('hosthd50007'),
                control.setting('hosthd50008'),
                control.setting('hosthd50009'),
                control.setting('hosthd50010'),
                control.setting('hosthd50011'),
                control.setting('hosthd50012'),
                control.setting('hosthd50013'),
                control.setting('hosthd50014'),
                control.setting('hosthd50015'),
                control.setting('hosthd50016'),
                control.setting('hosthd50017'),
                control.setting('hosthd50018'),
                control.setting('hosthd50019'),
                control.setting('hosthd50020')
            ]
        except:
            customhdDict = []
        try:
            customsdDict = [
                control.setting('host50001'),
                control.setting('host50002'),
                control.setting('host50003'),
                control.setting('host50004'),
                control.setting('host50005'),
                control.setting('host50006'),
                control.setting('host50007'),
                control.setting('host50008'),
                control.setting('host50009'),
                control.setting('host50010'),
                control.setting('host50011'),
                control.setting('host50012'),
                control.setting('host50013'),
                control.setting('host50014'),
                control.setting('host50015'),
                control.setting('host50016'),
                control.setting('host50017'),
                control.setting('host50018'),
                control.setting('host50019'),
                control.setting('host50020')
            ]
        except:
            customsdDict = []

        hd_rank = []
        hd_rank += [
            i for i in self.rdDict if i in self.hostprDict + self.hosthdDict
        ]
        hd_rank += [
            i for i in self.pzDict if i in self.hostprDict + self.hosthdDict
        ]
        hd_rank += customhdDict
        hd_rank += [
            i['source'] for i in self.sources
            if i['quality'] in ['1080p', 'HD'] and
            not i['source'] in customhdDict + self.hostprDict + self.hosthdDict
        ]
        hd_rank += self.hosthdDict
        hd_rank = [i.lower() for i in hd_rank]
        hd_rank = [x for y, x in enumerate(hd_rank) if x not in hd_rank[:y]]

        sd_rank = []
        sd_rank += [
            i for i in self.rdDict if i in self.hostprDict + self.hosthqDict
        ]
        sd_rank += [
            i for i in self.pzDict if i in self.hostprDict + self.hosthqDict
        ]
        sd_rank += customsdDict
        sd_rank += [
            i['source'] for i in self.sources
            if i['quality'] == 'SD' and not i['source'] in customsdDict +
            self.hostprDict + self.hosthqDict + self.hostmqDict +
            self.hostlqDict
        ]
        sd_rank += self.hosthqDict + self.hostmqDict + self.hostlqDict
        sd_rank = [i.lower() for i in sd_rank]
        sd_rank = [x for y, x in enumerate(sd_rank) if x not in sd_rank[:y]]

        for i in range(len(self.sources)):
            self.sources[i]['source'] = self.sources[i]['source'].lower()
        self.sources = sorted(self.sources, key=lambda k: k['source'])

        filter = []
        for host in hd_rank:
            filter += [
                i for i in self.sources
                if i['quality'] == '1080p' and i['source'] == host
            ]
        for host in hd_rank:
            filter += [
                i for i in self.sources
                if i['quality'] == 'HD' and i['source'] == host
            ]
        for host in sd_rank:
            filter += [
                i for i in self.sources
                if i['quality'] == 'SD' and i['source'] == host
            ]
        if len(filter) < 10:
            filter += [i for i in self.sources if i['quality'] == 'SCR']
        if len(filter) < 10:
            filter += [i for i in self.sources if i['quality'] == 'CAM']
        self.sources = filter

        try:
            playback_quality = control.setting('playback_quality')
        except:
            playback_quality = '0'

        if playback_quality == '1':
            self.sources = [
                i for i in self.sources if not i['quality'] == '1080p'
            ]
        elif playback_quality == '2':
            self.sources = [
                i for i in self.sources if not i['quality'] in ['1080p', 'HD']
            ]
        elif playback_quality == '3':
            self.sources = [
                i for i in self.sources if not i['quality'] in ['1080p', 'HD']
                and i['source'] in self.hostmqDict + self.hostlqDict
            ]
        elif playback_quality == '4':
            self.sources = [
                i for i in self.sources if not i['quality'] in ['1080p', 'HD']
                and i['source'] in self.hostlqDict
            ]

        try:
            playback_captcha = control.setting('playback_captcha_hosts')
        except:
            playback_captcha = 'false'

        try:
            playback_1080p = control.setting('playback_1080p_hosts')
        except:
            playback_1080p = 'true'

        try:
            playback_720p = control.setting('playback_720p_hosts')
        except:
            playback_720p = 'true'

        if playback_captcha == 'false':
            self.sources = [
                i for i in self.sources if not i['source'] in self.hostcapDict
            ]

        if playback_1080p == 'false':
            self.sources = [
                i for i in self.sources if not (
                    i['quality'] == '1080p' and i['source'] in self.hosthdDict
                    and not i['source'] in self.rdDict + self.pzDict)
            ]

        if playback_720p == 'false':
            self.sources = [
                i for i in self.sources
                if not (i['quality'] == 'HD' and i['source'] in self.hosthdDict
                        and not i['source'] in self.rdDict + self.pzDict)
            ]

        for i in range(len(self.sources)):
            #control.log("------------------------------ %s  | %s " % (self.sources[i]['source'], self.sources[i]))
            s = self.sources[i]['source'].lower()
            p = self.sources[i]['provider']
            p = re.sub('v\d*$', '', p)

            q = self.sources[i]['quality']
            if q == 'SD' and s in self.hostmqDict: q = 'MQ'
            elif q == 'SD' and s in self.hostlqDict: q = 'LQ'
            elif q == 'SD': q = 'HQ'

            try:
                d = self.sources[i]['info']
            except:
                d = ''
            if not d == '': d = ' | [I]%s [/I]' % d

            if s in self.rdDict:
                label = '%02d | [B]realdebrid[/B] | ' % int(i + 1)
            elif s in self.pzDict:
                label = '%02d | [B]premiumize[/B] | ' % int(i + 1)
            else:
                label = '%02d | [B]%s[/B] | ' % (int(i + 1), p)

            if q in ['1080p', 'HD']:
                label += '%s%s | [B][I]%s [/I][/B]' % (s, d, q)
            else:
                label += '%s%s | [I]%s [/I]' % (s, d, q)

            self.sources[i]['label'] = label.upper()

        return self.sources
Ejemplo n.º 31
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
Ejemplo n.º 32
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
Ejemplo n.º 33
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
Ejemplo n.º 34
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
Ejemplo n.º 35
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
Ejemplo n.º 36
0
def getPierwszaCredentialsInfo():
    user = control.setting('pierwszatv.user').strip()
    password = control.setting('pierwszatv.password')
    if (user == '' or password == ''): return False
    return True
Ejemplo n.º 37
0
def getWizjaCredentialsInfo():
    user = control.setting('wizja.user').strip()
    password = control.setting('wizja.pass')
    if (user == '' or password == ''): return False
    return True
Ejemplo n.º 38
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
Ejemplo n.º 39
0
def getYoyCredentialsInfo():
    user = control.setting('yoytv.user').strip()
    password = control.setting('yoytv.pass')
    if (user == '' or password == ''): return False
    return True
Ejemplo n.º 40
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
Ejemplo n.º 41
0
 def __init__(self):
     movie_library = os.path.join(control.transPath(control.setting('movie_library')),'')
     tv_library = os.path.join(control.transPath(control.setting('tv_library')),'')
     tv_downloads = os.path.join(control.transPath(control.setting('tv_downloads')),'')
Ejemplo n.º 42
0
    def checkSources(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:
                control.log("SOURCE S2 %s" % source)
                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]

        for i in range(0, timeout * 2):
            try:
                if xbmc.abortRequested == True: return sys.exit()
                if len(self.sources) >= 10: 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

        if len(self.sources) >= 10: return True
        else: return False
Ejemplo n.º 43
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 )
Ejemplo n.º 44
0
    def sourcesFilter(self):
        self.sourcesReset()
        try: customhdDict = [control.setting('hosthd50001'), control.setting('hosthd50002'), control.setting('hosthd50003'), control.setting('hosthd50004'), control.setting('hosthd50005'), control.setting('hosthd50006'), control.setting('hosthd50007'), control.setting('hosthd50008'), control.setting('hosthd50009'), control.setting('hosthd50010'), control.setting('hosthd50011'), control.setting('hosthd50012'), control.setting('hosthd50013'), control.setting('hosthd50014'), control.setting('hosthd50015'), control.setting('hosthd50016'), control.setting('hosthd50017'), control.setting('hosthd50018'), control.setting('hosthd50019'), control.setting('hosthd50020')]
        except: customhdDict = []
        try: customsdDict = [control.setting('host50001'), control.setting('host50002'), control.setting('host50003'), control.setting('host50004'), control.setting('host50005'), control.setting('host50006'), control.setting('host50007'), control.setting('host50008'), control.setting('host50009'), control.setting('host50010'), control.setting('host50011'), control.setting('host50012'), control.setting('host50013'), control.setting('host50014'), control.setting('host50015'), control.setting('host50016'), control.setting('host50017'), control.setting('host50018'), control.setting('host50019'), control.setting('host50020')]
        except: customsdDict = []

        hd_rank = []
        hd_rank += [i for i in self.rdDict if i in self.hostprDict + self.hosthdDict]
        hd_rank += [i for i in self.pzDict if i in self.hostprDict + self.hosthdDict]
        hd_rank += customhdDict
        hd_rank += [i['source'] for i in self.sources if i['quality'] in ['1080p', 'HD'] and not i['source'] in customhdDict + self.hostprDict + self.hosthdDict]
        hd_rank += self.hosthdDict
        hd_rank = [i.lower() for i in hd_rank]
        hd_rank = [x for y,x in enumerate(hd_rank) if x not in hd_rank[:y]]

        sd_rank = []
        sd_rank += [i for i in self.rdDict if i in self.hostprDict + self.hosthqDict]
        sd_rank += [i for i in self.pzDict if i in self.hostprDict + self.hosthqDict]
        sd_rank += customsdDict
        sd_rank += [i['source'] for i in self.sources if i['quality'] == 'SD' and not i['source'] in customsdDict + self.hostprDict + self.hosthqDict + self.hostmqDict + self.hostlqDict]
        sd_rank += self.hosthqDict + self.hostmqDict + self.hostlqDict
        sd_rank = [i.lower() for i in sd_rank]
        sd_rank = [x for y,x in enumerate(sd_rank) if x not in sd_rank[:y]]

        for i in range(len(self.sources)): self.sources[i]['source'] = self.sources[i]['source'].lower()
        self.sources = sorted(self.sources, key=lambda k: k['source'])

        filter = []
        for host in hd_rank: filter += [i for i in self.sources if i['quality'] == '1080p' and i['source'] == host]
        for host in hd_rank: filter += [i for i in self.sources if i['quality'] == 'HD' and i['source'] == host]
        for host in sd_rank: filter += [i for i in self.sources if i['quality'] == 'SD' and i['source'] == host]
        if len(filter) < 10: filter += [i for i in self.sources if i['quality'] == 'SCR']
        if len(filter) < 10: filter += [i for i in self.sources if i['quality'] == 'CAM']
        self.sources = filter

        try: playback_quality = control.setting('playback_quality')
        except: playback_quality = '0'

        if playback_quality == '1':
            self.sources = [i for i in self.sources if not i['quality'] == '1080p']
        elif playback_quality == '2':
            self.sources = [i for i in self.sources if not i['quality'] in ['1080p', 'HD']]
        elif playback_quality == '3':
            self.sources = [i for i in self.sources if not i['quality'] in ['1080p', 'HD'] and i['source'] in self.hostmqDict + self.hostlqDict]
        elif playback_quality == '4':
            self.sources = [i for i in self.sources if not i['quality'] in ['1080p', 'HD'] and i['source'] in self.hostlqDict]

        try: playback_captcha = control.setting('playback_captcha_hosts')
        except: playback_captcha = 'false'

        try: playback_1080p = control.setting('playback_1080p_hosts')
        except: playback_1080p = 'true'

        try: playback_720p = control.setting('playback_720p_hosts')
        except: playback_720p = 'true'

        if playback_captcha == 'false':
            self.sources = [i for i in self.sources if not i['source'] in self.hostcapDict]

        if playback_1080p == 'false':
            self.sources = [i for i in self.sources if not (i['quality'] == '1080p' and i['source'] in self.hosthdDict and not i['source'] in self.rdDict + self.pzDict)]

        if playback_720p == 'false':
            self.sources = [i for i in self.sources if not (i['quality'] == 'HD' and i['source'] in self.hosthdDict and not i['source'] in self.rdDict + self.pzDict)]

        for i in range(len(self.sources)):
            #control.log("------------------------------ %s  | %s " % (self.sources[i]['source'], self.sources[i]))
            s = self.sources[i]['source'].lower()
            p = self.sources[i]['provider']
            p = re.sub('v\d*$', '', p)

            q = self.sources[i]['quality']
            if q == 'SD' and s in self.hostmqDict: q = 'MQ'
            elif q == 'SD' and s in self.hostlqDict: q = 'LQ'
            elif q == 'SD': q = 'HQ'

            try: d = self.sources[i]['info']
            except: d = ''
            if not d == '': d = ' | [I]%s [/I]' % d

            if s in self.rdDict: label = '%02d | [B]realdebrid[/B] | ' % int(i+1)
            elif s in self.pzDict: label = '%02d | [B]premiumize[/B] | ' % int(i+1)
            else: label = '%02d | [B]%s[/B] | ' % (int(i+1), p)

            if q in ['1080p', 'HD']: label += '%s%s | [B][I]%s [/I][/B]' % (s, d, q)
            else: label += '%s%s | [I]%s [/I]' % (s, d, q)

            self.sources[i]['label'] = label.upper()

        return self.sources
Ejemplo n.º 45
0
def getItiviCredentialsInfo():
    user = control.setting('itivi.user').strip()
    password = control.setting('itivi.pass')
    if (user == '' or password == ''): return False
    return True
Ejemplo n.º 46
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
Ejemplo n.º 47
0
def getItiviCredentialsInfo():
    user = control.setting('itivi.user').strip()
    password = control.setting('itivi.pass')
    if (user == '' or password == ''): return False
    return True
Ejemplo n.º 48
0
def getPierwszaCredentialsInfo():
    user = control.setting('pierwszatv.user').strip()
    password = control.setting('pierwszatv.password')
    if (user == '' or password == ''): return False
    return True
Ejemplo n.º 49
0
def getLooknijCredentialsInfo():
    user = control.setting('looknij.user').strip()
    password = control.setting('looknij.pass')
    if (user == '' or password == ''): return False
    return True
Ejemplo n.º 50
0
    def movieDirectory(self, items):
        if items == None or len(items) == 0: return

        isFolder = True if control.setting('autoplay') == 'false' and control.setting('host_select') == '1' else False
        isFolder = False if control.window.getProperty('PseudoTVRunning') == 'True' else isFolder

        playbackMenu = control.lang(30204).encode('utf-8') if control.setting('autoplay') == 'true' else control.lang(30203).encode('utf-8')

        cacheToDisc = False if not action == 'movieSearch' else True

        addonPoster, addonBanner = control.addonPoster(), control.addonBanner()
        addonFanart, settingFanart = control.addonFanart(), control.setting('fanart')
        sysaddon = sys.argv[0]

        #try:
        #    favitems = favourites.getFavourites('movies')
        #    favitems = [i[0] for i in favitems]
        #except:
        #    pass

        for i in items:
            try:
                label = i['name']

                sysname = urllib.quote_plus(label)
                systitle = urllib.quote_plus(i['title'])
                #imdb, tmdb, year = i['imdb'], i['tmdb'], i['year']
                service = i['service']

                poster, fanart = i['poster'], i['fanart']
                if poster == '0': poster = addonPoster

                meta = dict((k,v) for k, v in i.iteritems() if not v == '0')
                sysmeta = urllib.quote_plus(json.dumps(meta))

                url = '%s?action=play&name=%s&title=%s&service=%s&meta=%s&t=%s' % (sysaddon, sysname, systitle, service, sysmeta, self.systime)
                sysurl = urllib.quote_plus(url)

                #if isFolder == True:
                #    url = '%s?action=sources&name=%s&title=%s&meta=%s' % (sysaddon, sysname, systitle,sysmeta)

                #cm = []

                #cm.append((playbackMenu, 'RunPlugin(%s?action=alterSources&url=%s)' % (sysaddon, sysurl)))

                #cm.append((control.lang(30205).encode('utf-8'), 'Action(Info)'))

                """if not action == 'movieSearch':
                    cm.append((control.lang(30206).encode('utf-8'), 'RunPlugin(%s?action=moviePlaycount&title=%s&year=%s&imdb=%s&query=7)' % (sysaddon, systitle, year, imdb)))
                    cm.append((control.lang(30207).encode('utf-8'), 'RunPlugin(%s?action=moviePlaycount&title=%s&year=%s&imdb=%s&query=6)' % (sysaddon, systitle, year, imdb)))
                """
                #if action == 'tvFavourites':
                #    cm.append((control.lang(30210).encode('utf-8'), 'RunPlugin(%s?action=deleteFavourite&meta=%s&content=movies)' % (sysaddon, sysmeta)))
                #else:
                #    cm.append((control.lang(30209).encode('utf-8'), 'RunPlugin(%s?action=addFavourite&meta=%s&query=0&content=movies)' % (sysaddon, sysmeta)))
                """
                else:
                    a=1
                    #if not imdb in favitems: cm.append((control.lang(30209).encode('utf-8'), 'RunPlugin(%s?action=addFavourite&meta=%s&content=movies)' % (sysaddon, sysmeta)))
                    #else: cm.append((control.lang(30210).encode('utf-8'), 'RunPlugin(%s?action=deleteFavourite&meta=%s&content=movies)' % (sysaddon, sysmeta)))
                """
                #cm.append((control.lang(30211).encode('utf-8'), 'RunPlugin(%s?action=movieToLibrary&name=%s&title=%s&year=%s&imdb=%s&tmdb=%s)' % (sysaddon, sysname, systitle,  service, sysmeta, self.systime)))

                #cm.append((control.lang(30212).encode('utf-8'), 'RunPlugin(%s?action=addView&content=movies)' % sysaddon))

                item = control.item(label=label, iconImage=poster, thumbnailImage=poster)
                try: item.setArt({'poster': poster})
                except: pass

                if settingFanart == 'true' and not fanart == '0':

                    item.setProperty('Fanart_Image', fanart)
                elif not addonFanart == None:
                    item.setProperty('Fanart_Image', addonFanart)

                #item.setInfo(type='Video', infoLabels = meta)
                item.setProperty('Video', 'true')
                #item.setProperty('IsPlayable', 'true')
                #item.addContextMenuItems(cm, replaceItems=True)
                control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=isFolder)

            except:
                pass

        try:
            url = items[0]['next']
            if url == '': raise Exception()
            url = '%s?action=movies&url=%s' % (sysaddon, urllib.quote_plus(url))
            addonNext = control.addonNext()
            item = control.item(label=control.lang(30213).encode('utf-8'), iconImage=addonNext, thumbnailImage=addonNext)
            item.addContextMenuItems([], replaceItems=False)
            if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart)
            control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True)
        except:
            pass


        control.content(int(sys.argv[1]), 'movies')
        control.directory(int(sys.argv[1]), cacheToDisc=cacheToDisc)
        views.setView('movies', {'skin.confluence': 500})
Ejemplo n.º 51
0
def getLooknijCredentialsInfo():
    user = control.setting('looknij.user').strip()
    password = control.setting('looknij.pass')
    if (user == '' or password == ''): return False
    return True
Ejemplo n.º 52
0
def getWizjaCredentialsInfo():
    user = control.setting('wizja.user').strip()
    password = control.setting('wizja.pass')
    if (user == '' or password == ''): return False
    return True
Ejemplo n.º 53
0
def getYoyCredentialsInfo():
    user = control.setting('yoytv.user').strip()
    password = control.setting('yoytv.pass')
    if (user == '' or password == ''): return False
    return True
Ejemplo n.º 54
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('2.1')

            raise Exception()
        url = '/api/stream/create'
        params = {}
        params['id'] =id
        params['user'] =control.setting('pierwszatv.user').strip()
        params['password'] = urllib.quote_plus(control.setting('pierwszatv.password'))

        result = get(url, params)
        result = json.loads(result)

        if result['status'] == 'ok':
            #time.sleep(1)
            #control.log('x1x1x1: %s' % result['status'])
            expirein = int(int(result['tokenExpireIn'])*0.75)
            expirewhen  = datetime.datetime.now() + datetime.timedelta(seconds=expirein)
            control.set_setting('pierwszatv.tokenExpireIn', str(int(time.mktime(expirewhen.timetuple()))))
            control.set_setting('pierwszatv.serverId', result['serverId'])
            control.set_setting('pierwszatv.streamId', result['streamId'])
            control.set_setting('pierwszatv.token', result['token'])

            for i in range(0, 5):
                try:
                    r = get('/api/stream/status', {'serverId': result['serverId'] , 'streamId': result['streamId'], 'token': result['token']})
                    r = json.loads(r)
                    if r['status'] == 'ok':
                        #control.infoDialog(control.lang(30489).encode('utf-8'), time=6000)
                        for j in range(0, 20):
                            time.sleep(1)
                            control.infoDialog(control.lang(30489).encode('utf-8'), time=500)
                            try:
                                result2 = client.request(r['source']+'?token='+result['token'],safe=True, timeout='2')
                                control.log('Pierwsza link check nr: %s: result:%s' % (j,result2))


                                if result2 == None: raise Exception()
                                else: return r['source']+'?token='+result['token']
                            except:
                                pass

                        return r['source']+'?token='+result['token']
                    time.sleep(3)

                except:
                    pass
        if result['status'] == 'error':
            control.infoDialog('%s' % result['message'].encode('utf-8'))

        return None

    except Exception as e:
        control.log('Error pierwsza.getstream %s' % e )
Ejemplo n.º 55
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