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


Python BaseVideo.ext方法代码示例

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


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

示例1: video_info

# 需要导入模块: from weboob.capabilities.video import BaseVideo [as 别名]
# 或者: from weboob.capabilities.video.BaseVideo import ext [as 别名]
def video_info(url):
    """Fetch info about a video using youtube-dl

    :param url: URL of the web page containing the video
    :rtype: :class:`weboob.capabilities.video.Video`
    """

    if not MediaPlayer._find_in_path(os.environ['PATH'], 'youtube-dl'):
        raise Exception('Please install youtube-dl')

    try:
        j = json.loads(subprocess.check_output(['youtube-dl', '-f', 'best', '-J', url]))
    except subprocess.CalledProcessError:
        return

    v = BaseVideo(id=url)
    v.title = j.get('title') or NotAvailable
    v.ext = j.get('ext') or NotAvailable
    v.description = j.get('description') or NotAvailable
    v.url = j['url']
    v.duration = j.get('duration') or NotAvailable
    v.author = j.get('uploader') or NotAvailable
    v.rating = j.get('average_rating') or NotAvailable

    if j.get('thumbnail'):
        v.thumbnail = Thumbnail(j['thumbnail'])

    d = j.get('upload_date', j.get('release_date'))
    if d:
        v.date = parse_date(d)

    return v
开发者ID:P4ncake,项目名称:weboob,代码行数:34,代码来源:ytdl.py

示例2: parse_movie

# 需要导入模块: from weboob.capabilities.video import BaseVideo [as 别名]
# 或者: from weboob.capabilities.video.BaseVideo import ext [as 别名]
    def parse_movie(self, movie):
        video = BaseVideo(u'%s#%s' % (movie['code'], 'movie'))
        video.title = unicode(movie['trailer']['name'])
        video._video_code = unicode(movie['trailer']['code'])
        video.ext = u'mp4'
        if 'poster' in movie:
            video.thumbnail = Thumbnail(movie['poster']['href'])
            video.thumbnail.url = unicode(movie['poster']['href'])
        tdate = movie['release']['releaseDate'].split('-')
        day = 1
        month = 1
        year = 1901
        if len(tdate) > 2:
            year = int(tdate[0])
            month = int(tdate[1])
            day = int(tdate[2])

        video.date = date(year, month, day)
        if 'userRating' in movie['statistics']:
            video.rating = movie['statistics']['userRating']
        elif 'pressRating' in movie['statistics']:
            video.rating = movie['statistics']['pressRating'] * 2
        video.rating_max = 5
        if 'synopsis' in movie:
            video.description = unicode(movie['synopsis'].replace('<p>', '').replace('</p>', ''))
        elif 'synopsisShort' in movie:
            video.description = unicode(movie['synopsisShort'].replace('<p>', '').replace('</p>', ''))
        if 'castingShort' in movie:
            if 'directors' in movie['castingShort']:
                video.author = unicode(movie['castingShort']['directors'])
        if 'runtime' in movie:
            video.duration = timedelta(seconds=int(movie['runtime']))
        return video
开发者ID:P4ncake,项目名称:weboob,代码行数:35,代码来源:browser.py

示例3: parse_movie

# 需要导入模块: from weboob.capabilities.video import BaseVideo [as 别名]
# 或者: from weboob.capabilities.video.BaseVideo import ext [as 别名]
    def parse_movie(self, movie):
        video = BaseVideo(u"%s#%s" % (movie["code"], "movie"))
        video.title = unicode(movie["trailer"]["name"])
        video._video_code = unicode(movie["trailer"]["code"])
        video.ext = u"mp4"
        if "poster" in movie:
            video.thumbnail = BaseImage(movie["poster"]["href"])
            video.thumbnail.url = unicode(movie["poster"]["href"])
        tdate = movie["release"]["releaseDate"].split("-")
        day = 1
        month = 1
        year = 1901
        if len(tdate) > 2:
            year = int(tdate[0])
            month = int(tdate[1])
            day = int(tdate[2])

        video.date = date(year, month, day)
        if "userRating" in movie["statistics"]:
            video.rating = movie["statistics"]["userRating"]
        elif "pressRating" in movie["statistics"]:
            video.rating = movie["statistics"]["pressRating"] * 2
        video.rating_max = 5
        if "synopsis" in movie:
            video.description = unicode(movie["synopsis"].replace("<p>", "").replace("</p>", ""))
        elif "synopsisShort" in movie:
            video.description = unicode(movie["synopsisShort"].replace("<p>", "").replace("</p>", ""))
        if "castingShort" in movie:
            if "directors" in movie["castingShort"]:
                video.author = unicode(movie["castingShort"]["directors"])
        if "runtime" in movie:
            video.duration = timedelta(seconds=int(movie["runtime"]))
        return video
开发者ID:kyrre,项目名称:weboob,代码行数:35,代码来源:browser.py

示例4: parse_video

# 需要导入模块: from weboob.capabilities.video import BaseVideo [as 别名]
# 或者: from weboob.capabilities.video.BaseVideo import ext [as 别名]
 def parse_video(self, _video, category):
     video = BaseVideo(u'%s#%s' % (_video['code'], category))
     video.title = unicode(_video['title'])
     video._video_code = unicode(_video['code'])
     video.ext = u'mp4'
     if 'runtime' in _video:
         video.duration = timedelta(seconds=int(_video['runtime']))
     if 'description' in _video:
         video.description = unicode(_video['description'])
     renditions = sorted(_video['rendition'], key=lambda x: 'bandwidth' in x and x['bandwidth']['code'], reverse=True)
     video.url = unicode(max(renditions, key=lambda x: 'bandwidth' in x)['href'])
     return video
开发者ID:sputnick-dev,项目名称:weboob,代码行数:14,代码来源:browser.py

示例5: parse_video

# 需要导入模块: from weboob.capabilities.video import BaseVideo [as 别名]
# 或者: from weboob.capabilities.video.BaseVideo import ext [as 别名]
 def parse_video(self, _video, category):
     video = BaseVideo(u"%s#%s" % (_video["code"], category))
     video.title = unicode(_video["title"])
     video._video_code = unicode(_video["code"])
     video.ext = u"mp4"
     if "runtime" in _video:
         video.duration = timedelta(seconds=int(_video["runtime"]))
     if "description" in _video:
         video.description = unicode(_video["description"])
     renditions = sorted(
         _video["rendition"], key=lambda x: "bandwidth" in x and x["bandwidth"]["code"], reverse=True
     )
     video.url = unicode(max(renditions, key=lambda x: "bandwidth" in x)["href"])
     return video
开发者ID:kyrre,项目名称:weboob,代码行数:16,代码来源:browser.py

示例6: get_video

# 需要导入模块: from weboob.capabilities.video import BaseVideo [as 别名]
# 或者: from weboob.capabilities.video.BaseVideo import ext [as 别名]
    def get_video(self, _id, video=None):
        if not video:
            video = BaseVideo(_id)

        new_video = video_info(_id)

        if not new_video:
            return

        video.ext = u'm3u8'

        for k, v in new_video.iter_fields():
            if not empty(v) and empty(getattr(video, k)):
                setattr(video, k, v)

        return video
开发者ID:laurentb,项目名称:weboob,代码行数:18,代码来源:module.py


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