From 87bbc496fc956ccbfa81b6a46f0f390a530c850c Mon Sep 17 00:00:00 2001 From: svhero658 Date: Sat, 27 Jan 2018 00:47:05 +0800 Subject: [PATCH] Fixed bilibili title extract --- .gitignore | 1 + src/you_get/extractor.py | 4 ++++ src/you_get/extractors/bilibili.py | 4 ++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 0888e5ab..8b415b37 100644 --- a/.gitignore +++ b/.gitignore @@ -83,3 +83,4 @@ _* /.idea *.m4a *.DS_Store +.vscode diff --git a/src/you_get/extractor.py b/src/you_get/extractor.py index 4c9ccaa5..4335dcf1 100644 --- a/src/you_get/extractor.py +++ b/src/you_get/extractor.py @@ -4,7 +4,9 @@ from .common import match1, maybe_print, download_urls, get_filename, parse_host from .common import print_more_compatible as print from .util import log from . import json_output +from subprocess import DEVNULL import os +import subprocess class Extractor(): def __init__(self, *args): @@ -242,6 +244,8 @@ class VideoExtractor(): print('Downloading {} ...\n'.format(filename)) with open(os.path.join(kwargs['output_dir'], filename), 'w', encoding='utf8') as fp: fp.write(self.danmuku) + output = get_filename(self.title) + subprocess.check_call(['danmaku2ass', '-o', output + '.ass', '-s', '1920x1080', '-fn', 'MS PGothic', '-fs', '48', '-a', '0.8', '-dm', '15', '-ds', '10', output + '.cmt.xml'], stdin=DEVNULL); # For main_dev() #download_urls(urls, self.title, self.streams[stream_id]['container'], self.streams[stream_id]['size']) diff --git a/src/you_get/extractors/bilibili.py b/src/you_get/extractors/bilibili.py index 1ec41203..cf5a16f0 100644 --- a/src/you_get/extractors/bilibili.py +++ b/src/you_get/extractors/bilibili.py @@ -125,7 +125,7 @@ class Bilibili(VideoExtractor): self.referer = self.url self.page = get_content(self.url) - m = re.search(r'(.*?)', self.page) + m = re.search(r'(?:)?[\n ]*(.*?)[\n ]*', self.page, flags=re.DOTALL) if m is not None: self.title = m.group(1) if self.title is None: @@ -135,7 +135,7 @@ class Bilibili(VideoExtractor): if 'subtitle' in kwargs: subtitle = kwargs['subtitle'] self.title = '{} {}'.format(self.title, subtitle) - + if 'bangumi.bilibili.com/movie' in self.url: self.movie_entry(**kwargs) elif 'bangumi.bilibili.com' in self.url: