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


Python VideoInfo.get_video_link方法代码示例

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


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

示例1: retrieveVideoInfo

# 需要导入模块: from common.DataObjects import VideoInfo [as 别名]
# 或者: from common.DataObjects.VideoInfo import get_video_link [as 别名]
def retrieveVideoInfo(video_id):
    
    video_info = VideoInfo()
    video_info.set_video_hosting_info(getVideoHostingInfo())
    video_info.set_video_id(video_id)
    try:
        video_info_link = 'http://embed.tune.pk/play/' + str(video_id) + '?autoplay=no'
        html = HttpUtils.HttpClient().getHtmlContent(url=video_info_link)
        image = re.compile("preview_img = '(.+?)';").findall(html)
        if image is not None and len(image) == 1:
            video_info.set_video_image(str(image[0]))
        html = html.replace('\n\r', '').replace('\r', '').replace('\n', '')
        sources = re.compile("{(.+?)}").findall(re.compile("sources:(.+?)]").findall(html)[0])
        for source in sources:
            video_link = str(re.compile('file[: ]*"(.+?)"').findall(source)[0])
            Logger.logDebug(video_link)
            label_text = re.compile('label[: ]*"(.+?)"').findall(source)
            if label_text is not None and len(label_text) == 1:
                label = str(label_text[0])
                Logger.logDebug(label)
                if label == '240p':
                    video_info.add_video_link(VIDEO_QUAL_LOW, video_link)
                elif label == '360p' and video_info.get_video_link(VIDEO_QUAL_SD) is None:
                    video_info.add_video_link(VIDEO_QUAL_SD, video_link)
                elif label == '480p' or label == 'SD':
                    video_info.add_video_link(VIDEO_QUAL_SD, video_link)
                elif label == '720p' or label == 'HD':
                    video_info.add_video_link(VIDEO_QUAL_HD_720, video_link)
                elif label == '1080p':
                    video_info.add_video_link(VIDEO_QUAL_HD_1080, video_link)
                else:
                    video_info.add_video_link(VIDEO_QUAL_SD, video_link)
                    
            else:
                video_info.add_video_link(VIDEO_QUAL_SD, video_link)
        video_info.set_video_stopped(False)
        
    except Exception, e:
        Logger.logError(e)
        video_info.set_video_stopped(True)
开发者ID:jigarsavla,项目名称:apple-tv2-xbmc,代码行数:42,代码来源:Tune_pk.py

示例2: retrieveVideoInfo

# 需要导入模块: from common.DataObjects import VideoInfo [as 别名]
# 或者: from common.DataObjects.VideoInfo import get_video_link [as 别名]
def retrieveVideoInfo(video_id):

    video_info = VideoInfo()
    video_info.set_video_hosting_info(getVideoHostingInfo())
    video_info.set_video_id(video_id)
    try:
        html = HttpUtils.HttpClient().getHtmlContent(url="https://docs.google.com/file/" + str(video_id) + "?pli=1")
        html = html.decode("utf8")
        title = re.compile("'title': '(.+?)'").findall(html)[0]
        video_info.set_video_name(title)
        stream_map = re.compile('fmt_stream_map":"(.+?)"').findall(html)[0].replace("\/", "/")
        formatArray = stream_map.split(",")
        for formatContent in formatArray:
            formatContentInfo = formatContent.split("|")
            qual = formatContentInfo[0]
            url = (formatContentInfo[1]).decode("unicode-escape")
            if qual == "13":  # 176x144
                video_info.add_video_link(VIDEO_QUAL_LOW, url)
            elif qual == "17":  # 176x144
                video_info.add_video_link(VIDEO_QUAL_LOW, url)
            elif qual == "36":  # 320x240
                video_info.add_video_link(VIDEO_QUAL_LOW, url)
            elif qual == "5":  # 400\\327226
                video_info.add_video_link(VIDEO_QUAL_LOW, url)
            elif qual == "34":  # 480x360 FLV
                video_info.add_video_link(VIDEO_QUAL_SD, url)
            elif qual == "6":  # 640\\327360 FLV
                video_info.add_video_link(VIDEO_QUAL_SD, url)
            elif qual == "35":  # 854\\327480 HD
                video_info.add_video_link(VIDEO_QUAL_SD, url)
            elif qual == "18":  # 480x360 MP4
                video_info.add_video_link(VIDEO_QUAL_SD, url)
            elif qual == "22":  # 1280x720 MP4
                video_info.add_video_link(VIDEO_QUAL_HD_720, url)
            elif qual == "37":  # 1920x1080 MP4
                video_info.add_video_link(VIDEO_QUAL_HD_1080, url)
            elif qual == "38" and video_info.get_video_link(VIDEO_QUAL_HD_1080) is None:  # 4096\\3272304 EPIC MP4
                video_info.add_video_link(VIDEO_QUAL_HD_1080, url)
            elif qual == "43" and video_info.get_video_link(VIDEO_QUAL_SD) is None:  # 360 WEBM
                video_info.add_video_link(VIDEO_QUAL_SD, url)
            elif qual == "44":  # 480 WEBM
                video_info.add_video_link(VIDEO_QUAL_SD, url)
            elif qual == "45" and video_info.get_video_link(VIDEO_QUAL_HD_720) is None:  # 720 WEBM
                video_info.add_video_link(VIDEO_QUAL_HD_720, url)
            elif qual == "46" and video_info.get_video_link(VIDEO_QUAL_HD_1080) is None:  # 1080 WEBM
                video_info.add_video_link(VIDEO_QUAL_HD_1080, url)
            elif qual == "120" and video_info.get_video_link(VIDEO_QUAL_HD_720) is None:  # New video qual
                video_info.add_video_link(VIDEO_QUAL_HD_720, url)
                # 3D streams - MP4
                # 240p -> 83
                # 360p -> 82
                # 520p -> 85
                # 720p -> 84
                # 3D streams - WebM
                # 360p -> 100
                # 360p -> 101
                # 720p -> 102
            else:  # unknown quality
                video_info.add_video_link(VIDEO_QUAL_SD, url)

            video_info.set_video_stopped(False)
    except Exception, e:
        logging.exception(e)
        video_info.set_video_stopped(True)
开发者ID:noba3,项目名称:KoTos,代码行数:66,代码来源:GoogleDocs.py

示例3: retrieveVideoInfo

# 需要导入模块: from common.DataObjects import VideoInfo [as 别名]
# 或者: from common.DataObjects.VideoInfo import get_video_link [as 别名]
def retrieveVideoInfo(video_id):
    
    video_info = VideoInfo()
    video_info.set_video_hosting_info(getVideoHostingInfo())
    video_info.set_video_id(video_id)
    try:
        video_info.set_video_image('http://i.ytimg.com/vi/' + video_id + '/default.jpg')
        html = HttpUtils.HttpClient().getHtmlContent(url='http://www.youtube.com/watch?v=' + video_id + '&fmt=18')
        stream_map = None
        html = html.replace('\\u0026', '&')
        match = re.compile('url_encoded_fmt_stream_map=(.+?)&').findall(html)
        
        if len(match) == 0:
            stream_map = (re.compile('url_encoded_fmt_stream_map": "(.+?)"').findall(html)[0]).replace('\\/', '/').split('url=')
        else:
            stream_map = urllib.unquote(match[0]).decode('utf8').split('url=')
        
        if re.search('status=fail', html):
            video_info.set_video_stopped(True)
            return video_info
        if stream_map == None:
            video_info.set_video_stopped(True)
            return video_info
            
        for attr in stream_map:
            if attr == '':
                continue
            parts = urllib.unquote(attr).decode('utf8').split('&qual')
            url = parts[0]
            qual = re.compile('&itag=(\d*)').findall(parts[1])[0]
            if(qual == '13'):#176x144
                video_info.add_video_link(VIDEO_QUAL_LOW, url)
            elif(qual == '17'):#176x144
                video_info.add_video_link(VIDEO_QUAL_LOW, url)
            elif(qual == '36'):#320x240
                video_info.add_video_link(VIDEO_QUAL_LOW, url)
            elif(qual == '5'):#400\\327226
                video_info.add_video_link(VIDEO_QUAL_LOW, url)
            elif(qual == '34'):#480x360 FLV
                video_info.add_video_link(VIDEO_QUAL_SD, url)
            elif(qual == '6'):#640\\327360 FLV
                video_info.add_video_link(VIDEO_QUAL_SD, url)
            elif(qual == '35'):#854\\327480 HD
                video_info.add_video_link(VIDEO_QUAL_SD, url)
            elif(qual == '18'):#480x360 MP4
                video_info.add_video_link(VIDEO_QUAL_SD, url)
            elif(qual == '22' and video_info.get_video_link(VIDEO_QUAL_HD_720) is None):#1280x720 MP4
                video_info.add_video_link(VIDEO_QUAL_HD_720, url)
            elif(qual == '37' and video_info.get_video_link(VIDEO_QUAL_HD_1080) is None):#1920x1080 MP4
                video_info.add_video_link(VIDEO_QUAL_HD_1080, url)
            elif(qual == '38'):#4096\\3272304 EPIC MP4
                video_info.add_video_link(VIDEO_QUAL_HD_1080, url)
            elif(qual == '43' and video_info.get_video_link(VIDEO_QUAL_SD) is None):#4096\\3272304 WEBM
                video_info.add_video_link(VIDEO_QUAL_SD, url)
            elif(qual == '44' and video_info.get_video_link(VIDEO_QUAL_HD_720) is None):#4096\\3272304 WEBM
                video_info.add_video_link(VIDEO_QUAL_HD_720, url)
            elif(qual == '45' and video_info.get_video_link(VIDEO_QUAL_HD_1080) is None):#4096\\3272304 WEBM
                video_info.add_video_link(VIDEO_QUAL_HD_1080, url)
            elif(qual == '120' and video_info.get_video_link(VIDEO_QUAL_HD_720) is None):#New video qual
                video_info.add_video_link(VIDEO_QUAL_HD_720, url)
            else:#unknown quality
                video_info.add_video_link(VIDEO_QUAL_SD, url)

            video_info.set_video_stopped(False)
    except:
        video_info.set_video_stopped(True)
    return video_info
开发者ID:iamfreetofly,项目名称:repository.iamfreetofly-xbmc-repaddon-bb,代码行数:69,代码来源:YouTube.py

示例4: retrieveVideoInfo

# 需要导入模块: from common.DataObjects import VideoInfo [as 别名]
# 或者: from common.DataObjects.VideoInfo import get_video_link [as 别名]
def retrieveVideoInfo(video_id):
    
    video_info = VideoInfo()
    video_info.set_video_hosting_info(getVideoHostingInfo())
    video_info.set_video_id(video_id)
    try:
        video_info.set_video_image('http://i.ytimg.com/vi/' + video_id + '/default.jpg')
        html = HttpUtils.HttpClient().getHtmlContent(url='http://www.youtube.com/get_video_info?video_id=' + video_id + '&asv=3&el=detailpage&hl=en_US')
        stream_map = None
        html = html.decode('utf8')
        html = html.replace('\n', '')
        html = html.replace('\r', '')
        html = html + '&'
        title = urllib.unquote_plus(re.compile('&title=(.+?)&').findall(html)[0]).replace('/\+/g', ' ')
        print title
        if re.search('status=fail', html):
            video_info.set_video_stopped(True)
            return video_info
        
        stream_info = re.compile('url_encoded_fmt_stream_map=(.+?)&').findall(html)
        stream_map = ''
        if(len(stream_info) == 0):
            stream_map = re.compile('fmt_stream_map": "(.+?)"').findall(html)[0].replace("\\/", "/")
        else:
            stream_map = stream_info[0]
            
        if stream_map == None:
            video_info.set_video_stopped(True)
            return video_info
        
        stream_map = urllib.unquote_plus(stream_map)

        
        formatArray = stream_map.split(',')
        for formatContent in formatArray:
            if formatContent == '':
                continue
            formatUrl = ""
            try:
                formatUrl = urllib.unquote(re.compile("url=([^&]+)").findall(formatContent)[0]) + "&title=" + urllib.quote_plus(title)   
            except:
                    print "Unexpected error"     
            if re.search("rtmpe", stream_map):
                try:
                    conn = urllib.unquote(re.compile("conn=([^&]+)").findall(formatContent)[0]);
                    host = re.compile("rtmpe:\/\/([^\/]+)").findall(conn)[0];
                    stream = re.compile("stream=([^&]+)").findall(formatContent)[0];
                    path = 'videoplayback';
                    
                    formatUrl = "-r %22rtmpe:\/\/" + host + "\/" + path + "%22 -V -a %22" + path + "%22 -f %22WIN 11,3,300,268%22 -W %22http:\/\/s.ytimg.com\/yt\/swfbin\/watch_as3-vfl7aCF1A.swf%22 -p %22http:\/\/www.youtube.com\/watch?v=" + video_id + "%22 -y %22" + urllib.unquote(stream) + "%22"
                except:
                    print "Unexpected error"
                
            if(formatUrl[0: 4] == "http" or formatUrl[0: 2] == "-r"):
                formatQual = re.compile("itag=([^&]+)").findall(formatContent)[0]
                if not re.search("signature=", formatUrl):
                    formatUrl += "&signature=" + re.compile("sig=([^&]+)").findall(formatContent)[0]
        
            qual = formatQual
            url = formatUrl
            if(qual == '13'):  # 176x144
                video_info.add_video_link(VIDEO_QUAL_LOW, url)
            elif(qual == '17'):  # 176x144
                video_info.add_video_link(VIDEO_QUAL_LOW, url)
            elif(qual == '36'):  # 320x240
                video_info.add_video_link(VIDEO_QUAL_LOW, url)
            elif(qual == '5'):  # 400\\327226
                video_info.add_video_link(VIDEO_QUAL_LOW, url)
            elif(qual == '34'):  # 480x360 FLV
                video_info.add_video_link(VIDEO_QUAL_SD, url)
            elif(qual == '6'):  # 640\\327360 FLV
                video_info.add_video_link(VIDEO_QUAL_SD, url)
            elif(qual == '35'):  # 854\\327480 HD
                video_info.add_video_link(VIDEO_QUAL_SD, url)
            elif(qual == '18'):  # 480x360 MP4
                video_info.add_video_link(VIDEO_QUAL_SD, url)
            elif(qual == '22'):  # 1280x720 MP4
                video_info.add_video_link(VIDEO_QUAL_HD_720, url)
            elif(qual == '37'):  # 1920x1080 MP4
                video_info.add_video_link(VIDEO_QUAL_HD_1080, url)
            elif(qual == '38' and video_info.get_video_link(VIDEO_QUAL_HD_1080) is None):  # 4096\\3272304 EPIC MP4
                video_info.add_video_link(VIDEO_QUAL_HD_1080, url)
            elif(qual == '43' and video_info.get_video_link(VIDEO_QUAL_SD) is None):  # 360 WEBM
                video_info.add_video_link(VIDEO_QUAL_SD, url)
            elif(qual == '44'):  # 480 WEBM
                video_info.add_video_link(VIDEO_QUAL_SD, url)
            elif(qual == '45' and video_info.get_video_link(VIDEO_QUAL_HD_720) is None):  # 720 WEBM
                video_info.add_video_link(VIDEO_QUAL_HD_720, url)
            elif(qual == '46' and video_info.get_video_link(VIDEO_QUAL_HD_1080) is None):  # 1080 WEBM
                video_info.add_video_link(VIDEO_QUAL_HD_1080, url)
            elif(qual == '120' and video_info.get_video_link(VIDEO_QUAL_HD_720) is None):  # New video qual
                video_info.add_video_link(VIDEO_QUAL_HD_720, url)
                # 3D streams - MP4
                # 240p -> 83
                # 360p -> 82
                # 520p -> 85
                # 720p -> 84
                # 3D streams - WebM
                # 360p -> 100
                # 360p -> 101
#.........这里部分代码省略.........
开发者ID:ak0ng,项目名称:dk-xbmc-repaddon-rep,代码行数:103,代码来源:YouTube.py


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