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.ua = None
|
||||||
self.referer = None
|
self.referer = None
|
||||||
self.danmaku = None
|
self.danmaku = None
|
||||||
|
self.lyrics = None
|
||||||
|
|
||||||
if args:
|
if args:
|
||||||
self.url = args[0]
|
self.url = args[0]
|
||||||
@ -238,9 +239,11 @@ class VideoExtractor():
|
|||||||
output_dir=kwargs['output_dir'],
|
output_dir=kwargs['output_dir'],
|
||||||
merge=kwargs['merge'],
|
merge=kwargs['merge'],
|
||||||
av=stream_id in self.dash_streams)
|
av=stream_id in self.dash_streams)
|
||||||
|
|
||||||
if 'caption' not in kwargs or not kwargs['caption']:
|
if 'caption' not in kwargs or not kwargs['caption']:
|
||||||
print('Skipping captions or danmaku.')
|
print('Skipping captions or danmaku.')
|
||||||
return
|
return
|
||||||
|
|
||||||
for lang in self.caption_tracks:
|
for lang in self.caption_tracks:
|
||||||
filename = '%s.%s.srt' % (get_filename(self.title), lang)
|
filename = '%s.%s.srt' % (get_filename(self.title), lang)
|
||||||
print('Saving %s ... ' % filename, end="", flush=True)
|
print('Saving %s ... ' % filename, end="", flush=True)
|
||||||
@ -249,12 +252,19 @@ class VideoExtractor():
|
|||||||
'w', encoding='utf-8') as x:
|
'w', encoding='utf-8') as x:
|
||||||
x.write(srt)
|
x.write(srt)
|
||||||
print('Done.')
|
print('Done.')
|
||||||
|
|
||||||
if self.danmaku is not None and not dry_run:
|
if self.danmaku is not None and not dry_run:
|
||||||
filename = '{}.cmt.xml'.format(get_filename(self.title))
|
filename = '{}.cmt.xml'.format(get_filename(self.title))
|
||||||
print('Downloading {} ...\n'.format(filename))
|
print('Downloading {} ...\n'.format(filename))
|
||||||
with open(os.path.join(kwargs['output_dir'], filename), 'w', encoding='utf8') as fp:
|
with open(os.path.join(kwargs['output_dir'], filename), 'w', encoding='utf8') as fp:
|
||||||
fp.write(self.danmaku)
|
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()
|
# For main_dev()
|
||||||
#download_urls(urls, self.title, self.streams[stream_id]['container'], self.streams[stream_id]['size'])
|
#download_urls(urls, self.title, self.streams[stream_id]['container'], self.streams[stream_id]['size'])
|
||||||
keep_obj = kwargs.get('keep_obj', False)
|
keep_obj = kwargs.get('keep_obj', False)
|
||||||
|
@ -399,8 +399,8 @@ class Bilibili(VideoExtractor):
|
|||||||
# set audio title
|
# set audio title
|
||||||
self.title = song_info['data']['title']
|
self.title = song_info['data']['title']
|
||||||
|
|
||||||
lyric = song_info['data']['lyric']
|
# get lyrics
|
||||||
# TODO: download lyrics
|
self.lyrics = get_content(song_info['data']['lyric'])
|
||||||
|
|
||||||
api_url = self.bilibili_audio_api(sid)
|
api_url = self.bilibili_audio_api(sid)
|
||||||
api_content = get_content(api_url, headers=self.bilibili_headers())
|
api_content = get_content(api_url, headers=self.bilibili_headers())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user