示例#1
0
    def getLinksForVideo(self, cItem):
        printDBG("WrestlingNet.getLinksForVideo [%s]" % cItem)
        urlTab = []
        sts, data = self.cm.getPage(cItem['url'])
        if not sts: return urlTab

        sts, data = self.cm.ph.getDataBeetwenMarkers(data, 'entry-content',
                                                     'video-meta-info',
                                                     True)  #'id="more-'
        if not sts:
            SetIPTVPlayerLastHostError(
                _("Please visit '%s' from using web-browser form the PC. If links are available please report this problem.\nEmail: [email protected]"
                  ) % cItem['url'])
            return urlTab

        data = data.split('<h2>')
        if len(data): del data[0]
        re_links = re.compile('<a[^>]+?href="([^"]+?)"[^>]*?>([^<]+?)</a>')
        for item in data:
            type = self.cleanHtmlStr(item.split('</h2>')[0])

            links = re_links.findall(item)
            for link in links:
                urlTab.append({'name': type + ' ' + link[1], 'url': link[0]})

        return urlTab
示例#2
0
 def getPage(self, baseUrl, addParams={}, post_data=None):
     if addParams == {}: addParams = dict(self.defaultParams)
     
     proxy = config.plugins.iptvplayer.hdsto_proxy.value
     if proxy == 'webproxy':
         addParams = dict(addParams)
         proxy = 'http://n-guyot.fr/exit/browse.php?u={0}&b=4'.format(urllib.quote(baseUrl, ''))
         addParams['header']['Referer'] = proxy + '&f=norefer'
         baseUrl = proxy
     elif proxy != 'None':
         if proxy == 'proxy_1':
             proxy = config.plugins.iptvplayer.alternative_proxy1.value
         else:
             proxy = config.plugins.iptvplayer.alternative_proxy2.value
         addParams = dict(addParams)
         addParams.update({'http_proxy':proxy})
     tries = 0
     while tries < 2:
         tries += 1
         sts, data = self.cm.getPage(baseUrl, addParams, post_data)
         if sts:
             if self.getFullUrl(self.cm.meta['url']).endswith('/home.php'):
                 SetIPTVPlayerLastHostError('\n'.join(self.membersOnly))
             elif config.plugins.iptvplayer.hdsto_proxy.value == 'webproxy' and 'sslagree' in data:
                 sts, data = self.cm.getPage('http://n-guyot.fr/exit/includes/process.php?action=sslagree', addParams, post_data)
                 continue
         break
     return sts, data
示例#3
0
	def getVideos(self,videoUrl):
		urlTab = []	
		Url = self.MAIN_URL+'/'+videoUrl		
		sts, data = self.getPage(Url)
		if sts:
			printDBG('dddddaaaaattttaaaaa'+data)
			_data2 = re.findall('<iframe.*?src=["\'](.*?)["\']',data, re.S|re.IGNORECASE)
			if _data2:
				printDBG('01')
				URL_=_data2[0]
				if URL_.startswith('//'):
					URL_='http:'+URL_
				urlTab.append((URL_,'1'))
			else:
				printDBG('02')
				_data2 = re.findall('<body>.*?src=["\'](.*?)["\']',data, re.S|re.IGNORECASE)
				if _data2:
					printDBG('03')
					URL_=_data2[0]
					if URL_.startswith('//'):
						URL_='http:'+URL_
					urlTab.append((URL_,'1'))
				else:
					printDBG('04')
					if 'https://asiatv.cc/userpro/' in data:
						SetIPTVPlayerLastHostError('Only premium users!!')
				
		return urlTab
示例#4
0
    def unpackZipArchive(self, tmpFile, tmpDIR):
        errorCode = 0
        # check if archive is not evil
        cmd = "unzip -l '{0}' 2>&1 ".format(tmpFile)
        ret = self.iptv_execute(cmd)
        if not ret['sts'] or 0 != ret['code']:
            errorCode = ret['code']
            if errorCode == 0:
                errorCode = 9
        elif '..' in ret['data']:
            errorCode = 9

        # if archive is valid then upack it
        if errorCode == 0:
            cmd = "unzip -o '{0}' -d '{1}' 2>/dev/null".format(tmpFile, tmpDIR)
            ret = self.iptv_execute(cmd)
            if not ret['sts'] or 0 != ret['code']:
                errorCode = ret['code']
                if errorCode == 0:
                    errorCode = 9

        if errorCode != 0:
            message = _('Unzip error code[%s].') % errorCode
            if str(errorCode) == str(127):
                message += '\n' + _(
                    'It seems that unzip utility is not installed.')
            elif str(errorCode) == str(9):
                message += '\n' + _('Wrong format of zip archive.')
            SetIPTVPlayerLastHostError(message)
            return False

        return True
示例#5
0
    def listSearchResult(self, cItem, searchPattern, searchType):
        printDBG(
            "FuufPL.listSearchResult cItem[%s], searchPattern[%s] searchType[%s]"
            % (cItem, searchPattern, searchType))

        post_data = {'q': searchPattern}
        sts, data = self.cm.getPage(FuufPL.SRCH_URL, {}, post_data)
        if not sts: return

        try:
            data = byteify(json.loads(data))
            for item in data:
                url = item['url']
                title = self.cleanHtmlStr(item['name'])
                icon = self.cm.ph.getSearchGroups(item['name'],
                                                  'src="([^"]+?)"')[0]

                if '' != url and '' != title:
                    params = dict(cItem)
                    params.update({
                        'title': title,
                        'url': self._getFullUrl(url),
                        'icon': self._getFullUrl(icon)
                    })
                    self.addVideo(params)
        except:
            printExc()
            SetIPTVPlayerLastHostError(_("Parsing search result failed."))
示例#6
0
    def listItems(self, cItem, nextCategory):
        printDBG("MaxtvGO.listItems [%s]" % cItem)

        sts, data = self.getPage(cItem['url'])
        if not sts: return

        article = self.getArticleContent(cItem, data)
        if len(article):
            title = article[0]['title']
            icon = article[0]['images'][0]['url']
            params = dict(cItem)
            params.update({'good_for_fav': True, 'title': title, 'icon': icon})
            self.addVideo(params)

        cookieHeader = self.cm.getCookieHeader(self.COOKIE_FILE)
        catsTitle = ''
        data = self.cm.ph.getDataBeetwenNodes(data,
                                              ('<div', '>', 'slajder_film'),
                                              ('<div', '>', 'chat_round'))[1]
        data = re.compile('(<h3[^>]*?>[^>]*?</[^>]*?>)').split(data)
        for catData in data:
            if catData.startswith('<h3'):
                catsTitle = self.cleanHtmlStr(catData)
            tmp = self.cm.ph.getAllItemsBeetwenMarkers(catData, '<a', '</a>')
            for item in tmp:
                url = self.getFullUrl(
                    self.cm.ph.getSearchGroups(
                        item, '''href=['"]([^'^"]+?)['"]''')[0])
                icon = self.getFullIconUrl(
                    self.cm.ph.getSearchGroups(
                        item, '''src=['"]([^'^"]+?)['"]''')[0])
                icon = strwithmeta(
                    icon, {
                        'Cookie': cookieHeader,
                        'User-Agent': self.USER_AGENT,
                        'Referer': cItem['url']
                    })
                title = self.cleanHtmlStr(
                    self.cm.ph.getSearchGroups(
                        item, '''alt=['"]([^'^"]+?)['"]''')[0])
                if title == '':
                    title = catsTitle + ' ' + self.cleanHtmlStr(
                        icon.split('/')[-1].split('.', 1)[0].replace(
                            'small', ''))
                # 'category':nextCategory,
                params = dict(cItem)
                params.update({
                    'good_for_fav': True,
                    'title': title,
                    'url': url,
                    'icon': icon
                })
                self.addVideo(params)

        if self.loggedIn != True and 0 == len(self.currList):
            msg = _(
                'The host %s requires registration. \nPlease fill your login and password in the host configuration. Available under blue button.'
                % self.getMainUrl())
            GetIPTVNotify().push(msg, 'error', 10)
            SetIPTVPlayerLastHostError(msg)
示例#7
0
    def getVideoLinks(self, videoUrl):
        printDBG("CineTO.getVideoLinks [%s]" % videoUrl)
        videoUrl = strwithmeta(videoUrl)
        urlTab = []

        # mark requested link as used one
        if len(self.cacheLinks.keys()):
            for key in self.cacheLinks:
                for idx in range(len(self.cacheLinks[key])):
                    if videoUrl in self.cacheLinks[key][idx]['url']:
                        if not self.cacheLinks[key][idx]['name'].startswith(
                                '*'):
                            self.cacheLinks[key][idx][
                                'name'] = '*' + self.cacheLinks[key][idx][
                                    'name']
                        break

        sts, data = self.getPage(videoUrl)
        if sts:
            videoUrl = data.meta['url']
            urlTab = self.up.getVideoLinkExt(videoUrl)
            if 0 == len(urlTab) and 'gcaptchaSetup' in data:
                SetIPTVPlayerLastHostError(
                    _('Link protected with google recaptcha v2.'))
        else:
            urlTab = self.up.getVideoLinkExt(videoUrl)

        return urlTab
示例#8
0
    def getVideoLinks(self, videoUrl):
        printDBG("GamatoMovies.getVideoLinks [%s]" % videoUrl)
        urlTab = []

        # mark requested link as used one
        if len(self.cacheLinks.keys()):
            key = self.cacheLinks.keys()[0]
            for idx in range(len(self.cacheLinks[key])):
                if videoUrl in self.cacheLinks[key][idx]['url']:
                    if not self.cacheLinks[key][idx]['name'].startswith('*'):
                        self.cacheLinks[key][idx][
                            'name'] = '*' + self.cacheLinks[key][idx]['name']
                    break

        shortUri = videoUrl
        domain = self.up.getDomain(videoUrl)
        if 'sh.st' in domain or 'viid.me' in domain:
            from Plugins.Extensions.IPTVPlayer.libs.unshortenit import unshorten
            uri, sts = unshorten(videoUrl)
            videoUrl = str(uri)
            if not self.cm.isValidUrl(videoUrl):
                SetIPTVPlayerLastHostError(str(sts))
            else:
                # set resolved uri in cache
                if len(self.cacheLinks.keys()):
                    key = self.cacheLinks.keys()[0]
                    for idx in range(len(self.cacheLinks[key])):
                        if shortUri in self.cacheLinks[key][idx]['url']:
                            self.cacheLinks[key][idx]['url'] = videoUrl
                            break
        if self.cm.isValidUrl(videoUrl):
            return self.up.getVideoLinkExt(videoUrl)

        return urlTab
示例#9
0
    def _getLanguages(self):
        lang = GetDefaultLang()
        subParams = [{'name': 'sublanguageid', 'value': lang}]
        params = [self.loginToken, self._getArraryParam(subParams)]

        sts, data = self._rpcMethodCall("GetSubLanguages", params)
        printDBG(">>>>>>>>>>>>>>>>>>>>>>>>>>>>> data[%s]" % data)
        if sts:
            try:
                list = []
                defaultLanguageItem = None
                for item in data:
                    if 'LanguageName' in item and 'SubLanguageID' in item and 'ISO639' in item:
                        params = {
                            'title':
                            '{0} [{1}]'.format(item['LanguageName'],
                                               item['SubLanguageID']),
                            'lang':
                            item['SubLanguageID']
                        }
                        if lang != item['ISO639']:
                            list.append(params)
                        else:
                            defaultLanguageItem = params
                if None != defaultLanguageItem:
                    list.insert(0, defaultLanguageItem)
                return list
            except Exception:
                printExc()
        SetIPTVPlayerLastHostError(_('Get languages failed!'))
        return []
示例#10
0
    def downloadAndUnpack(self, url, params={}, post_data=None, unpackToSubDir=False):
        data, fileName = self.downloadFileData(url, params, post_data)
        if data == None:
            return None
        ext = fileName.rsplit('.', 1)[-1].lower()
        printDBG("fileName[%s] ext[%s]" % (fileName, ext))
        if ext not in ['zip', 'rar']:
            SetIPTVPlayerLastHostError(_('Unknown file extension "%s".') % ext)
            return None
            
        tmpFile = GetTmpDir( self.TMP_FILE_NAME )
        tmpArchFile = tmpFile + '.' + ext
        tmpDIR = ''
        if unpackToSubDir:
            dirName = fileName.rsplit('.', 1)[0].split('filename=', 1)[-1]
            if dirName != '':
                tmpDIR = GetSubtitlesDir(dirName)
        
        if tmpDIR == '':
            tmpDIR = GetTmpDir(self.TMP_DIR_NAME)
        
        printDBG(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
        printDBG(fileName)
        printDBG(tmpFile)
        printDBG(tmpArchFile)
        printDBG(tmpDIR)
        printDBG(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")

        if not self.writeFile(tmpArchFile, data):
            return None
        
        if not self.unpackArchive(tmpArchFile, tmpDIR):
            rm(tmpArchFile)
            return None
        return tmpDIR
示例#11
0
    def downloadAndUnpack(self, url, params={}, post_data=None):
        data, fileName = self.downloadFileData(url, params, post_data)
        if data == None:
            return None
        ext = fileName.split('.')[-1].lower()
        if ext not in ['zip', 'rar']:
            SetIPTVPlayerLastHostError(_('Unknown file extension "%s".') % ext)
            return None

        tmpFile = GetTmpDir(self.TMP_FILE_NAME)
        tmpArchFile = tmpFile + '.' + ext
        tmpDIR = GetTmpDir(self.TMP_DIR_NAME)
        printDBG(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
        printDBG(fileName)
        printDBG(tmpFile)
        printDBG(tmpArchFile)
        printDBG(tmpDIR)
        printDBG(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")

        if not self.writeFile(tmpArchFile, data):
            return None

        if not self.unpackArchive(tmpArchFile, tmpDIR):
            rm(tmpArchFile)
            return None
        return tmpDIR
示例#12
0
    def getLinksForVideo(self, cItem, source_id=None):
        linksTab = []

        if 'item_data' not in cItem:
            sts, data = self.getPage(cItem['url'])
            if not sts: return
            client_location = self.cm.meta['url']
            data = ph.find(data, 'var contentResources = [', '];', flags=0)[1]
            try:
                data = json_loads('[%s]' % data)[0]
            except Exception:
                pass
        else:
            client_location = cItem['url']
            data = cItem['item_data']

        try:
            drm = data.get('drm')
            if drm:
                SetIPTVPlayerLastHostError(_('Link protected with DRM.'))
            video_id = data['id']
        except Exception:
            printExc()
            return []

        #dashLinks = self.doGetLinks(video_id, client_location, 'application/dash+xml')
        try:
            for it in (False, True):
                hlsLinks = self.doGetLinks(video_id, client_location,
                                           'application/x-mpegURL', it)
                if hlsLinks:
                    linksTab.extend(
                        getDirectM3U8Playlist(hlsLinks[0]['url'],
                                              checkExt=True,
                                              checkContent=True,
                                              sortWithMaxBitrate=999999999))
                    break

            for it in (True, False):
                mp4Links = self.doGetLinks(video_id, client_location,
                                           'video/mp4', it)
                for item in mp4Links:
                    if item['mimetype'] == 'video/mp4':
                        linksTab.append({
                            'name':
                            '[MP4] bitrate: %s' % item['bitrate'],
                            'url':
                            item['url'],
                            'bitrate':
                            item['bitrate']
                        })
                if mp4Links:
                    break
            if not mp4Links and drm:
                return []
            linksTab.sort(reverse=True, key=lambda k: int(k['bitrate']))
        except Exception:
            printExc()

        return linksTab
示例#13
0
    def getSubtitles(self, cItem):
        printDBG("YoutubeComProvider.getSubtitles")
        if not self.cm.isValidUrl(self.popcornsubtitlesUrl):
            SetIPTVPlayerLastHostError(_('Wrong uri.'))
            return

        url = self.popcornsubtitlesUrl
        urlParams = dict(self.defaultParams)

        sts, tmp = self.cm.getPage(url, urlParams)
        if not sts: return

        imdbid = self.cm.ph.getSearchGroups(tmp, '/(tt[0-9]+?)[^0-9]')[0]
        tmp = self.cm.ph.getDataBeetwenMarkers(tmp, '<tbody>', '</tbody>')[1]
        tmp = self.cm.ph.getAllItemsBeetwenMarkers(tmp,
                                                   '<tr',
                                                   '</tr>',
                                                   withMarkers=True)
        for item in tmp:
            url = self.getFullUrl(
                self.cm.ph.getSearchGroups(item,
                                           '''href=['"]([^'^"]+?)['"]''')[0])
            title = self.cleanHtmlStr(item)
            lang = self.cleanHtmlStr(
                self.cm.ph.getDataBeetwenMarkers(item, '<td', '</td>')[1])
            if self.cm.isValidUrl(url):
                params = dict(cItem)
                params.update({
                    'title': lang,
                    'url': url,
                    'lang': lang,
                    'imdbid': imdbid,
                    'desc': title
                })
                self.addSubtitle(params)
示例#14
0
 def listItems(self, cItem, nextCategory):
     printDBG("MaxtvGO.listItems [%s]" % cItem)
     
     sts, data = self.getPage(cItem['url'])
     if not sts: return
     
     try:
         data = byteify(json.loads(data))
         if data.get('error') != None:
             SetIPTVPlayerLastHostError(str(data['error']['message']))
         for item in data['data']:
             sTitle = self.cleanHtmlStr(item['name'])
             subItems = []
             for it in item['videos']:
                 title = self.cleanHtmlStr(it['title'])
                 #icon = self.getFullIconUrl(it['image'])
                 icon = str(it.get('vimeoPosterId', ''))
                 if icon != '': icon = 'http://i.vimeocdn.com/video/%s.jpg?mw=300' % icon
                 url = self.getFullUrl('video.php?film=') + it['code']
                 params = dict(cItem)
                 params.update({'type':'video', 'good_for_fav':True, 'title':title, 'url':url, 'icon':icon})
                 subItems.append(params)
             
             if len(subItems):
                 params = dict(cItem)
                 params.update({'category':nextCategory, 'good_for_fav':False, 'title':sTitle, 'sub_items':subItems})
                 self.addDir(params)
         
     except Exception:
         printExc()
     
         if self.loggedIn != True and 0 == len(self.currList):
             msg = _('The host %s requires registration. \nPlease fill your login and password in the host configuration. Available under blue button.' % self.getMainUrl())
             GetIPTVNotify().push(msg, 'error', 10)
示例#15
0
 def _doLogin(self, login, password):
     lang = GetDefaultLang()
     params = [login, hex_md5(password), lang, self.USER_AGENT]
     sts, data = self._rpcMethodCall("LogIn", params)
     if sts and (None == data or 0 == len(data)):
         sts = False
     printDBG(">>>>>>>>>>>>>>>>>>>>>>>>>>>>> data[%s]" % data)
     if not sts:
         SetIPTVPlayerLastHostError(_('Login failed!'))
     elif ('' != login and self._checkStatus(data, 0)) or '' == login:
         if 'token' in data[0]:
             self.loginToken = data[0]['token']
         else:
             SetIPTVPlayerLastHostError(_('Get token failed!') + '\n' + _('Error message: \"%s\".\nError code: \"%s\".') % (self.lastApiError['code'], self.lastApiError['message']))
     else:
         SetIPTVPlayerLastHostError(_('Login failed!') + '\n' + _('Error message: \"%s\".\nError code: \"%s\".') % (self.lastApiError['code'], self.lastApiError['message']))
示例#16
0
    def getVideoLink(self, cItem):
        printDBG("InternetowaApi.getVideoLink")
        urlsTab = []

        sts, data = self.cm.getPage(cItem['url'], self.http_params)
        if not sts: return urlsTab
        cUrl = self.cm.meta['url']

        SetIPTVPlayerLastHostError(self.cleanHtmlStr(self.cm.ph.getDataBeetwenNodes(data, ('<div', '>', 'nostream'), ('</div', '>'), False)[1]))

        data = self.cm.ph.getAllItemsBeetwenMarkers(data, '<iframe', '>', caseSensitive=False)
        printDBG(data)
        for item in data:
            url = self.getFullUrl(self.cm.ph.getSearchGroups(item, '''src=['"]([^'^"]+?)['"]''')[0])
            if not self.cm.isValidUrl(url): continue
            if 1 == self.up.checkHostSupport(url):
                url = strwithmeta(url, {'Referer':cUrl})
                urlsTab.extend( self.up.getVideoLinkExt(url) )
            else:
                params = dict(self.http_params)
                params['header'] = MergeDicts(self.HTTP_HEADER, {'Referer':cUrl})
                sts, tmp = self.cm.getPage(url, params)
                if not sts: continue
                tmp2 = self.cm.ph.getDataBeetwenMarkers(tmp, '<audio', '</audio>', False)[1]
                tmp2 = self.cm.ph.getDataBeetwenMarkers(tmp, '<audio', '</audio>', False)[1]
                tmp = self.cm.ph.getAllItemsBeetwenMarkers(tmp2, '<source', '>')
                for it in tmp:
                    printDBG(it)
                    type = self.cm.ph.getSearchGroups(it, '''type=['"]([^"^']+?)['"]''')[0].lower().split('/', 1)
                    mediaUrl = self.cm.getFullUrl( self.cm.ph.getSearchGroups(it, '''src=['"]([^"^']+?)['"]''')[0], self.cm.meta['url'])
                    if type[0] in ('audio', 'video'):
                        mediaUrl = strwithmeta(mediaUrl, {'User-Agent':params['header']['User-Agent'], 'Referer':self.cm.meta['url']})
                        urlsTab.append({'name':'[%s] %s' % (type[1], self.cm.getBaseUrl(url, True)), 'url':mediaUrl, 'need_resolve':0})
        return urlsTab
示例#17
0
    def getVideoLinks(self, videoUrl):
        printDBG("BSTO.getVideoLinks [%s]" % videoUrl)
        urlTab = []

        key = strwithmeta(videoUrl).meta.get('links_key', '')
        if key in self.cacheLinks:
            for idx in range(len(self.cacheLinks[key])):
                if self.cacheLinks[key][idx][
                        'url'] == videoUrl and not self.cacheLinks[key][idx][
                            'name'].startswith('*'):
                    self.cacheLinks[key][idx][
                        'name'] = '*' + self.cacheLinks[key][idx]['name']

        sts, data = self.getPage(videoUrl)
        if not sts: return []

        errorMsg = ''

        baseUrl = self.cm.ph.getSearchGroups(
            data, '''href=['"][^'^"]*?(/out/[^'^"]+?)['"]''')[0]
        url = self.getFullUrl(baseUrl)
        params = dict(self.defaultParams)
        params['return_data'] = False
        try:
            prevUrl = url
            sts, response = self.cm.getPage(prevUrl, params)
            url = response.geturl()
            response.close()
            if url == prevUrl:
                sts, data = self.getPage(url)
                if 'bitte das Captcha' in data:
                    errorMsg = _('Link protected with google recaptcha v2.')
        except Exception:
            printExc()

        if 1 != self.up.checkHostSupport(url):
            url = baseUrl.replace('/out/', '/watch/')[1:]

            hostUrl = ''
            try:
                sts, data = self.cm.getPage(self.getFullUrl('/api/' + url),
                                            self.getHeaders(url))
                if not sts: return []

                data = byteify(json.loads(data))
                printDBG(data)

                hostUrl = data['fullurl']
            except Exception:
                printExc()
        else:
            hostUrl = url

        if 1 != self.up.checkHostSupport(hostUrl):
            SetIPTVPlayerLastHostError(errorMsg)
        elif self.cm.isValidUrl(hostUrl):
            urlTab = self.up.getVideoLinkExt(hostUrl)

        return urlTab
示例#18
0
    def getVideoLink(self, cItem):
        printDBG("WizjaTvApi.getVideoLink")
        urlsTab = []

        sts, data = self.cm.getPage(cItem['url'], self.http_params)
        if not sts:
            return urlsTab

        data = self.cm.ph.getAllItemsBeetwenMarkers(data,
                                                    '<iframe',
                                                    '>',
                                                    caseSensitive=False)
        printDBG(data)
        for item in data:
            url = self.getFullUrl(
                self.cm.ph.getSearchGroups(item,
                                           '''src=['"]([^'^"]+?)['"]''')[0])
            if not self.cm.isValidUrl(url):
                continue
            HTTP_HEADER = dict(self.HTTP_HEADER)
            HTTP_HEADER.update({'Referer': cItem['url']})
            params = dict(self.http_params)
            params['header'] = HTTP_HEADER

            tries = 0
            while tries < 2:
                tries += 1

                if 'porter' in url or 'player' in item:
                    sts, tmp = self.cm.getPage(url, params)
                    if not sts:
                        break
                    printDBG(tmp)
                    videoUrl = urllib.unquote(
                        self.cm.ph.getSearchGroups(
                            tmp,
                            '''['"]?src['"]?\s*:\s*['"](rtmp[^'^"]+?)['"]''')
                        [0])
                    killUrl = self.getFullUrl(
                        self.cm.ph.getSearchGroups(
                            tmp,
                            '''<a[^>]+?href=["']([^'^"]*?killme\.php[^'^"]*?)'''
                        )[0])
                    if videoUrl != '':
                        urlTab = self.cm.ph.getSearchGroups(
                            videoUrl,
                            '''rtmp://([^/]+?)/([^/]+?)/([^/]+?)\?(.+?)&streamType''',
                            4)
                        rtmp = 'rtmp://' + urlTab[0] + '/' + urlTab[1] + '?' + urlTab[3] + \
                               ' playpath=' + urlTab[2] + '?' + urlTab[3] + \
                               ' app=' + urlTab[1] + '?' + urlTab[3] + \
                               ' swfVfy=1 flashVer=WIN\\2020,0,0,306 swfUrl=http://wizja.tv/player/StrobeMediaPlayback_v3.swf live=1 token=fake pageUrl=' + cItem['url']
                        urlsTab.append({'name': 'rtmp', 'url': rtmp})
                    elif self.cm.isValidUrl(killUrl):
                        sts, tmp = self.cm.getPage(killUrl, params)
                        continue
                    SetIPTVPlayerLastHostError(self.cleanHtmlStr(tmp))
                break
        return urlsTab
示例#19
0
    def getLinksForVideo(self, cItem):
        printDBG("Filmativa.getLinksForVideo [%s]" % cItem)
        urlTab = []

        if not cItem.get('url', ''):
            return []

        if cItem.get('direct', False):
            if cItem.get('subtitles', ''):
                subtitlesTab = [{
                    'title': 'Serbian',
                    'url': cItem.get('subtitles', ''),
                    'lang': 'srp',
                    'format': 'vtt'
                }]
                url = strwithmeta(cItem['url'],
                                  {'external_sub_tracks': subtitlesTab})
                urlTab.append({'name': 'link', 'url': url, 'need_resolve': 1})
            else:
                urlTab.append({
                    'name': 'link',
                    'url': cItem['url'],
                    'need_resolve': 1
                })

        else:
            sts, data = self.cm.getPage(cItem['url'])
            if not sts:
                return urlTab

            if 'USKORO!' in data:
                SetIPTVPlayerLastHostError('USKORO!')
                return urlTab

            divIframe = self.cm.ph.getDataBeetwenMarkers(
                data, ('<div', '>', 'trailer'), '</div>', False)[1]
            url = self.cm.ph.getSearchGroups(divIframe, 'src="([^"]+?)"')[0]
            if 'videomega.tv/validatehash.php?' in url:
                sts, data = self.cm.getPage(
                    url, {
                        'header': {
                            'Referer': cItem['url'],
                            'User-Agent': 'Mozilla/5.0'
                        }
                    })
                if sts:
                    data = self.cm.ph.getSearchGroups(data,
                                                      'ref="([^"]+?)"')[0]
                    linkUrl = 'http://videomega.tv/view.php?ref={0}&width=700&height=460&val=1'.format(
                        data)
                    urlTab.append({
                        'name': 'videomega.tv',
                        'url': linkUrl,
                        'need_resolve': 1
                    })
            elif self.cm.isValidUrl(url):
                urlTab.append({'name': 'link', 'url': url, 'need_resolve': 1})

        return urlTab
示例#20
0
    def getLinksForVideo(self, cItem):
        printDBG("TVNowDE.getLinksForVideo [%s]" % cItem)
        retTab = []

        cacheTab = self.cacheLinks.get(cItem['url'], [])
        if len(cacheTab):
            return cacheTab

        urlDashClear = ''  #cItem.get('dashclear', '')
        if not self.cm.isValidUrl(urlDashClear):
            try:
                seoUrlItem = cItem['f_seo_url_format']
                seoUrlFormat = cItem['f_seo_url_item']
                station = cItem['f_station']
                url = self.getFullUrl(
                    '/movies/{0}/{1}?fields=*,format,files,manifest,breakpoints,paymentPaytypes,trailers,packages&station={2}'
                    .format(seoUrlItem, seoUrlFormat, station))
                sts, data = self.getPage(url)
                if not sts: return []
                try:
                    data = json_loads(data)
                except Exception:
                    data = 'error'

                if 'error' in data: data = cItem['orig_item']

                urlDashClear = data['manifest']['dashclear']
                if data.get('isDrm', False):
                    SetIPTVPlayerLastHostError(_("Video with DRM protection."))
                if not self.cm.isValidUrl(urlDashClear): return []
            except Exception:
                printExc()

        if self.cm.isValidUrl(urlDashClear):
            urlHlsClear = urlDashClear.replace('/vodnowusodash.',
                                               '/vodnowusohls.').split('?', 1)
            urlHlsClear[0] = urlHlsClear[0][:-3] + 'm3u8'
            urlHlsClear = '?'.join(urlHlsClear)
            hlsTab = getDirectM3U8Playlist(urlHlsClear, checkContent=True)
            dashTab = getMPDLinksWithMeta(urlDashClear, False)
            try:
                hlsTab = sorted(
                    hlsTab, key=lambda item: -1 * int(item.get('bitrate', 0)))
                dashTab = sorted(
                    dashTab,
                    key=lambda item: -1 * int(item.get('bandwidth', 0)))
            except Exception:
                printExc()
            if config.plugins.iptvplayer.tvnowde_prefered_format.value == 'hls':
                retTab.extend(hlsTab)
                retTab.extend(dashTab)
            else:
                retTab.extend(dashTab)
                retTab.extend(hlsTab)
        if len(retTab):
            self.cacheLinks[cItem['url']] = retTab

        return retTab
示例#21
0
    def getVideoLink(self, cItem):
        printDBG("TelewizjadaNetApi.getVideoLink")

        url = self.MAIN_URL + 'live.php?cid=%s' % cItem['cid']
        sts, data = self.cm.getPage(url, self.http_params)
        if not sts: return []

        http_params = dict(self.http_params)
        HTTP_HEADER = {
            'User-Agent':
            'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:21.0) Gecko/20100101 Firefox/21.0'
        }
        http_params.update({'header': HTTP_HEADER})
        http_params['header']['Referer'] = url

        url = self.MAIN_URL + 'get_mainchannel.php'
        sts, data = self.cm.getPage(url, http_params, {'cid': cItem['cid']})
        if not sts: return []
        try:
            data = byteify(json.loads(data))
            vid_url = data['url']
        except Exception:
            printExc()
            return []

        url = self.MAIN_URL + 'set_cookie.php'
        sts, data = self.cm.getPage(url, http_params, {'url': vid_url})
        if not sts: return []

        url = self.MAIN_URL + 'get_channel_url.php'
        sts, data = self.cm.getPage(url, http_params, {'cid': cItem['cid']})
        if not sts: return []

        try:
            vid_url = byteify(json.loads(data))
            vid_url = vid_url['url']
        except Exception:
            vid_url = data

        urlsTab = []
        vid_url = vid_url.strip()
        if vid_url.startswith('http://') and 'm3u8' in vid_url:
            try:
                sessid = self.cm.getCookieItem(self.COOKIE_FILE, 'sessid')
                msec = self.cm.getCookieItem(self.COOKIE_FILE, 'msec')
                statid = self.cm.getCookieItem(self.COOKIE_FILE, 'statid')
                url = strwithmeta(
                    vid_url, {
                        'Cookie':
                        'sessid=%s; msec=%s; statid=%s;' %
                        (sessid, msec, statid)
                    })
                urlsTab = getDirectM3U8Playlist(url)
            except Exception:
                SetIPTVPlayerLastHostError(
                    "Problem z dostępem do pliku \"%\".\nSprawdź, czy masz wolne miejsce na pliki cookies."
                    % self.COOKIE_FILE)
        return urlsTab
示例#22
0
    def getVideoLinks(self, videoUrl):
        printDBG("SerienStreamTo.getVideoLinks [%s]" % videoUrl)
        urlTab = []
        videoUrl = strwithmeta(videoUrl)
        key = videoUrl.meta.get('base_url', '')
        if key != '' and key in self.cacheLinks:
            for idx in range(len(self.cacheLinks[key])):
                if self.cacheLinks[key][idx]['url'] == videoUrl:
                    if not self.cacheLinks[key][idx]['name'].startswith('*'):
                        self.cacheLinks[key][idx][
                            'name'] = '*' + self.cacheLinks[key][idx]['name']

        if self.cm.isValidUrl(videoUrl):
            if 1 != self.up.checkHostSupport(videoUrl):
                params = dict(self.defaultParams)
                try:
                    params['max_data_size'] = 0
                    params['no_redirection'] = True
                    tries = 0
                    url = videoUrl
                    while tries < 3:
                        sts, data = self.getPage(url, params)
                        printDBG("+++++++++++")
                        printDBG(self.cm.meta)
                        printDBG("+++++++++++")
                        url = self.cm.meta.get('location', '')
                        if not self.cm.isValidUrl(url):
                            break
                        if url != '':
                            videoUrl = url
                        tries += 1
                except Exception:
                    printExc()

            printDBG(">>>>>>>>>>>>>>>>>>>>>>>>||||||||||||||||||||||||")
            if 1 != self.up.checkHostSupport(videoUrl):
                sts, data = self.getPage(videoUrl)
                if sts:
                    videoUrl = self.cm.meta['url']
                printDBG("+++++++++++")
                printDBG(data)
                printDBG("+++++++++++")
                if sts and 'google.com/recaptcha/' in data and 'sitekey' in data:
                    message = _('Link protected with google recaptcha v2.')
                    if True != self.loggedIn:
                        message += '\n' + _(
                            'Please fill your login and password in the host configuration (available under blue button) and try again.'
                        )
                    else:
                        message += '\n' + self.cleanHtmlStr(
                            self.cm.ph.getDataBeetwenMarkers(
                                data, '<small', '</small>')[1])
                        message += '\n' + _('Please retry later.')
                    SetIPTVPlayerLastHostError(message)

            if 1 == self.up.checkHostSupport(videoUrl):
                urlTab = self.up.getVideoLinkExt(videoUrl)
        return urlTab
示例#23
0
    def getLinksForVideo(self, cItem):
        printDBG("FiliserTv.getLinksForVideo [%s]" % cItem)
        urlTab = []

        if len(self.cacheLinks.get(cItem['url'], [])):
            return self.cacheLinks[cItem['url']]

        sts, data = self.getPage(cItem['url'], self.defaultParams)
        if not sts: return []

        errorMessage = ph.clean_html(
            ph.find(data, ('<h2', '>', 'title_block'), '</section>')[1])
        if '' != errorMessage: SetIPTVPlayerLastHostError(errorMessage)

        lParams = {}
        tmp = ph.findall(data,
                         ('<div', '>', ph.check(ph.any, ('"box"', "'box'"))),
                         '</section>',
                         flags=ph.START_S,
                         limits=2)
        if not tmp: return
        lParams['code'] = ph.getattr(tmp[0], 'data-code')
        lParams['code2'] = ph.getattr(tmp[0], 'data-code2')
        lParams['type'] = ph.getattr(tmp[0], 'id').split('_', 1)[0]

        tmp = ph.findall(tmp[1], ('<h', '>'), ('</h', '>'), flags=0, limits=2)
        lParams['title1'] = ph.clean_html(tmp[0])
        lParams['title2'] = ph.clean_html(tmp[-1])

        data = data.split('<div id="links">')
        if 2 != len(data): return []

        tabs = []
        tmp = ph.find(data[0], '<div id="video_links"',
                      '<div class="clear">')[1]
        tmp = re.compile(
            '<[^>]+?data-type\="([^"]+?)"[^>]*?>([^<]+?)<').findall(tmp)
        for item in tmp:
            tabs.append({'key': item[0], 'title': ph.clean_html(item[1])})

        if tabs: del data[0]

        for tab in tabs:
            tmp = ph.find(data[0], 'data-type="%s"' % tab['key'], '</ul>')[1]
            tmp = ph.findall(tmp, '<li', '</li>')
            for item in tmp:
                url = strwithmeta(ph.getattr(item, 'data-ref'),
                                  {'link_params': lParams})
                title = ph.clean_html(item.split('<div class="rightSide">')[0])
                urlTab.append({
                    'name': '%s: %s' % (tab['title'], title),
                    'url': url,
                    'need_resolve': 1
                })

        self.cacheLinks[cItem['url']] = urlTab
        return urlTab
示例#24
0
    def _initialize_api(self, video_id):
        sts, data = self.cm.getPage('http://www.vevo.com/')
        if sts:
            oauth_token = self.cm.ph.getSearchGroups(data, '''"access_token":"([^"]+?)"''')[0]

        if 'THIS PAGE IS CURRENTLY UNAVAILABLE IN YOUR REGION' in data:
            SetIPTVPlayerLastHostError(_('%s said: This page is currently unavailable in your region') % self.IE_NAME)

        self._api_url_template = 'http://apiv2.vevo.com/%s?token=' + oauth_token
示例#25
0
 def getPage(self, url, params={}, post_data=None):
     if params == {}:
         params = dict(self.defaultParams)
     sts, data = self.cm.getPage(url, params, post_data)
     if sts:
         error = self.cm.ph.getDataBeetwenMarkers(data, '<div class="alert-message"', '</div>')[1]
         if error != '':
             SetIPTVPlayerLastHostError(self.cleanHtmlStr(error))
     return sts, data
示例#26
0
    def downloadSubtitleFile(self, cItem):
        printDBG("OpenSubOrgProvider.downloadSubtitleFile")
        retData = {}
        title = cItem['title']
        fileName = cItem['file_name']
        url = cItem['url']
        lang = cItem['lang']
        encoding = cItem['encoding']
        imdbid = cItem['imdbid']

        urlParams = dict(self.defaultParams)
        urlParams['max_data_size'] = self.getMaxFileSize()

        sts, data = self.cm.getPage(url, urlParams)
        if not sts:
            SetIPTVPlayerLastHostError(_('Failed to download subtitle.'))
            return retData

        try:
            data = DecodeGzipped(data)
        except Exception:
            printExc()
            SetIPTVPlayerLastHostError(_('Failed to gzip.'))
            return retData

        try:
            data = data.decode(encoding).encode('UTF-8')
        except Exception:
            printExc()
            SetIPTVPlayerLastHostError(_('Failed to decode to UTF-8.'))
            return retData

        fileName = GetSubtitlesDir(fileName)
        printDBG(">>")
        printDBG(fileName)
        printDBG("<<")
        try:
            with open(fileName, 'w') as f:
                f.write(data)
            retData = {'title': title, 'path': fileName, 'lang': lang, 'imdbid': imdbid}
        except Exception:
            SetIPTVPlayerLastHostError(_('Failed to write file "%s".') % fileName)
            printExc()
        return retData
示例#27
0
 def getLinksForVideo(self, cItem):
     videoUrlTab = []
     baseUrl   = self.getFullUrl( cItem['url'] )
     try:
         sts, data = self.cm.getPage( baseUrl )
         verUrl = self.getFullUrl(self.cm.ph.getSearchGroups(data, '<iframe id="framep" class="radi" src="([^"]+?)"')[0])
         sts, data = self.cm.getPage( verUrl )
         versions = []
         sts, data = self.cm.ph.getDataBeetwenMarkers(data, '<b>Wersja:</b>', '<script>', False)
         if sts:
             data = data.split('<input')
             if len(data): del data[0]
             for item in data:
                 name  = self.cm.ph.getSearchGroups(item, 'name="([^"]+?)"')[0]
                 value = self.cm.ph.getSearchGroups(item, 'value="([^"]+?)"')[0]
                 versions.append({'title':value, 'url': verUrl + ('&wi=va&%s=%s' % (name, value) )})
         else:
             versions.append({'title':'', 'url': verUrl + '&wi=va'})
         for item in versions:
             try:
                 url = item['url']
                 sts, data = self.cm.getPage( url )
                 
                 videoUrl = ''
                 if "url: escape('http" in data:
                     match = re.search("url: escape\('([^']+?)'", data)
                     if match: videoUrl = match.group(1)
                 elif "eval(function(p,a,c,k,e,d)" in data:
                     printDBG( 'Host resolveUrl packed' )
                     match = re.search('eval\((.+?),0,{}\)\)', data, re.DOTALL)
                     if match: videoUrl = self.decodeJS('eval(' + match.group(1) + ',0,{}))')
                 elif "var flm = '" in data:
                     printDBG( 'Host resolveUrl var flm' )
                     match = re.search("var flm = '([^']+?)';", data)
                     if match: videoUrl = match.group(1)
                 elif 'primary: "html5"' in data:
                     printDBG( 'Host resolveUrl html5' )
                     match = re.search('file: "([^"]+?)"', data)
                     if match: videoUrl = match.group(1)
                 elif 'sources:' in data:
                     data2 = self.cm.ph.getDataBeetwenMarkers(data, 'sources:', ']', False)[1]
                     videoUrl = self.cm.ph.getSearchGroups(data2, '''src[^'"]*?['"](http[^'"]+?)['"]''')[0]
                     data2 = None
                 if videoUrl.startswith('http') and videoUrl != 'http://serialnet.pl/':
                     videoUrl = byteify(json.loads('"%s"' % videoUrl))
                     videoUrlTab.append({'name':item['title'], 'url':videoUrl})
                 else:
                     msg = self.cleanHtmlStr(self.cm.ph.getDataBeetwenMarkers(data, '<div id="errorbox"', '</div>')[1])
                     if msg == '': 
                         msg = self.cm.ph.getDataBeetwenMarkers(data, 'on("error"', '}', False)[1]
                         msg = self.cleanHtmlStr(self.cm.ph.getSearchGroups(msg, "text\('([^']+?)'")[0])
                     SetIPTVPlayerLastHostError(msg)
                 printDBG("SerialeNet.getLinksForVideo >>>>>>>>>>>>>>>> videoUrl[%s]" % videoUrl)
             except Exception: printExc()
     except Exception: printExc()
     return videoUrlTab 
示例#28
0
 def writeFile(self, filePath, data):
     printDBG('CBaseSubProviderClass.writeFile path[%s]' % filePath)
     try:
         with open(filePath, 'w') as f:
             f.write(data)
         return True
     except Exception:
         printExc()
         SetIPTVPlayerLastHostError(_('Failed to write file "%s".') % filePath)
     return False
    def getPage(self, url, params={}, post_data=None):
        HTTP_HEADER = dict(self.HEADER)
        params.update({'header': HTTP_HEADER})

        sts, data = self.cm.getPage(url, params, post_data)
        if sts and None == data:
            sts = False
        if sts and 'Duze obciazenie!' in data:
            SetIPTVPlayerLastHostError(self.cleanHtmlStr(data))
        return sts, data
示例#30
0
    def getVideoLinks(self, videoUrl):
        printDBG("EgyBest.getVideoLinks [%s]" % videoUrl)
        videoUrl = strwithmeta(videoUrl)
        urlTab = []

        # mark requested link as used one
        if len(self.cacheLinks.keys()):
            for key in self.cacheLinks:
                for idx in range(len(self.cacheLinks[key])):
                    if videoUrl in self.cacheLinks[key][idx]['url']:
                        if not self.cacheLinks[key][idx]['name'].startswith('*'):
                            self.cacheLinks[key][idx]['name'] = '*' + self.cacheLinks[key][idx]['name'] + '*'
                        break

        if videoUrl.meta.get('iptv_proto', '') == 'm3u8':
            return getDirectM3U8Playlist(videoUrl, False, checkContent=True, sortWithMaxBitrate=999999999)
        elif videoUrl.meta.get('direct', False):
            return [{'name': 'direct', 'url': videoUrl}]

        params = dict(self.defaultParams)
        params['header'] = dict(self.AJAX_HEADER)
        params['header']['Referer'] = videoUrl.meta.get('Referer', '')
        params['with_metadata'] = True

        if videoUrl.meta.get('priv_api_call', False):
            url = self.getFullUrl('/api?call=' + videoUrl)
        else:
            url = videoUrl

        if 'api?call=' in url:
            sts, data = self.getPage(url, params)
            if not sts:
                return []
            videoUrl = strwithmeta(data.meta['url'], videoUrl.meta)
            if 1 != self.up.checkHostSupport(videoUrl):
                try:
                    data = byteify(json.loads(data), '', True)
                    if data.get('status', '') == '200':
                        authUrl = data.get('auth_url', '')
                        url = data.get('url', '')
                        if self.cm.isValidUrl(url) and self.cm.isValidUrl(authUrl):
                            sts, tmp = self.getPage(authUrl)
                            if sts:
                                urlTab.append({'name': 'direct', 'url': url})
                    elif data.get('action', '') == 'message':
                        SetIPTVPlayerLastHostError(self.cleanHtmlStr(data['message']))
                        printDBG(self.cleanHtmlStr(data['message']))
                    printDBG(data)
                except Exception:
                    printExc()

        if 1 == self.up.checkHostSupport(videoUrl):
            urlTab = self.up.getVideoLinkExt(videoUrl)

        return urlTab