mirror of
https://github.com/soimort/you-get.git
synced 2025-02-02 16:24:00 +03:00
Feature: support download bilibili space favorite folder files
This commit is contained in:
parent
3a41c3d22c
commit
b554f9f9bc
@ -32,13 +32,13 @@ class Bilibili(VideoExtractor):
|
||||
SEC1 = '94aba54af9065f71de72f5508f1cd42e'
|
||||
SEC2 = '9b288147e5474dd2aa67085f716c560d'
|
||||
stream_types = [
|
||||
{'id': 'hdflv'},
|
||||
{'id': 'flv720'},
|
||||
{'id': 'flv'},
|
||||
{'id': 'hdmp4'},
|
||||
{'id': 'mp4'},
|
||||
{'id': 'live'},
|
||||
{'id': 'vc'}
|
||||
{'id': 'hdflv'},
|
||||
{'id': 'flv720'},
|
||||
{'id': 'flv'},
|
||||
{'id': 'hdmp4'},
|
||||
{'id': 'mp4'},
|
||||
{'id': 'live'},
|
||||
{'id': 'vc'}
|
||||
]
|
||||
fmt2qlt = dict(hdflv=4, flv=3, hdmp4=2, mp4=1)
|
||||
|
||||
@ -348,6 +348,36 @@ def parse_cid_playurl(xml):
|
||||
log.w(e)
|
||||
return [], 0
|
||||
|
||||
def download_video_from_favlist(url, **kwargs):
|
||||
# the url has format: https://space.bilibili.com/64169458/#/favlist?fid=1840028
|
||||
|
||||
m = re.search(r'space\.bilibili\.com/(\d+)/.*?fid=(\d+).*?', url)
|
||||
vmid = ""
|
||||
favid = ""
|
||||
if m is not None:
|
||||
vmid = m.group(1)
|
||||
favid = m.group(2)
|
||||
jsonresult = json.loads(get_content("https://api.bilibili.com/x/space/fav/arc?vmid={}&ps=300&fid={}&order=fav_time&tid=0&keyword=&pn=1&jsonp=jsonp".format(vmid, favid)))
|
||||
print(jsonresult)
|
||||
# log.wtf("Got files list for vmid" + vmid + " favid:" + favid)
|
||||
if jsonresult['code'] != 0:
|
||||
log.wtf("Fail to get the files of page " + jsonresult)
|
||||
sys.exit(2)
|
||||
|
||||
else:
|
||||
videos = jsonresult['data']['archives']
|
||||
videocount = len(videos)
|
||||
for i in range(videocount):
|
||||
videoid = videos[i]["aid"]
|
||||
videotitle = videos[i]["title"]
|
||||
videourl = "https://www.bilibili.com/video/av{}".format(videoid)
|
||||
print("Start downloading ", videotitle, " video ", videotitle)
|
||||
Bilibili().download_by_url(videourl, subtitle=videotitle, **kwargs)
|
||||
|
||||
else:
|
||||
log.wtf("Fail to parse the fav title" + url, "")
|
||||
|
||||
|
||||
def bilibili_download_playlist_by_url(url, **kwargs):
|
||||
url = url_locations([url])[0]
|
||||
kwargs['playlist'] = True
|
||||
@ -363,6 +393,9 @@ def bilibili_download_playlist_by_url(url, **kwargs):
|
||||
for ep_id in ep_ids:
|
||||
ep_url = '#'.join([base_url, ep_id])
|
||||
Bilibili().download_by_url(ep_url, **kwargs)
|
||||
elif 'favlist' in url:
|
||||
# this a fav list folder
|
||||
download_video_from_favlist(url, **kwargs)
|
||||
else:
|
||||
aid = re.search(r'av(\d+)', url).group(1)
|
||||
page_list = json.loads(get_content('http://www.bilibili.com/widget/getPageList?aid={}'.format(aid)))
|
||||
|
Loading…
Reference in New Issue
Block a user