mirror of
https://github.com/soimort/you-get.git
synced 2025-03-13 03:17:44 +03:00
[bilibili] support audio lyrics
This commit is contained in:
parent
11184c2552
commit
96a25273a1
@ -34,6 +34,7 @@ class VideoExtractor():
|
||||
self.ua = None
|
||||
self.referer = None
|
||||
self.danmaku = None
|
||||
self.lyrics = None
|
||||
|
||||
if args:
|
||||
self.url = args[0]
|
||||
@ -238,9 +239,11 @@ class VideoExtractor():
|
||||
output_dir=kwargs['output_dir'],
|
||||
merge=kwargs['merge'],
|
||||
av=stream_id in self.dash_streams)
|
||||
|
||||
if 'caption' not in kwargs or not kwargs['caption']:
|
||||
print('Skipping captions or danmaku.')
|
||||
return
|
||||
|
||||
for lang in self.caption_tracks:
|
||||
filename = '%s.%s.srt' % (get_filename(self.title), lang)
|
||||
print('Saving %s ... ' % filename, end="", flush=True)
|
||||
@ -249,12 +252,19 @@ class VideoExtractor():
|
||||
'w', encoding='utf-8') as x:
|
||||
x.write(srt)
|
||||
print('Done.')
|
||||
|
||||
if self.danmaku is not None and not dry_run:
|
||||
filename = '{}.cmt.xml'.format(get_filename(self.title))
|
||||
print('Downloading {} ...\n'.format(filename))
|
||||
with open(os.path.join(kwargs['output_dir'], filename), 'w', encoding='utf8') as fp:
|
||||
fp.write(self.danmaku)
|
||||
|
||||
if self.lyrics is not None and not dry_run:
|
||||
filename = '{}.lrc'.format(get_filename(self.title))
|
||||
print('Downloading {} ...\n'.format(filename))
|
||||
with open(os.path.join(kwargs['output_dir'], filename), 'w', encoding='utf8') as fp:
|
||||
fp.write(self.lyrics)
|
||||
|
||||
# For main_dev()
|
||||
#download_urls(urls, self.title, self.streams[stream_id]['container'], self.streams[stream_id]['size'])
|
||||
keep_obj = kwargs.get('keep_obj', False)
|
||||
|
@ -399,8 +399,8 @@ class Bilibili(VideoExtractor):
|
||||
# set audio title
|
||||
self.title = song_info['data']['title']
|
||||
|
||||
lyric = song_info['data']['lyric']
|
||||
# TODO: download lyrics
|
||||
# get lyrics
|
||||
self.lyrics = get_content(song_info['data']['lyric'])
|
||||
|
||||
api_url = self.bilibili_audio_api(sid)
|
||||
api_content = get_content(api_url, headers=self.bilibili_headers())
|
||||
|
Loading…
x
Reference in New Issue
Block a user