[embed] add support for bilibili's embedded player

Sample embed: for http://www.bilibili.com/video/av5079467/:

  <embed
    height="415" width="544" quality="high"
    allowfullscreen="true" type="application/x-shockwave-flash"
    src="http://static.hdslb.com/miniloader.swf"
    flashvars="aid=5079467&page=1"
    pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash"
  ></embed>
This commit is contained in:
Zhiming Wang 2016-12-05 23:45:28 -05:00
parent 61d9bf124e
commit a6d3c13684
No known key found for this signature in database
GPG Key ID: BBD31D4D110044B8

View File

@ -2,6 +2,7 @@ __all__ = ['embed_download']
from ..common import * from ..common import *
from .bilibili import bilibili_download
from .iqiyi import iqiyi_download_by_vid from .iqiyi import iqiyi_download_by_vid
from .le import letvcloud_download_by_vu from .le import letvcloud_download_by_vu
from .netease import netease_download from .netease import netease_download
@ -42,6 +43,11 @@ netease_embed_patterns = [ '(http://\w+\.163\.com/movie/[^\'"]+)' ]
vimeo_embed_patters = [ 'player\.vimeo\.com/video/(\d+)' ] vimeo_embed_patters = [ 'player\.vimeo\.com/video/(\d+)' ]
"""
check the share button on http://www.bilibili.com/video/av5079467/
"""
bilibili_embed_patterns = [ 'static\.hdslb\.com/miniloader\.swf.*aid=(\d+)' ]
def embed_download(url, output_dir = '.', merge = True, info_only = False ,**kwargs): def embed_download(url, output_dir = '.', merge = True, info_only = False ,**kwargs):
content = get_content(url, headers=fake_headers) content = get_content(url, headers=fake_headers)
@ -78,6 +84,12 @@ def embed_download(url, output_dir = '.', merge = True, info_only = False ,**kwa
found = True found = True
vimeo_download_by_id(url, title=title, output_dir=output_dir, merge=merge, info_only=info_only) vimeo_download_by_id(url, title=title, output_dir=output_dir, merge=merge, info_only=info_only)
aids = matchall(content, bilibili_embed_patterns)
for aid in aids:
found = True
url = 'http://www.bilibili.com/video/av%s/' % aid
bilibili_download(url, output_dir=output_dir, merge=merge, info_only=info_only)
if not found: if not found:
raise NotImplementedError(url) raise NotImplementedError(url)