当前位置: 首页>>代码示例>>Python>>正文


Python CParsingHelper.getDataBeetwenReMarkers方法代码示例

本文整理汇总了Python中Plugins.Extensions.IPTVPlayer.libs.pCommon.CParsingHelper.getDataBeetwenReMarkers方法的典型用法代码示例。如果您正苦于以下问题:Python CParsingHelper.getDataBeetwenReMarkers方法的具体用法?Python CParsingHelper.getDataBeetwenReMarkers怎么用?Python CParsingHelper.getDataBeetwenReMarkers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Plugins.Extensions.IPTVPlayer.libs.pCommon.CParsingHelper的用法示例。


在下文中一共展示了CParsingHelper.getDataBeetwenReMarkers方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getFilmTab

# 需要导入模块: from Plugins.Extensions.IPTVPlayer.libs.pCommon import CParsingHelper [as 别名]
# 或者: from Plugins.Extensions.IPTVPlayer.libs.pCommon.CParsingHelper import getDataBeetwenReMarkers [as 别名]
 def getFilmTab(self, url, category, pager):
     sts, data = self.cm.getPage( url, {'header': self.HEADER } )
     if not sts: return 
     nextPage = re.search('<li><a href="/filmy?.+?" rel="next">&raquo;</a></li>', data)        
     data = CParsingHelper.getDataBeetwenMarkers(data, '<div class="row-fluid  movie-item">', '<div class="container">', False)[1]
     data = data.split('<div class="row-fluid  movie-item">')
     titleA = re.compile('<a class="title"[^>]+?>')
     titleB = re.compile('</small>')
     plotA  = re.compile('<p class="desc">')
     plotB  = re.compile('</div>')
     for item in data:
         title = CParsingHelper.getDataBeetwenReMarkers(item, titleA, titleB, False)[1]
         page  = self.MAINURL + CParsingHelper.getSearchGroups(item, 'class="title" href="([^"]+?)"', 1)[0]
         plot  = CParsingHelper.getDataBeetwenReMarkers(item, plotA, plotB, False)[1]
         img   = CParsingHelper.getSearchGroups(item, 'src="([^"]+?)"', 1)[0]
         if '' != title and '' != page:
             params = {'title': title, 'page': page, 'icon': img, 'plot': plot}
             self.addVideo(params)
     if nextPage:
         params = {'name': 'nextpage', 'category': category, 'title': 'Następna strona', 'page': str(int(pager) + 1)}
         self.addDir(params)
开发者ID:a4tech,项目名称:iptvplayer-for-e2,代码行数:23,代码来源:hostkinoman.py

示例2: getSearchResult

# 需要导入模块: from Plugins.Extensions.IPTVPlayer.libs.pCommon import CParsingHelper [as 别名]
# 或者: from Plugins.Extensions.IPTVPlayer.libs.pCommon.CParsingHelper import getDataBeetwenReMarkers [as 别名]
    def getSearchResult(self, baseUrl, cat, searchType):
        printDBG("getSearchResult for url[%s] searchType[%s]" % (baseUrl, searchType) )

        sts, data = self.cm.getPage( baseUrl )
        if False == sts:
            printDBG("getSearchResult problem")
            return
        
        if 'filmy' == searchType:
            marer1 = '<div class="results_title">[^<]*?Filmy:[^<]*?</div>'
            marer2 = '<div class="results_title">'
        else:
            marer1 = '<div class="results_title">[^<]*?Seriale:[^<]*?</div>'
            marer2 = '<div class="results_title">'
        
        sts, data = CParsingHelper.getDataBeetwenReMarkers(data, re.compile(marer1), re.compile(marer2), False)
        if False == sts:
            printDBG("getSearchResult problem no data beetween markers")
            return

        data = data.split('<div class="result box pl-round"')
        if len(data) > 1:
            del data[0]
            for item in data:
                item = item.replace('<br/>', '')
                # url & title
                match = re.search('<a href="([^"]+?)" class="en pl-white">([^<]+?)</a>', item)
                if match: 
                    url = self.MAINURL + match.group(1)
                    title = match.group(2).replace('\n', '').replace('\r', '').strip()
                else: continue
                # img
                match = re.search('<img src="([^"]+?)"', item)
                if match: img = match.group(1)
                else: img = ''
                # plot
                match = re.search('<p>([^<]+?)</p>', item)
                if match: plot = match.group(1)
                else: plot = ''
                
                params = { 'title': title, 'url': url, 'icon': img, 'plot': plot}
                if cat == '':
                    self.addVideo(params)
                else:
                    params['name']='category'
                    params['category']=cat 
                    self.addDir(params)
开发者ID:samsamsam-iptvplayer,项目名称:iptvplayer-for-e2,代码行数:49,代码来源:hostalekinotv.py

示例3: parseListBase

# 需要导入模块: from Plugins.Extensions.IPTVPlayer.libs.pCommon import CParsingHelper [as 别名]
# 或者: from Plugins.Extensions.IPTVPlayer.libs.pCommon.CParsingHelper import getDataBeetwenReMarkers [as 别名]
    def parseListBase(self, data, type='video'):
        printDBG("parseListBase----------------")
        urlPatterns = { 'video'    :    ['video'   , 'href="[ ]*?(/watch\?v=[^"]+?)"'            , ''], 
                        'channel'  :    ['category', 'href="(/[^"]+?)"'                     , ''],
                        'playlist' :    ['category', 'list=([^"]+?)"'                       , '/playlist?list='],
                        'movie'    :    ['video'   , 'data-context-item-id="([^"]+?)"'      , '/watch?v='],
                        'live'     :    ['video'   , 'href="(/watch\?v=[^"]+?)"'            , ''],
                        'tray'     :    ['video'   , 'data-video-id="([^"]+?)"'             , '/watch?v='], }
        currList = []
        for i in range(len(data)):
            #printDBG("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
            # get requaired params
            url   = urlPatterns[type][2] + self.getAttributes(urlPatterns[type][1], data[i])
            
            # get title
            title = '' #self.getAttributes('title="([^"]+?)"', data[i])
            if '' == title: title = self.getAttributes('data-context-item-title="([^"]+?)"', data[i])
            if '' == title: title = self.getAttributes('data-video-title="([^"]+?)"', data[i])
            if '' == title: sts,title = CParsingHelper.getDataBeetwenMarkers(data[i], '<h3 class="yt-lockup-title">', '</h3>', False) 
            if '' == title: sts,title = CParsingHelper.getDataBeetwenReMarkers(data[i], re.compile('<span [^>]*?class="title[^>]*?>'), re.compile('</span>'), False) 
            if '' == title: sts,title = CParsingHelper.getDataBeetwenReMarkers(data[i], re.compile('class="pl-video-title-link[^>]*?>'), re.compile('<'), False)
            
            if '' == title:
                titleMarker = self.cm.ph.getSearchGroups(data[i], '(<[^">]+?"yt-lockup-title[^"]*?"[^>]*?>)')[0]
                if '' != titleMarker:
                    tidx = titleMarker.find(' ')
                    if tidx > 0:
                        tmarker = titleMarker[1:tidx]
                        title = self.cm.ph.getDataBeetwenMarkers(data[i],  titleMarker, '</%s>' % tmarker)[1]
            
            if '' != title: title = CParsingHelper.removeDoubles(remove_html_markup(title, ' '), ' ')
                
            img   = self.getAttributes('data-thumb="([^"]+?\.jpg)"', data[i])
            if '' == img:  img = self.getAttributes('src="([^"]+?\.jpg)"', data[i])
            time  = self.getAttributes('data-context-item-time="([^"]+?)"', data[i])
            if '' == time: time  = self.getAttributes('class="video-time">([^<]+?)</span>', data[i])
            if '' == time: sts, time = CParsingHelper.getDataBeetwenReMarkers(data[i], re.compile('pl-video-time"[^>]*?>'), re.compile('<'), False)
            if '' == time: sts, time = CParsingHelper.getDataBeetwenReMarkers(data[i], re.compile('timestamp"[^>]*?>'), re.compile('<'), False)
            time = time.strip()
            # desc
            sts,desc  = CParsingHelper.getDataBeetwenReMarkers(data[i], re.compile('class="video-description[^>]+?>'), re.compile('</p>'), False)
            if '' == desc: sts,desc = CParsingHelper.getDataBeetwenReMarkers(data[i], re.compile('class="yt-lockup-description[^>]+?>'), re.compile('</div>'), False)
            desc = CParsingHelper.removeDoubles(remove_html_markup(desc, ' '), ' ')
            
            urlTmp = url.split(';')
            if len(urlTmp) > 0: url = urlTmp[0]
            if type == 'video': url = url.split('&')[0] 
                
            # printDBG('url   [%s] ' % url)
            # printDBG('title [%s] ' % title)
            # printDBG('img   [%s] ' % img)
            # printDBG('time  [%s] ' % time)
            # printDBG('desc  [%s] ' % desc)
            if title != '' and url != '' and img != '':
                correctUrlTab = [url, img]
                for i in range(len(correctUrlTab)):
                    if not correctUrlTab[i].startswith('http:') and not correctUrlTab[i].startswith('https:'):
                        if correctUrlTab[i].startswith("//"):
                            correctUrlTab[i] = 'http:' + correctUrlTab[i]
                        else:
                            correctUrlTab[i] = 'http://www.youtube.com' + correctUrlTab[i]
                    else:
                        if correctUrlTab[i].startswith('https:'):
                            correctUrlTab[i] = "http:" + correctUrlTab[i][6:]

                title = clean_html(title.decode("utf-8")).encode("utf-8")
                desc  = clean_html(desc.decode("utf-8")).encode("utf-8")
                params = {'type': urlPatterns[type][0], 'category': type, 'title': title, 'url': correctUrlTab[0], 'icon': correctUrlTab[1], 'time': time, 'desc': desc}
                currList.append(params)

        return currList
开发者ID:c0ns0le,项目名称:iptvplayer-for-e2-fork,代码行数:73,代码来源:youtubeparser.py


注:本文中的Plugins.Extensions.IPTVPlayer.libs.pCommon.CParsingHelper.getDataBeetwenReMarkers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。