Пример #1
0
    def getLinksForVideo(self, cItem):
        asset_id = str(cItem.get('object_id', ''))
        url = self._getFullUrl(cItem.get('url', ''))
        
        if 'tvpstream.tvp.pl' in url:
            sts, data = self.cm.getPage(url)
            if not sts: return []
            
            hlsUrl = self.cm.ph.getSearchGroups(data, '''['"](http[^'^"]*?\.m3u8[^'^"]*?)['"]''')[0]
            if '' != hlsUrl:
                videoTab = getDirectM3U8Playlist(hlsUrl, checkExt=False, variantCheck=False)
                if 1 < len(videoTab):
                    max_bitrate = int(config.plugins.iptvplayer.tvpVodDefaultformat.value)
                    def __getLinkQuality( itemLink ):
                        if 'width' in itemLink and 'height' in itemLink:
                            bitrate = self.getBitrateFromFormat('%sx%s' % (itemLink['width'], itemLink['height']))
                            if bitrate != 0: return bitrate
                        return int(itemLink['bitrate'])
                    oneLink = CSelOneLink(videoTab, __getLinkQuality, max_bitrate)
                    if config.plugins.iptvplayer.tvpVodUseDF.value:
                        videoTab = oneLink.getOneLink()
                    else:
                        videoTab = oneLink.getSortedLinks()
                if 1 <= len(videoTab):
                    return videoTab
            
        if '' == asset_id:
            asset_id = self.getObjectID(url)

        return self.getVideoLink(asset_id)
            def _getVideoLink(data, FORMATS):
                videoTab = []
                for item in data['formats']:
                    if item['mimeType'] in FORMATS.keys():
                        formatType = FORMATS[item['mimeType']].encode('utf-8')
                        name = self.getFormatFromBitrate(
                            str(item['totalBitrate'])) + '\t ' + formatType
                        url = item['url'].encode('utf-8')
                        if 'm3u8' == formatType:
                            videoTab.extend(getDirectM3U8Playlist(url))
                        else:
                            videoTab.append({
                                'name':
                                name,
                                'bitrate':
                                str(item['totalBitrate']),
                                'url':
                                url
                            })
                if 1 < len(videoTab):
                    max_bitrate = int(
                        config.plugins.iptvplayer.tvpVodDefaultformat.value)

                    def __getLinkQuality(itemLink):
                        return int(itemLink['bitrate'])

                    oneLink = CSelOneLink(videoTab, __getLinkQuality,
                                          max_bitrate)
                    if config.plugins.iptvplayer.tvpVodUseDF.value:
                        videoTab = oneLink.getOneLink()
                    else:
                        videoTab = oneLink.getSortedLinks()
                return videoTab
Пример #3
0
 def _getVideoLink(data, FORMATS):
     videoTab = []
     for item in data['formats']:
         if item['mimeType'] in FORMATS.keys():
             formatType = FORMATS[item['mimeType']].encode('utf-8')
             format = self.REAL_FORMATS.get(formatType, '')
             name = self.getFormatFromBitrate( str(item['totalBitrate']) ) + '\t ' + formatType
             url = item['url'].encode('utf-8')
             if 'm3u8' == formatType:
                 videoTab.extend( getDirectM3U8Playlist(url) )
             else:
                 meta = {'iptv_format':format}
                 if config.plugins.iptvplayer.tvpVodProxyEnable.value:
                     meta['http_proxy'] = config.plugins.iptvplayer.proxyurl.value
                 videoTab.append( {'name' : name, 'bitrate': str(item['totalBitrate']), 'url' : self.up.decorateUrl(url, meta) })
     if 1 < len(videoTab):
         max_bitrate = int(config.plugins.iptvplayer.tvpVodDefaultformat.value)
         def __getLinkQuality( itemLink ):
             return int(itemLink['bitrate'])
         oneLink = CSelOneLink(videoTab, __getLinkQuality, max_bitrate)
         if config.plugins.iptvplayer.tvpVodUseDF.value:
             videoTab = oneLink.getOneLink()
         else:
             videoTab = oneLink.getSortedLinks()
     return videoTab
 def getVideoLinks(self,url):
     printDBG('WRZUTA.getVideoLinks')
     nurl = url.split("/")
     url = 'http://'+ nurl[2] + '/u/' + nurl[4]
     retList = []
     sts, data = self.cm.getPage(url)
     if not sts: return retList
     match = re.compile('var _src = {(.+?)};', re.DOTALL).findall(data)
     if len(match) > 0:
         match2 = re.compile("\t'(.+?)': (.+?),?\n").findall(match[0])
         for num, item in match2[::-1]:
             if item != '""':
                 parts = re.compile('"(.*?)"').findall(item)
                 linkVideo = ''.join(parts)
                 if linkVideo.find("http://c.wrzuta.pl/wht") == -1:
                     retList.append({'name': num, 'url': linkVideo})
                     
     maxRes = int(config.plugins.iptvplayer.wrzutaDefaultformat.value) * 1.1
     def __getLinkQuality( itemLink ):
         return int(itemLink['name'])
     obj = CSelOneLink(retList, __getLinkQuality, maxRes)
     if config.plugins.iptvplayer.wrzutaUseDF.value:
         retList = obj.getOneLink()
     else: retList = obj.getSortedLinks()
     return retList
Пример #5
0
    def getVideoLinks(self, url):
        printDBG('WRZUTA.getVideoLinks')
        nurl = url.split("/")
        url = 'http://' + nurl[2] + '/u/' + nurl[4]
        retList = []
        sts, data = self.cm.getPage(url)
        if not sts: return retList
        match = re.compile('var _src = {(.+?)};', re.DOTALL).findall(data)
        if len(match) > 0:
            match2 = re.compile("\t'(.+?)': (.+?),?\n").findall(match[0])
            for num, item in match2[::-1]:
                if item != '""':
                    parts = re.compile('"(.*?)"').findall(item)
                    linkVideo = ''.join(parts)
                    if linkVideo.find("http://c.wrzuta.pl/wht") == -1:
                        retList.append({'name': num, 'url': linkVideo})

        maxRes = int(config.plugins.iptvplayer.wrzutaDefaultformat.value) * 1.1

        def __getLinkQuality(itemLink):
            return int(itemLink['name'])

        obj = CSelOneLink(retList, __getLinkQuality, maxRes)
        if config.plugins.iptvplayer.wrzutaUseDF.value:
            retList = obj.getOneLink()
        else:
            retList = obj.getSortedLinks()
        return retList
Пример #6
0
 def getLinksForVideo(self, cItem):
     printDBG("TVJWORG.getLinksForVideo [%s]" % cItem)
     urlTab = []
     
     try:
         tmpTab = cItem.get('files', [])
         for item in tmpTab:
             try:
                 linkVideo = item['progressiveDownloadURL']
                 linkVideo = urlparser.decorateUrl(linkVideo, {'Referer': 'http://tv.jw.org/'})
                 urlTab.append({'name':item['label'], 'url': linkVideo, 'need_resolve':0})
             except Exception:
                 printExc()
             
         if 1 < len(urlTab):
             error = False
             max_bitrate = int(config.plugins.iptvplayer.tvjworg_default_format.value)
             def __getLinkQuality( itemLink ):
                 try: 
                     return int(itemLink['name'][0:-1])
                 except Exception:
                     error = True
                     return 0
             oneLink = CSelOneLink(urlTab, __getLinkQuality, max_bitrate)
             if not error and config.plugins.iptvplayer.tvjworg_use_df.value:
                 urlTab = oneLink.getOneLink()
             else:
                 urlTab = oneLink.getSortedLinks()
     except Exception:
         printExc()
     
     return urlTab
Пример #7
0
 def getLinksForVideo(self, cItem):
     printDBG("TVJWORG.getLinksForVideo [%s]" % cItem)
     urlTab = []
     
     try:
         tmpTab = cItem.get('files', [])
         for item in tmpTab:
             try:
                 linkVideo = item['progressiveDownloadURL']
                 linkVideo = urlparser.decorateUrl(linkVideo, {'Referer': 'http://tv.jw.org/'})
                 urlTab.append({'name':item['label'], 'url': linkVideo, 'need_resolve':0})
             except:
                 printExc()
             
         if 1 < len(urlTab):
             error = False
             max_bitrate = int(config.plugins.iptvplayer.tvjworg_default_format.value)
             def __getLinkQuality( itemLink ):
                 try: 
                     return int(itemLink['name'][0:-1])
                 except:
                     error = True
                     return 0
             oneLink = CSelOneLink(urlTab, __getLinkQuality, max_bitrate)
             if not error and config.plugins.iptvplayer.tvjworg_use_df.value:
                 urlTab = oneLink.getOneLink()
             else:
                 urlTab = oneLink.getSortedLinks()
     except:
         printExc()
     
     return urlTab
 def getLinksForVideo(self, cItem):
     printDBG("KissCartoonMe.getLinksForVideo [%s]" % cItem)
     urlTab = []
     
     sts, data = self.getPage(cItem['url']) 
     if not sts: return urlTab
     
     tmpTab = self.cm.ph.getAllItemsBeetwenMarkers(data, 'asp.wrap(', ')', False)
     for tmp in tmpTab:
         tmp = tmp.strip()
         if tmp.startswith('"'):
             tmp = tmp[1:-1]
         else:
             tmp = self.cm.ph.getSearchGroups(data, '''var %s =[^'^"]*?["']([^"^']+?)["']''')[0]
         if tmp == '': continue
         try:
             tmp = base64.b64decode(tmp)
             tmp = self.cm.ph.getAllItemsBeetwenMarkers(tmp, '<a ', '</a>')
             for item in tmp:
                 url  = self.cm.ph.getSearchGroups(item, '''href="([^"]+?)"''')[0]
                 if 'googlevideo.com' not in url: continue
                 name = self.cleanHtmlStr(item)
                 urlTab.append({'name':name, 'url':url, 'need_resolve':0})
         except:
             printExc()
             continue
     
     tmpTab = self.cm.ph.getDataBeetwenMarkers(data, '<select id="selectQuality">', '</select>', False)
     tmpTab = self.cm.ph.getAllItemsBeetwenMarkers(data, '<option', '</option>')
     for item in tmpTab:
         url  = self.cm.ph.getSearchGroups(item, '''value="([^"]+?)"''')[0]
         if '' == url: continue
         try:
             url = base64.b64decode(url)
         except:
             continue
         if '://' not in url: continue
         name = self.cleanHtmlStr(item)
         urlTab.append({'name':name, 'url':url, 'need_resolve':0})
         
     if 0 < len(urlTab):
         max_bitrate = int(config.plugins.iptvplayer.kisscartoon_defaultformat.value)
         def __getLinkQuality( itemLink ):
             try:
                 return int(self.cm.ph.getSearchGroups('|'+itemLink['name']+'|', '[^0-9]([0-9]+?)[^0-9]')[0])
             except: return 0
         urlTab = CSelOneLink(urlTab, __getLinkQuality, max_bitrate).getBestSortedList()         
         
     data = self.cm.ph.getAllItemsBeetwenMarkers(data, '<iframe ', '>', withMarkers=True, caseSensitive=False)
     for item in data:
         url  = self.cm.ph.getSearchGroups(item, '''<iframe[^>]+?src=['"]([^'^"]+?)['"]''',  grupsNum=1, ignoreCase=True)[0]
         url = self._getFullUrl(url)
         if url.startswith('http') and 'facebook.com' not in url and 1 == self.up.checkHostSupport(url):
             urlTab.append({'name': self.up.getHostName(url), 'url':url, 'need_resolve':1})
             
     return urlTab
Пример #9
0
 def getDirectLinks(self, url):
     printDBG('MoonwalkParser.getDirectLinks')
     linksTab = []
     try:
         self._setBaseUrl(url)
         params = copy.deepcopy(self.defaultParams)
         params['header']['Referer'] = url
         sts, data = self.cm.getPage( url, params)
         if not sts: return []
         
         sec_header, post_data = self._getSecurityData(data)
         params['header'].update(sec_header)
         
         params['load_cookie'] = True
         sts, data = self.cm.getPage( '%s/sessions/new_session' % self.baseUrl, params, post_data)
         printDBG("=======================================================")
         printDBG(data)
         printDBG("=======================================================")
         if not sts: return []
         
         try: 
             data = byteify( json.loads(data) )
             data = data['mans']
         except Exception: printExc()
         if 'm3u8' == config.plugins.iptvplayer.moonwalk_format.value:
             tmpTab = getDirectM3U8Playlist(data["manifest_m3u8"])
             def __getLinkQuality( itemLink ):
                 return itemLink['heigth']
             if config.plugins.iptvplayer.moonwalk_use_df.value:
                 maxRes = config.plugins.iptvplayer.moonwalk_df_format.value
                 tmpTab = CSelOneLink(tmpTab, __getLinkQuality, maxRes).getSortedLinks()
                 tmpTab = [tmpTab[0]]
             for item in tmpTab:
                 linksTab.append({'name':'[hls/m3u8] %sp' % __getLinkQuality(item), 'url':item['url']})
         else:
             tmpTab = getF4MLinksWithMeta(data["manifest_f4m"])
             def __getLinkQuality( itemLink ):
                 printDBG(itemLink)
                 bitrate = int(self.cm.ph.getDataBeetwenMarkers(itemLink['name'], 'bitrate[', ']', False)[1])
                 if bitrate < 400:
                     return 360
                 elif bitrate < 700:
                     return 480
                 elif bitrate < 1200:
                     return 720
                 return 1080
             if config.plugins.iptvplayer.moonwalk_use_df.value:
                 maxRes = config.plugins.iptvplayer.moonwalk_df_format.value
                 tmpTab = CSelOneLink(tmpTab, __getLinkQuality, maxRes).getSortedLinks()
                 tmpTab = [tmpTab[0]]
             for item in tmpTab:
                 linksTab.append({'name':'[f4m/hds] %sp' % __getLinkQuality(item), 'url':item['url']})
     except Exception:
         printExc()
     return linksTab
Пример #10
0
 def _sortVideoLinks(videoTab):
     if 1 < len(videoTab):
         max_bitrate = int(config.plugins.iptvplayer.tvpVodDefaultformat.value)
         def __getLinkQuality( itemLink ):
             if 'width' in itemLink and 'height' in itemLink:
                 bitrate = self.getBitrateFromFormat('%sx%s' % (itemLink['width'], itemLink['height']))
                 if bitrate != 0: return bitrate
             try: return int(itemLink['bitrate'])
             except Exception: return 0
         oneLink = CSelOneLink(videoTab, __getLinkQuality, max_bitrate)
         videoTab = oneLink.getSortedLinks()
     return videoTab
Пример #11
0
    def getLinksForVideo(self, cItem):
        printDBG("TvGryPL.getLinksForVideo [%s]" % cItem)
        id = self.cm.ph.getSearchGroups(cItem['url'] + '_',
                                        'ID=([0-9]+?)[^0-9]', 1)[0]

        urlTab = []
        sts, data = self.cm.getPage(
            'http://tvgry.pl/video/source.v2.asp?SC=TV&ID=%s&QL=SD' % id)
        if not sts: return urlTab
        data = re.compile('file="([^"]+?)"[^>]*?label="([^"]+?)"').findall(
            data)
        for item in data:
            q = ""
            if '_C/500_' in item[0] or "Mobile" in item[1]:
                q = 'MOB'
            elif '_C/750_' in item[0] or "SD" in item[1]:
                q = 'SD'
            elif '_C/1280_' in item[0] or "720p" in item[1]:
                q = 'HD'
            #elif '_C/1920_' in item[0] or "1080p" in item[1]:
            #    q = 'FHD'
            if '' != q:
                urlTab.append({
                    'name':
                    item[1],
                    'url':
                    urlparser.decorateUrl(item[0], {
                        'Referer':
                        'http://p.jwpcdn.com/6/12/jwplayer.flash.swf'
                    }),
                    'q':
                    q
                })

        # for item in ['MOB', 'SD', 'HD']:
        # url = 'http://tvgry.pl/video/source.asp?SC=TV&ID=%s&QL=%s' % (id, item[:2])
        # sts,data = self.getPage(url)
        # if not sts: continue
        # url = self.cm.ph.getSearchGroups(data, 'file>(http[^<]+?)<', 1)[0]
        # if '' != url: urlTab.append({'name':item, 'url':url, 'q':item})

        if 1 < len(urlTab):
            map = {'MOB': 0, 'SD': 1, 'HD': 2, 'FHD': 3}
            oneLink = CSelOneLink(
                urlTab, lambda x: map[x['q']],
                map[config.plugins.iptvplayer.tvgrypl_default_quality.value])
            if config.plugins.iptvplayer.tvgrypl_use_dq.value:
                urlTab = oneLink.getOneLink()
            else:
                urlTab = oneLink.getSortedLinks()
        return urlTab
Пример #12
0
 def getLinksForVideo(self, cItem):
     printDBG("WRealu24TV.getLinksForVideo [%s]" % cItem)
     retTab = []
     hlsTab = []
     
     sts, data = self.getPage(cItem['url'])
     if not sts: return
     
     data = re.sub("<!--[\s\S]*?-->", "", data)
     cookieHeader = self.cm.getCookieHeader(self.COOKIE_FILE)
     
     data = self.cm.ph.getDataBeetwenMarkers(data, '<video', '</video>')[1]
     if 'document.write(' in data:
         jscode = ['var document = {};document.write=function(txt){print(txt);}']
         tmp = self.cm.ph.getAllItemsBeetwenNodes(data, ('<script', '>'), ('</script', '>'), False)
         for item in tmp:
             jscode.append(item)
         jscode = '\n'.join(jscode)
         ret = js_execute( jscode )
         if ret['sts'] and 0 == ret['code']:
             data = ret['data'].strip()
     
     data = self.cm.ph.getAllItemsBeetwenMarkers(data, '<source', '>')
     printDBG(data)
     for item in data:
         url = self.getFullUrl(self.cm.ph.getSearchGroups(item, '''src=['"]([^'^"]+?)['"]''')[0])
         if not self.cm.isValidUrl(url): continue
         type = self.cm.ph.getSearchGroups(item, '''type=['"]([^'^"]+?)['"]''')[0].lower()
         label = self.cm.ph.getSearchGroups(item, '''label=['"]([^'^"]+?)['"]''')[0]
         res = self.cm.ph.getSearchGroups(item, '''res=['"]([^'^"]+?)['"]''')[0]
         if label == '': label = res
         
         if 'mp4' in type:
             url = self.up.decorateUrl(url, {'Cookie':cookieHeader, 'User-Agent':self.USER_AGENT, 'Referer':cItem['url']})
             retTab.append({'name':label, 'url':url, 'res':res, 'need_resolve':0})
         elif 'mpegurl' in type:
             url = self.up.decorateUrl(url, {'iptv_proto':'m3u8', 'Origin':self.up.getDomain(cItem['url'], False), 'Cookie':cookieHeader, 'User-Agent':self.USER_AGENT, 'Referer':cItem['url']}) 
             hlsTab.extend(getDirectM3U8Playlist(url, checkContent=True, sortWithMaxBitrate=999999999))
         else:
             printDBG("Unknown source: [%s]" % item)
     
     if 1 < len(retTab):
         def __getLinkQuality( itemLink ):
             try: return int(itemLink['res'])
             except Exception: return 0
         oneLink = CSelOneLink(retTab, __getLinkQuality, 999999999)
         retTab = oneLink.getSortedLinks()
     
     retTab.extend(hlsTab)
     return retTab
Пример #13
0
    def getLinksForVideo(self, cItem):
        printDBG("QuesttvCoUK.getLinksForVideo [%s]" % cItem)
        urlTab = []
        mp4Tab = []
        hlsTab = []

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

            videoId = self.cm.ph.getSearchGroups(data, '''data\-videoid=['"]([^'^"]+?)['"]''')[0]
            if videoId == '':
                return ''

            getParams = {}
            data = self.cm.ph.getDataBeetwenMarkers(data, '<object', '</object>')[1]
            data = self.cm.ph.getAllItemsBeetwenMarkers(data, '<param', '>')
            for item in data:
                name = self.cm.ph.getSearchGroups(item, '''name=['"]([^'^"]+?)['"]''')[0]
                if name not in ['playerID', '@videoPlayer', 'playerKey']:
                    continue
                value = self.cm.ph.getSearchGroups(item, '''value=['"]([^'^"]+?)['"]''')[0]
                getParams[name] = value

            url = 'http://c.brightcove.com/services/viewer/htmlFederated?' + urllib.urlencode(getParams)
            sts, data = self.getPage(url)
            if sts:
                data = self.cm.ph.getDataBeetwenMarkers(data, '"renditions":', ']', False)[1]
                try:
                    printDBG(data)
                    data = byteify(json.loads(data + ']'), '', True)
                    for item in data:
                        if item['videoCodec'] != 'H264':
                            continue
                        url = item['defaultURL']
                        if not self.cm.isValidUrl(url):
                            continue
                        name = '[mp4] bitrate: %s, %sx%s' % (item['encodingRate'], item['frameWidth'], item['frameHeight'])
                        mp4Tab.append({'name': name, 'url': url, 'bitrate': item['encodingRate']})

                        def __getLinkQuality(itemLink):
                            try:
                                return int(itemLink['bitrate'])
                            except Exception:
                                return 0
                        mp4Tab = CSelOneLink(mp4Tab, __getLinkQuality, 999999999).getSortedLinks()
                except Exception:
                    printExc()

        hlsUrl = 'http://c.brightcove.com/services/mobile/streaming/index/master.m3u8?videoId=' + videoId
        hlsTab = getDirectM3U8Playlist(hlsUrl, checkContent=True, sortWithMaxBitrate=999999999)
        for idx in range(len(hlsTab)):
            hlsTab[idx]['name'] = '[hls] ' + hlsTab[idx]['name'].replace('None', '').strip()

        urlTab.extend(mp4Tab)
        urlTab.extend(hlsTab)
        return urlTab
Пример #14
0
    def getLinksForVideo(self, Index=0, selItem=None):
        listLen = len(self.onet.currList)
        if listLen < Index and listLen > 0:
            printDBG(
                "ERROR getLinksForVideo - current list is to short len: %d, Index: %d"
                % (listLen, Index))
            return RetHost(RetHost.ERROR, value=[])

        if self.onet.currList[Index].name != 'playSelectedMovie':
            printDBG("ERROR getLinksForVideo - current item has wrong type")
            return RetHost(RetHost.ERROR, value=[])

        retlist = []
        videoID = self.onet.currList[Index].category

        subTrackTab, tab = self.onet.api.getVideoTab(
            self.onet.currList[Index].category, True)
        if config.plugins.iptvplayer.onetvodUseDF.value:
            maxRes = int(
                config.plugins.iptvplayer.onetvodDefaultformat.value) * 1.1
            tab = CSelOneLink(tab, _getLinkQuality, maxRes).getOneLink()

        for item in tab:
            if item[0] == vodonet.FORMAT:
                nameLink = "type: %s \t bitrate: %s" % (item[0], item[2])
                url = item[1].encode('utf-8')
                url = strwithmeta(url, {'external_sub_tracks': subTrackTab})
                retlist.append(CUrlItem(nameLink.encode('utf-8'), url, 0))

        return RetHost(RetHost.OK, value=retlist)
    def getLinksForVideo(self, Index=0, selItem=None):
        listLen = len(self.host.currList)
        if listLen < Index and listLen > 0:
            printDBG(
                "ERROR getLinksForVideo - current list is to short len: %d, Index: %d"
                % (listLen, Index))
            return RetHost(RetHost.ERROR, value=[])
        retlist = []
        if 'ekstraklasa.tv' in self.host.currList[Index].get('host', ''):
            tab = self.host.getLinks_ETV(self.host.currList[Index].get(
                'url', ''))
            if config.plugins.iptvplayer.ekstraklasa_usedf.value:
                maxRes = int(config.plugins.iptvplayer.
                             ekstraklasa_defaultformat.value) * 1.1

                def _getLinkQuality(itemLink):
                    return int(itemLink[2])

                tab = CSelOneLink(tab, _getLinkQuality, maxRes).getOneLink()

            for item in tab:
                if item[0] == Ekstraklasa.ETV_FORMAT:
                    nameLink = "type: %s \t bitrate: %s" % (item[0], item[2])
                    url = item[1]
                    retlist.append(
                        CUrlItem(nameLink.encode('utf-8'), url.encode('utf-8'),
                                 0))
        elif 'ekstraklasa.org' in self.host.currList[Index].get('host', ''):
            pass
        return RetHost(RetHost.OK, value=retlist)
Пример #16
0
    def getLinksForVideo(self, Index=0, selItem=None):
        listLen = len(self.host.currList)
        if listLen < Index and listLen > 0:
            print "ERROR getLinksForVideo - current list is to short len: %d, Index: %d" % (
                listLen, Index)
            return RetHost(RetHost.ERROR, value=[])

        selItem = self.host.currList[Index]
        if selItem['type'] != 'video':
            print "ERROR getLinksForVideo - current item has wrong type"
            return RetHost(RetHost.ERROR, value=[])

        retlist = []

        if None != selItem and 'url' in selItem and 1 < len(selItem['url']):
            tmpList = self.host.getVideoLinks(selItem['url'])
            if config.plugins.iptvplayer.wpUseDF.value:
                maxRes = int(config.plugins.iptvplayer.wpDefaultformat.value)
                tmpList = CSelOneLink(tmpList, _getLinkQuality,
                                      maxRes).getOneLink()

            for idx in range(len(tmpList)):
                retlist.append(
                    CUrlItem(tmpList[idx]['name'], tmpList[idx]['url'], 0))

        return RetHost(RetHost.OK, value=retlist)
Пример #17
0
    def getLinksForVideo(self, Index=0, selItem=None):
        listLen = len(self.host.currList)
        if listLen < Index and listLen > 0:
            printDBG(
                "ERROR getLinksForVideo - current list is to short len: %d, Index: %d"
                % (listLen, Index))
            return RetHost(RetHost.ERROR, value=[])
        retlist = []
        if 'ekstraklasa.tv' in self.host.currList[Index].get('host', ''):
            tab = self.host.getLinks_ETV(self.host.currList[Index].get(
                'url', ''))

            def __getLinkQuality(itemLink):
                return int(itemLink['bitrate'])

            maxRes = int(config.plugins.iptvplayer.ekstraklasa_defaultformat.
                         value) * 1.1
            tab = CSelOneLink(tab, __getLinkQuality, maxRes).getSortedLinks()
            printDBG(
                ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>. tab[%s]" %
                tab)
            if config.plugins.iptvplayer.ekstraklasa_usedf.value and len(tab):
                tab = [tab[0]]

            for item in tab:
                retlist.append(CUrlItem(item['name'], item['url'], 0))
        elif 'ekstraklasa.org' in self.host.currList[Index].get('host', ''):
            pass
        return RetHost(RetHost.OK, value=retlist)
Пример #18
0
    def getLinksForVideo(self, url):
        printDBG("Youtube.getLinksForVideo url[%s]" % url)
        ytformats = config.plugins.iptvplayer.ytformat.value
        maxRes = int(config.plugins.iptvplayer.ytDefaultformat.value) * 1.1
        dash = config.plugins.iptvplayer.ytShowDash.value

        if not url.startswith("http://") and not url.startswith("https://"):
            url = 'http://www.youtube.com/' + url
        tmpTab, dashTab = self.ytp.getDirectLinks(url,
                                                  ytformats,
                                                  dash,
                                                  dashSepareteList=True)

        def __getLinkQuality(itemLink):
            tab = itemLink['format'].split('x')
            return int(tab[0])

        tmpTab = CSelOneLink(tmpTab, __getLinkQuality, maxRes).getSortedLinks()
        if config.plugins.iptvplayer.ytUseDF.value and 0 < len(tmpTab):
            tmpTab = [tmpTab[0]]

        videoUrls = []
        for item in tmpTab:
            videoUrls.append({
                'name': item['format'] + ' | ' + item['ext'],
                'url': item['url']
            })
        for item in dashTab:
            videoUrls.append({
                'name':
                _("[dash] ") + item['format'] + ' | ' + item['ext'],
                'url':
                item['url']
            })
        return videoUrls
Пример #19
0
    def getVideoLink(self, cItem):
        printDBG("DjingComApi.getVideoLink")
        urlsTab = []
        hlsUrl = cItem.get('iptv_hls_url', '')
        printDBG("hlsUrl||||||||||||||||| " + hlsUrl)
        if hlsUrl != '':
            hlsUrl = strwithmeta(
                hlsUrl, {
                    'User-Agent': self.defaultParams['header']['User-Agent'],
                    'Referer': cItem['url']
                })
            try:
                urlsTab = getDirectM3U8Playlist(hlsUrl, checkContent=True)
            except:
                printExc()

            if not urlsTab:
                hlsUrl = "https://www" + hlsUrl[hlsUrl.find(".djing"):]
                urlsTab = getDirectM3U8Playlist(hlsUrl, checkContent=True)

        def __getLinkQuality(itemLink):
            try:
                return int(itemLink['bitrate'])
            except Exception:
                return 0

        return CSelOneLink(urlsTab, __getLinkQuality,
                           99999999).getSortedLinks()
Пример #20
0
    def getLinksForVideo(self, Index=0, selItem=None):
        listLen = len(self.host.currList)
        if listLen < Index and listLen > 0:
            printDBG(
                "ERROR getLinksForVideo - current list is to short len: %d, Index: %d"
                % (listLen, Index))
            return RetHost(RetHost.ERROR, value=[])

        if self.host.currList[Index]["type"] != 'video':
            printDBG("ERROR getLinksForVideo - current item has wrong type")
            return RetHost(RetHost.ERROR, value=[])

        urlsTab = self.host.getVideoUrl(self.host.currList[Index]["page"])
        if config.plugins.iptvplayer.ytUseDF.value:
            maxRes = int(config.plugins.iptvplayer.ytDefaultformat.value) * 1.1

            def __getLinkQuality(itemLink):
                tab = itemLink['name'].split('x')
                return int(tab[0])

            urlsTab = CSelOneLink(urlsTab, __getLinkQuality,
                                  maxRes).getOneLink()
        retlist = []
        for urlItem in urlsTab:
            retlist.append(CUrlItem(urlItem['name'], urlItem['url'], 0))

        return RetHost(RetHost.OK, value=retlist)
Пример #21
0
    def getLinksForVideo(self, cItem):
        urlsTab = []

        if 'url' in cItem and cItem['url'].startswith('rtmp://'):
            urlsTab = [{'name': 'rtmp', 'url': cItem['url'], 'need_resolve':0}]
        elif 'url' in cItem:
            urlsTab = getDirectM3U8Playlist(cItem['url'])
        else:
            url = 'http://mediaserwer3.christusvincit-tv.pl/api_v3/index.php?service=multirequest&apiVersion=3.1&expiry=86400&clientTag=kwidget%3Av2.41&format=1&ignoreNull=1&action=null&1:service=session&1:action=startWidgetSession&1:widgetId=_100&2:ks=%7B1%3Aresult%3Aks%7D&2:service=baseentry&2:action=list&2:filter:objectType=KalturaBaseEntryFilter&2:filter:redirectFromEntryId='
            url += cItem['f_id']
            url += '&3:ks=%7B1%3Aresult%3Aks%7D&3:contextDataParams:referrer=http%3A%2F%2Fmediaserwer3.christusvincit-tv.pl&3:contextDataParams:objectType=KalturaEntryContextDataParams&3:contextDataParams:flavorTags=all&3:contextDataParams:streamerType=auto&3:service=baseentry&3:entryId=%7B2%3Aresult%3Aobjects%3A0%3Aid%7D&3:action=getContextData&4:ks=%7B1%3Aresult%3Aks%7D&4:service=metadata_metadata&4:action=list&4:version=-1&4:filter:metadataObjectTypeEqual=1&4:filter:orderBy=%2BcreatedAt&4:filter:objectIdEqual=%7B2%3Aresult%3Aobjects%3A0%3Aid%7D&4:pager:pageSize=1&5:ks=%7B1%3Aresult%3Aks%7D&5:service=cuepoint_cuepoint&5:action=list&5:filter:objectType=KalturaCuePointFilter&5:filter:orderBy=%2BstartTime&5:filter:statusEqual=1&5:filter:entryIdEqual=%7B2%3Aresult%3Aobjects%3A0%3Aid%7D&kalsig=404d9c08e114ce91328cd739e5151b80'
            sts, data = self.getPage(url)
            if not sts:
                return []

            try:
                data = json_loads(data)
                baseUrl = data[1]['objects'][0]['dataUrl']
                for item in data[2]['flavorAssets']:
                    if item['fileExt'] != 'mp4' or not item['isWeb']:
                        continue
                    item['bitrate'] *= 1024
                    name = '%sx%s %s, bitrate: %s' % (item['width'], item['height'], formatBytes(item['size'] * 1024), item['bitrate'])
                    url = baseUrl.replace('/format/', '/flavorId/%s/format/' % item['id'])
                    urlsTab.append({'name': name, 'url': url, 'need_resolve': 0, 'bitrate': item['bitrate'], 'original': item['isOriginal']})
                urlsTab.sort(key=lambda x: x['bitrate'], reverse=True)
            except Exception:
                printExc()
        if len(urlsTab):
            max_bitrate = int(config.plugins.iptvplayer.christusvincit_preferred_bitrate.value)
            urlsTab = CSelOneLink(urlsTab, lambda x: int(x['bitrate']), max_bitrate).getSortedLinks()
            if config.plugins.iptvplayer.christusvincit_use_preferred_bitrate.value:
                urlsTab = [urlsTab[0]]
        return urlsTab
Пример #22
0
    def _getVideoUrls(self, vodData):
        urls = []
        re_compile_srcreq = re.compile('<srcreq ([^>]+?)>')
        max_bitrate = int(config.plugins.iptvplayer.iplaDefaultformat.value)

        def __getLinkQuality(itemLink):
            return int(itemLink['bitrate'])

        try:
            links = re_compile_srcreq.findall(vodData)
            for link in links:
                attrib = self.__getAttribs(link)
                drm = attrib['drmtype']
                if drm == '0':
                    if config.plugins.iptvplayer.ZablokujWMV.value and attrib[
                            'format'] == '0':
                        continue
                    name = "Jakość: %s\t format: %s\t  bitrate: %s" % (
                        attrib['quality'], attrib['format'], attrib['bitrate'])
                    urls.append({
                        'name': name,
                        'url': attrib['url'],
                        'bitrate': attrib['bitrate']
                    })
        except Exception:
            printExc()
        urls = CSelOneLink(urls, __getLinkQuality,
                           max_bitrate).getSortedLinks()
        if config.plugins.iptvplayer.iplaUseDF.value:
            urls = [urls[0]]
        return urls
Пример #23
0
    def getLinksForVideo(self, cItem):
        printDBG("TvGryPL.getLinksForVideo [%s]" % cItem)
        id = self.cm.ph.getSearchGroups(cItem["url"] + "_", "ID=([0-9]+?)[^0-9]", 1)[0]

        urlTab = []
        sts, data = self.cm.getPage("http://tvgry.pl/video/source.v2.asp?SC=TV&ID=%s&QL=SD" % id)
        if not sts:
            return urlTab
        data = re.compile('file="([^"]+?)"[^>]*?label="([^"]+?)"').findall(data)
        for item in data:
            q = ""
            if "_C/500_" in item[0] or "Mobile" in item[1]:
                q = "MOB"
            elif "_C/750_" in item[0] or "SD" in item[1]:
                q = "SD"
            elif "_C/1280_" in item[0] or "720p" in item[1]:
                q = "HD"
            # elif '_C/1920_' in item[0] or "1080p" in item[1]:
            #    q = 'FHD'
            if "" != q:
                urlTab.append(
                    {
                        "name": item[1],
                        "url": urlparser.decorateUrl(
                            item[0], {"Referer": "http://p.jwpcdn.com/6/12/jwplayer.flash.swf"}
                        ),
                        "q": q,
                    }
                )

        # for item in ['MOB', 'SD', 'HD']:
        # url = 'http://tvgry.pl/video/source.asp?SC=TV&ID=%s&QL=%s' % (id, item[:2])
        # sts,data = self.getPage(url)
        # if not sts: continue
        # url = self.cm.ph.getSearchGroups(data, 'file>(http[^<]+?)<', 1)[0]
        # if '' != url: urlTab.append({'name':item, 'url':url, 'q':item})

        if 1 < len(urlTab):
            map = {"MOB": 0, "SD": 1, "HD": 2, "FHD": 3}
            oneLink = CSelOneLink(
                urlTab, lambda x: map[x["q"]], map[config.plugins.iptvplayer.tvgrypl_default_quality.value]
            )
            if config.plugins.iptvplayer.tvgrypl_use_dq.value:
                urlTab = oneLink.getOneLink()
            else:
                urlTab = oneLink.getSortedLinks()
        return urlTab
Пример #24
0
def getF4MLinksWithMeta(manifestUrl, checkExt=True, cookieParams={}, sortWithMaxBitrate=-1):
    if checkExt and not manifestUrl.split('?')[0].endswith('.f4m'):
        return []

    cm = common()
    headerParams, postData = cm.getParamsFromUrlWithMeta(manifestUrl)
    headerParams.update(cookieParams)

    retPlaylists = []
    sts, data = cm.getPage(manifestUrl, headerParams, postData)
    if sts:
        liveStreamDetected = False
        if 'live' == CParsingHelper.getDataBeetwenMarkers('<streamType>', '</streamType>', False):
            liveStreamDetected = True

        tmp = cm.ph.getDataBeetwenMarkers(data, '<manifest', '</manifest>')[1]
        baseUrl = cm.ph.getDataBeetwenReMarkers(tmp, re.compile('<baseURL[^>]*?>'), re.compile('</baseURL>'), False)[1].strip()
        printDBG("|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| " + baseUrl)
        if baseUrl == '':
            baseUrl = manifestUrl
        tmp = cm.ph.getAllItemsBeetwenMarkers(tmp, '<media', '>')
        for item in tmp:
            link = cm.ph.getSearchGroups(item, '''href=['"]([^'^"]+)['"]''')[0]
            if link != '':
                link = urljoin(baseUrl, link)
            if cm.isValidUrl(link):
                try:
                    bitrate = int(cm.ph.getSearchGroups(item, '''bitrate=['"]([^'^"]+)['"]''')[0])
                except Exception:
                    bitrate = 0
                retPlaylists.append({'name': '[f4m/hds] bitrate[%s]' % bitrate, 'bitrate': bitrate, 'url': link})

        if 0 == len(retPlaylists):
            bitrates = re.compile('bitrate="([0-9]+?)"').findall(data)
            for item in bitrates:
                link = strwithmeta(manifestUrl, {'iptv_proto': 'f4m', 'iptv_bitrate': item})
                if liveStreamDetected:
                    link.meta['iptv_livestream'] = True
                try:
                    bitrate = int(item)
                except Exception:
                    bitrate = 0
                retPlaylists.append({'name': '[f4m/hds] bitrate[%s]' % item, 'bitrate': bitrate, 'url': link})

        if 0 == len(retPlaylists):
            link = strwithmeta(manifestUrl, {'iptv_proto': 'f4m'})
            if liveStreamDetected:
                link.meta['iptv_livestream'] = True
            retPlaylists.append({'name': '[f4m/hds]', 'bitrate': 0, 'url': link})

        if sortWithMaxBitrate > -1:
            def __getLinkQuality(itemLink):
                try:
                    return int(itemLink['bitrate'])
                except Exception:
                    printExc()
                    return 0
            retPlaylists = CSelOneLink(retPlaylists, __getLinkQuality, sortWithMaxBitrate).getSortedLinks()
    return retPlaylists
Пример #25
0
            def _getVideoLink(data, FORMATS):
                videoTab = []
                for item in data['formats']:
                    if item['mimeType'] in FORMATS.keys():
                        formatType = FORMATS[item['mimeType']].encode('utf-8')
                        format = self.REAL_FORMATS.get(formatType, '')
                        name = self.getFormatFromBitrate(
                            str(item['totalBitrate'])) + '\t ' + formatType
                        url = item['url'].encode('utf-8')
                        if 'm3u8' == formatType:
                            videoTab.extend(
                                getDirectM3U8Playlist(url,
                                                      checkExt=False,
                                                      variantCheck=False))
                        else:
                            meta = {'iptv_format': format}
                            if config.plugins.iptvplayer.tvpVodProxyEnable.value:
                                meta[
                                    'http_proxy'] = config.plugins.iptvplayer.proxyurl.value
                            videoTab.append({
                                'name':
                                name,
                                'bitrate':
                                str(item['totalBitrate']),
                                'url':
                                self.up.decorateUrl(url, meta)
                            })
                if 1 < len(videoTab):
                    max_bitrate = int(
                        config.plugins.iptvplayer.tvpVodDefaultformat.value)

                    def __getLinkQuality(itemLink):
                        if 'with' in itemLink and 'heigth' in itemLink:
                            bitrate = self.getBitrateFromFormat(
                                '%sx%s' %
                                (itemLink['with'], itemLink['heigth']))
                            if bitrate != 0: return bitrate
                        return int(itemLink['bitrate'])

                    oneLink = CSelOneLink(videoTab, __getLinkQuality,
                                          max_bitrate)
                    if config.plugins.iptvplayer.tvpVodUseDF.value:
                        videoTab = oneLink.getOneLink()
                    else:
                        videoTab = oneLink.getSortedLinks()
                return videoTab
Пример #26
0
    def getLinksForVideo(self, cItem):
        printDBG("TvGryPL.getLinksForVideo [%s]" % cItem)
        id = self.cm.ph.getSearchGroups(cItem['url'] + '_', 'ID=([0-9]+?)[^0-9]', 1)[0]

        urlTab = []
        for item in ['MOB', 'SD', 'HD']:
            url = 'http://tvgry.pl/video/source.asp?SC=TV&ID=%s&QL=%s' % (id, item[:2])
            sts,data = self.getPage(url)
            if not sts: continue
            url = self.cm.ph.getSearchGroups(data, 'file>(http[^<]+?)<', 1)[0]
            if '' != url: urlTab.append({'name':item, 'url':url, 'q':item})
            
        if 1 < len(urlTab):
            map = {'MOB':0, 'SD':1, 'HD':2}
            oneLink = CSelOneLink(urlTab, lambda x: map[x['q']], map[config.plugins.iptvplayer.tvgrypl_default_quality.value])
            if config.plugins.iptvplayer.tvgrypl_use_dq.value: urlTab = oneLink.getOneLink()
            else: urlTab = oneLink.getSortedLinks()
        return urlTab
Пример #27
0
 def getVideoLinks(self, videoUrl):
     printDBG("KissCartoonMe.getVideoLinks [%s]" % videoUrl)
     urlTab = []
     
     referer = strwithmeta(videoUrl).meta.get('Referer', videoUrl)
     params = dict(self.defaultParams)
     params['header'] = dict(params['header'] )
     params['header'] ['Referer'] = referer
     params['return_data'] = False
     
     try:
         sts, response = self.getPage(videoUrl, params)
         videoUrl = response.geturl()
         response.close()
     except Exception:
         printExc()
         return urlTab
     
     if 'kisscartoon' not in self.up.getDomain(videoUrl):
         return self.up.getVideoLinkExt(videoUrl)
     
     params.update({'return_data':True})
     sts, data = self.getPage(videoUrl, params) 
     if not sts: return urlTab
     
     try:
         data = byteify(json.loads(data))
         printDBG(data)
         for item in data['playlist'][0].get('sources', []):
             if 'mp4' not in item['type']: continue
             url = item['file']
             name = item['label']
             urlTab.append({'name':name, 'url':url, 'need_resolve':0})
         
         for item in data['playlist']:
             url = item.get('file', '')
             type = url.split('?', 1)[0].rsplit('.', 1)[-1].lower()
             if self.cm.isValidUrl(url):
                 if type == 'mp4':
                     name = item.get('label', 'mp4')
                     urlTab.append({'name':name, 'url':url, 'need_resolve':0})
                 else:
                     urlTab.extend(getDirectM3U8Playlist(url, checkContent=True))
     except Exception:
         printExc()
         
     if 0 < len(urlTab):
         max_bitrate = int(config.plugins.iptvplayer.kisscartoon_defaultformat.value)
         def __getLinkQuality( itemLink ):
             try:
                 return int(self.cm.ph.getSearchGroups('|'+itemLink['name']+'|', '[^0-9]([0-9]+?)[^0-9]')[0])
             except Exception: return 0
         urlTab = CSelOneLink(urlTab, __getLinkQuality, max_bitrate).getBestSortedList()
     return urlTab
Пример #28
0
    def getLinks(self, id):
        printDBG("TvnVod.getLinks cItem.id[%r]" % id)
        videoUrls = []

        url = self.baseUrl + '&type=episode&id=%s&limit=%d&page=1&sort=newest&m=%s' % (
            id, self.itemsPerPage, 'getItem')
        sts, data = self.cm.getPage(url)
        if sts:
            try:
                data = json.loads(data)
                if 'success' == data['status']:
                    data = data['item']
                    # videoTime = 0
                    # tmp = self._getJItemStr(data, 'run_time', '')
                    # if '' != tmp:
                    # tmp = tmp.split(":")
                    # videoTime = int(tmp[0])*60*60+int(tmp[1])*60+int(tmp[2])

                    plot = self._getJItemStr(data, 'lead', '')
                    printDBG("data:\n%s\n" % data)
                    videos = data['videos']['main']['video_content']
                    if None == videos:
                        SetIPTVPlayerLastHostError("DRM protection.")
                    else:
                        for video in videos:
                            url = self._getJItemStr(video, 'url', '')
                            if '' == url:
                                SetIPTVPlayerLastHostError("DRM protection.")
                            #    url = self._getJItemStr(video, 'src', '')
                            if '' != url:
                                qualityName = self._getJItemStr(
                                    video, 'profile_name', '')
                                videoUrls.append({
                                    'name': qualityName,
                                    'profile_name': qualityName,
                                    'url': url,
                                    'need_resolve': 1
                                })
                    if 1 < len(videoUrls):
                        max_bitrate = int(
                            config.plugins.iptvplayer.TVNDefaultformat.value)

                        def __getLinkQuality(itemLink):
                            return int(
                                TvnVod.QUALITIES_TABLE.get(
                                    itemLink['profile_name'], 9999))

                        videoUrls = CSelOneLink(videoUrls, __getLinkQuality,
                                                max_bitrate).getSortedLinks()
                        if config.plugins.iptvplayer.TVNUseDF.value:
                            videoUrls = [videoUrls[0]]
            except:
                printExc()
        return videoUrls
Пример #29
0
 def getLinks(self, id):
     printDBG("TvnVod.getLinks cItem.id[%r]" % id )
     videoUrls = []
     
     for pl in ['Panasonic', 'Samsung', 'Android2']:#, 'Android4']: #'Android', ''Samsung', 
         if pl in ['Android', 'Android2', 'Panasonic']:
             url = '&type=episode&id=%s&limit=%d&page=1&sort=newest&m=%s' % (id, self.itemsPerPage, 'getItem')
         else:
             url = 'm=getItem&id=%s&android23video=1&deviceType=Tablet&os=4.1.1&playlistType=&connectionType=WIFI&deviceScreenWidth=1920&deviceScreenHeight=1080&appVersion=3.3.4&manufacturer=unknown&model=androVMTablet' % id
         url = self.getBaseUrl(pl) + url
         
         sts, data = self.cm.getPage(url, { 'header': self.getHttpHeader(pl) })
         if not sts: continue
         try:
             data = json_loads(data)
             if 'success' == data['status']:
                 data = data['item']
                 # videoTime = 0
                 # tmp = self._getJItemStr(data, 'run_time', '')
                 # if '' != tmp:
                     # tmp = tmp.split(":")
                     # videoTime = int(tmp[0])*60*60+int(tmp[1])*60+int(tmp[2])
                  
                 plot = self._getJItemStr(data, 'lead', '')
                 printDBG("data:\n%s\n" % data)
                 videos = data['videos']['main']['video_content']
                 if None == videos:
                     SetIPTVPlayerLastHostError("DRM protection.")
                 else:
                     for video in videos:
                         url = self._getJItemStr(video, 'url', '')
                         if '' == url:
                             SetIPTVPlayerLastHostError("DRM protection.")
                         #    url = self._getJItemStr(video, 'src', '')
                         if '' != url:
                             url = strwithmeta(url, {'tvn_platform':pl})
                             qualityName = self._getJItemStr(video, 'profile_name', '')
                             videoUrls.append({'name':qualityName, 'profile_name':qualityName, 'url':url, 'need_resolve':1})
                 if  1 < len(videoUrls):
                     max_bitrate = int(config.plugins.iptvplayer.TVNDefaultformat.value)
                     def __getLinkQuality( itemLink ):
                         return int(TvnVod.QUALITIES_TABLE.get(itemLink['profile_name'], 9999))
                     videoUrls = CSelOneLink(videoUrls, __getLinkQuality, max_bitrate).getSortedLinks()
                     if config.plugins.iptvplayer.TVNUseDF.value:
                         videoUrls = [videoUrls[0]]
         except Exception: printExc()
         if len(videoUrls):
             break
     return videoUrls
Пример #30
0
 def getLinksForVideo(self, cItem):
     printDBG("ITV.getLinksForVideo [%s]" % cItem)
     
     retTab = []
     forwardedIP = self.getRandomGBIP()
     if cItem.get('is_live', False):
         if self.cacheLive == {}:
             sts, data = self.getPage('http://textuploader.com/dlr3q')
             if not sts: return []
             data = self.cleanHtmlStr(self.cm.ph.getDataBeetwenNodes(data, ('<code', '>'), ('</code', '>'), False)[1])
             try:
                 data = base64.b64decode(data)
                 printDBG(data)
                 self.cacheLive = byteify(json.loads(data), '', True)
             except Exception:
                 printExc()
         videoUrl = self.cacheLive.get(cItem['url'].split('/')[-1], '')
         if forwardedIP != '': videoUrl = strwithmeta(videoUrl, {'X-Forwarded-For':forwardedIP})
         retTab = getDirectM3U8Playlist(videoUrl, checkContent=True)
     else:
         params = dict(self.defaultParams)
         params['header'] = dict(params['header'])
         params['header']['User-Agent'] = self.MOBILE_USER_AGENT
         if forwardedIP != '': params['header']['X-Forwarded-For'] = forwardedIP
         
         sts, data = self.getPage(cItem['url'], params)
         if not sts: return []
         
         url   = self.cm.ph.getSearchGroups(data, '''data\-video\-id=['"]([^'^"]+?)['"]''')[0]
         hmac  = self.cm.ph.getSearchGroups(data, '''data\-video\-hmac=['"]([^'^"]+?)['"]''')[0]
         
         params['header'].update({'Content-Type':'application/json', 'Accept':'application/vnd.itv.vod.playlist.v2+json', 'Origin':self.getMainUrl(), 'Referer':cItem['url'], 'hmac':hmac})
         params['raw_post_data'] = True
         post_data = {"user":{"itvUserId":"","entitlements":[],"token":""},"device":{"manufacturer":"Apple","model":"iPhone","os":{"name":"iPad OS","version":"9.3","type":"ios"}},"client":{"version":"4.1","id":"browser"},"variantAvailability":{"featureset":{"min":["hls","aes"],"max":["hls","aes"]},"platformTag":"mobile"}}
         try:
             sts, data = self.getPage(url, params, json.dumps(post_data))
             if not sts: return []
             data = byteify(json.loads(data), '', True)['Playlist']['Video']
             videoUrl = data['Base'] + data['MediaFiles'][-1]['Href']
             retTab = getDirectM3U8Playlist(videoUrl, checkContent=True)
         except Exception:
             printExc()
     
     def __getLinkQuality( itemLink ):
         try: return int(itemLink['bitrate'])
         except Exception: return 0
     
     retTab = CSelOneLink(retTab, __getLinkQuality, 99999999).getSortedLinks()
     return retTab
Пример #31
0
 def getLinksForVideo(self, cItem):
     printDBG("UKTVPlay.getLinksForVideo [%s]" % cItem)
     
     retTab = []
     
     videoUrl = 'http://c.brightcove.com/services/mobile/streaming/index/master.m3u8?videoId=%s' % cItem['f_video_id']
     retTab = getDirectM3U8Playlist(videoUrl, checkContent=True)
     
     def __getLinkQuality( itemLink ):
         try: return int(itemLink['bitrate'])
         except Exception: return 0
     
     retTab = CSelOneLink(retTab, __getLinkQuality, 99999999).getSortedLinks()
     
     return retTab
Пример #32
0
 def getLinksForVideo(self, cItem):
     printDBG("Playpuls.getLinksForVideo [%s]" % cItem['url'])
     videoUrls =[]
     sts, data = self.cm.getPage(cItem['url'])
     if sts:
         data = self.cm.ph.getSearchGroups(data, "var source = '([^']+?)'")[0]
         data = 'http://redir.atmcdn.pl/hls/o2/pulstv/vod/' + data + '/hls/playlist.hls/playlist.m3u8'
         videoUrls = getDirectM3U8Playlist(data, checkExt=False)
         if 0 < len(videoUrls):
             max_bitrate = int(config.plugins.iptvplayer.playpuls_defaultformat.value)
             def __getLinkQuality( itemLink ):
                 return int(itemLink['bitrate'])
             videoUrls = CSelOneLink(videoUrls, __getLinkQuality, max_bitrate).getSortedLinks()
             if config.plugins.iptvplayer.playpuls_usedf.value:
                 videoUrls = [videoUrls[0]]            
     return videoUrls
Пример #33
0
    def getLinksForVideo(self, cItem):
        printDBG("VODPL.getLinksForVideo [%s]" % cItem)
        url = cItem['url']
        videoUrls = []
        tmpTab = []
        tries = 0
        while tries < 2:
            tries += 1
            sts, data = self.cm.getPage(url)
            if not sts:
                return videoUrls
            ckmId = self.cm.ph.getSearchGroups(data,
                                               'data-params-mvp="([^"]+?)"')[0]
            if '' == ckmId:
                ckmId = self.cm.ph.getSearchGroups(data,
                                                   'id="mvp:([^"]+?)"')[0]
            if '' != ckmId:
                tmpTab = self._getVideoTab(ckmId)
                break
            data = self.cm.ph.getDataBeetwenMarkers(data, 'pulsembed_embed',
                                                    '</div>')[1]
            url = self.cm.ph.getSearchGroups(data, 'href="([^"]+?)"')[0]

        tab = []
        for item in tmpTab:
            if item[0] == 'mp4':
                tab.append(item)

        def __getLinkQuality(itemLink):
            try:
                return int(itemLink[2])
            except Exception:
                return 0

        maxRes = int(
            config.plugins.iptvplayer.onetvodDefaultformat.value) * 1.1
        tab = CSelOneLink(tab, __getLinkQuality, maxRes).getSortedLinks()
        if config.plugins.iptvplayer.onetvodUseDF.value and len(tab) > 0:
            tab = [tab[0]]

        for item in tab:
            name = "type: %s \t bitrate: %s" % (item[0], item[2])
            url = item[1]
            videoUrls.append({'name': name, 'url': url, 'need_resolve': 0})

        return videoUrls
Пример #34
0
    def getLinksForVideo(self, cItem):
        printDBG("WpTV.getLinksForVideo [%s]" % cItem)
        urlTab = []

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

        vidId = self.cm.ph.getSearchGroups(data, 'data-mid="([^"]+?)"')[0]
        vidUrl = self.MAIN_URL + "player/mid,%s,embed.json" % vidId
        try:
            sts, data = self.cm.getPage(vidUrl, self.defaultParams)
            if not sts:
                return []

            tmpTab = []
            qMap = {"HQ": '2', "LQ": '1'}
            data = byteify(json.loads(data))
            for item in data['clip']['url']:
                if 'mp4' not in item['type']:
                    continue
                urlTab.append({
                    'name': item['quality'] + ' ' + item['type'],
                    'url': self.getFullUrl(item['url']),
                    'quality': qMap.get(item['quality'], '3'),
                    'need_resolve': 0
                })

            if 0 < len(urlTab):
                max_bitrate = int(
                    config.plugins.iptvplayer.wpDefaultformat.value)

                def __getLinkQuality(itemLink):
                    if 'mobile' in itemLink['name']:
                        return 0
                    return int(itemLink['quality'])

                urlTab = CSelOneLink(urlTab, __getLinkQuality,
                                     max_bitrate).getSortedLinks()
                if config.plugins.iptvplayer.wpUseDF.value:
                    urlTab = [urlTab[0]]
        except Exception:
            printExc()
        return urlTab
Пример #35
0
    def getLinksForVideo(self, cItem):
        printDBG('WRZUTA.getVideoLinks')
        videoUrls = self.up.getVideoLinkExt(cItem['url'])

        if 0 < len(videoUrls):
            max_bitrate = int(
                config.plugins.iptvplayer.wrzutaDefaultformat.value)

            def __getLinkQuality(itemLink):
                try:
                    value = self.cm.ph.getSearchGroups(itemLink['name'],
                                                       '[^0-9]([0-9]+?)p')[0]
                    return int(value)
                except:
                    printExc()
                    return 0

            videoUrls = CSelOneLink(videoUrls, __getLinkQuality,
                                    max_bitrate).getSortedLinks()
            if config.plugins.iptvplayer.wrzutaUseDF.value:
                videoUrls = [videoUrls[0]]
        for idx in range(len(videoUrls)):
            videoUrls[idx]['need_resolve'] = 0
        return videoUrls
Пример #36
0
 def getVideoLinks(self, videoUrl):
     printDBG("KissCartoonMe.getVideoLinks [%s]" % videoUrl)
     urlTab = []
     
     if 'kisscartoon' not in videoUrl:
         return self.up.getVideoLinkExt(videoUrl)
         
         
     sts, data = self.getPage(videoUrl) 
     if not sts: return urlTab
     
     tmpTab = self.cm.ph.getAllItemsBeetwenMarkers(data, 'asp.wrap(', ')', False)
     for tmp in tmpTab:
         tmp = tmp.strip()
         if tmp.startswith('"'):
             tmp = tmp[1:-1]
         else:
             tmp = self.cm.ph.getSearchGroups(data, '''var %s =[^'^"]*?["']([^"^']+?)["']''')[0]
         if tmp == '': continue
         try:
             tmp = base64.b64decode(tmp)
             tmp = self.cm.ph.getAllItemsBeetwenMarkers(tmp, '<a ', '</a>')
             for item in tmp:
                 url  = self.cm.ph.getSearchGroups(item, '''href="([^"]+?)"''')[0]
                 if 'googlevideo.com' not in url: continue
                 name = self.cleanHtmlStr(item)
                 urlTab.append({'name':name, 'url':url, 'need_resolve':0})
         except:
             printExc()
             continue
             
     def _decUrl(data):
         password = base64.b64decode('X1dyeExsM3JuQTQ4aWFmZ0N5Xw==')[1:-1]
         salt = base64.b64decode('X0NhcnRLUyQyMTQxI18=')[1:-1]
         iv = a2b_hex(base64.b64decode('X2E1ZThkMmU5YzE3MjFhZTBlODRhZDY2MGM0NzJjMWYzXw==')[1:-1])
         encrypted = base64.b64decode(data)
         iterations = 1000
         keySize = 16
         key = pbkdf2(password, salt, iterations, keySize)
         cipher = AES_CBC(key=key, keySize=16)
         return cipher.decrypt(encrypted, iv)
     
     tmpTab = self.cm.ph.getDataBeetwenMarkers(data, '<select id="selectQuality">', '</select>', False)[1]
     tmpTab = self.cm.ph.getAllItemsBeetwenMarkers(tmpTab, '<option', '</option>')
     for item in tmpTab:
         url  = self.cm.ph.getSearchGroups(item, '''value="([^"]+?)"''')[0]
         if '' == url: continue
         try:
             #printDBG(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> url[%s]" % url)
             url = _decUrl(url)
             #printDBG("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< url[%s]" % url)
         except:
             #printExc()
             continue
         if '://' not in url: continue
         name = self.cleanHtmlStr(item)
         urlTab.append({'name':name, 'url':url, 'need_resolve':0})
         
     if 0 < len(urlTab):
         max_bitrate = int(config.plugins.iptvplayer.kisscartoon_defaultformat.value)
         def __getLinkQuality( itemLink ):
             try:
                 return int(self.cm.ph.getSearchGroups('|'+itemLink['name']+'|', '[^0-9]([0-9]+?)[^0-9]')[0])
             except: return 0
         urlTab = CSelOneLink(urlTab, __getLinkQuality, max_bitrate).getBestSortedList()         
         
     data = self.cm.ph.getAllItemsBeetwenMarkers(data, '<iframe ', '>', withMarkers=True, caseSensitive=False)
     for item in data:
         url  = self.cm.ph.getSearchGroups(item, '''<iframe[^>]+?src=['"]([^'^"]+?)['"]''',  grupsNum=1, ignoreCase=True)[0]
         url = self._getFullUrl(url)
         if url.startswith('http') and 'facebook.com' not in url and 1 == self.up.checkHostSupport(url):
             urlTab.extend(self.up.getVideoLinkExt(url))
     return urlTab