From e8cf76ca95c7163c470b8a2aaf3e2ab8735aff9a Mon Sep 17 00:00:00 2001 From: haha114514 <47912037+haha114514@users.noreply.github.com> Date: Thu, 2 Feb 2023 04:15:02 +1100 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E9=83=A8=E5=88=86=E6=9C=BA?= =?UTF-8?q?=E5=99=A8=E4=B8=8A=E7=9B=B4=E6=8E=A5=E8=B0=83time.strtime?= =?UTF-8?q?=E4=BC=9A=E6=9C=89=E4=B8=AD=E6=96=87=E6=8A=A5=E9=94=99=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20(#272)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 解决部分机器上直接调time.strtime会有中文报错的问题 * Update download.py --- biliup/engine/download.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/biliup/engine/download.py b/biliup/engine/download.py index 7d0c2d0..68b18d1 100644 --- a/biliup/engine/download.py +++ b/biliup/engine/download.py @@ -70,10 +70,10 @@ class DownloadBase: '-i', self.raw_stream_url, *self.default_output_args, *self.opt_args, '-c', 'copy', '-f', self.suffix] if config.get('segment_time'): - args += ['-f', 'segment', f'{time.strftime(filename)} part-%03d.{self.suffix}'] + args += ['-f', 'segment', f'{(time.strftime(filename).encode("unicode-escape").decode()).encode().decode("unicode-escape")} part-%03d.{self.suffix}'] else: - args += [f'{time.strftime(filename)}.{self.suffix}.part'] - + args += [f'{(time.strftime(filename).encode("unicode-escape").decode()).encode().decode("unicode-escape")}.{self.suffix}'] + proc = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) try: with proc.stdout as stdout: @@ -178,8 +178,8 @@ def get_valid_filename(name): >>> get_valid_filename("{self.fname}%Y-%m-%dT%H_%M_%S") '{self.fname}%Y-%m-%dT%H_%M_%S' """ - #s = str(name).strip().replace(" ", "_") #因为有些人会在主播名中间加入空格,为了避免和录播完毕自动改名冲突,所以注销掉 - s = re.sub(r"(?u)[^-\w.%{}\[\]【】「」]", "", s) + #s = str(name).strip().replace(" ", "_") #因为有些人会在主播名中间加入空格,为了避免和录播完毕自动改名冲突,所以注释掉 + s = re.sub(r"(?u)[^-\w.%{}\[\]【】「」\s]", "", str(name)) if s in {"", ".", ".."}: raise RuntimeError("Could not derive file name from '%s'" % name) return s