From 11b1f8ea6f0ad3cf708d7d4b44d77fc0905bff38 Mon Sep 17 00:00:00 2001 From: flt6 <1404262047@qq.com> Date: Sun, 12 Mar 2023 13:57:38 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20update?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: 675e932431ea8000277a664896ba8f4c9fb80a94 Former-commit-id: 99dacc5ebe0dfe1c2ab4c0d5e9c7fc47aa586aab --- English_listen_gen/main.py | 60 +++++++++++++++++++++++++++ down/down.py | 85 ++++++++++++++++++++++++++++++++++++++ mult/main.py | 84 +++++++++++++++++++++++++++++++++++++ mult/main_up.py | 84 +++++++++++++++++++++++++++++++++++++ zxxk_dl/main.py | 25 +++++++---- 5 files changed, 330 insertions(+), 8 deletions(-) create mode 100644 English_listen_gen/main.py create mode 100644 down/down.py create mode 100644 mult/main.py create mode 100644 mult/main_up.py diff --git a/English_listen_gen/main.py b/English_listen_gen/main.py new file mode 100644 index 0000000..21b4be9 --- /dev/null +++ b/English_listen_gen/main.py @@ -0,0 +1,60 @@ +from re import match +from mytts import SpeechConfig, AudioOutputConfig, SpeechSynthesizer +from html import escape +from rich import print + +def read(filename): + rst:list[str] = [] + with open(filename, 'r',encoding="utf-8") as f: + for line in f: + line = line.strip() + delay = match("\{delay\s([\d\.]+)\}",line) + if delay is not None: + # rst.append(f'') + t = float(delay.group(1)) + delay_text = "" + if t>5: + delay_text = ''*int(t//5)+f'' + else: + delay_text = f'' + if "" in rst[-1]: + rst[-1] = rst[-1].replace("",delay_text+'') + else: + rst.append(f'') + raise RuntimeWarning("Why there is a delay at the very beginning?") + continue + who, con = line.split(': ') + if who == "B": + fmt = f'{con}' + elif who == "W": + fmt = f'{con}' + elif who == "M": + fmt = f'{con}' + else: + raise AssertionError("Not a valid text format: {}->{}".format(who,con)) + rst.append(fmt) + SSML_MODEL='''{}''' + lines = rst + totLines = len(lines) + content = [] + i = 0 + while i < totLines: + tem = "" + while tem.count("3: + for name in names_code.copy(): # To avoid the infulence of names_code modification + if pool[name].poll() is not None: + ret = pool[name].poll() + print(ret) + if ret != 0: + print(f"'{name}' error") + elif pool[name].args[0] == "ffmpeg": + tmp = 'tmp_'+name + names_alt.append(tmp) + cmd = [ + "auto-editor", + "-mcut", + "1", + "-o", + "opt/"+name, + tmp + ] + pool.update({tmp:Popen(cmd,stderr=open(name+"_auto.log","w",encoding="utf-8"))}) + names_code.append(tmp) + elif pool[name].args[0] == "auto-editor": + print(f"'{name}' success") + pool.pop(name) + names_code.pop(names_code.index(name)) + +print(names_code,len(names_code),len(names_code)>0) +while len(names_code)>0: + for name in names_code.copy(): # To avoid the infulence of names_code modification + if pool[name].poll() is not None: + ret = pool[name].poll() + if ret != 0: + print(f"'{name}' error") + elif pool[name].args[0] == "ffmpeg": + tmp = 'tmp_'+name + names_alt.append(tmp) + cmd = [ + "auto-editor", + "-mcut", + "1", + "-o", + "opt/"+name, + tmp + ] + pool.update({tmp:Popen(cmd,stdout=open(name+"_auto.log","w",encoding="utf-8"))}) + names_code.append(tmp) + elif pool[name].args[0] == "auto-editor": + print(f"'{name}' success") + pool.pop(name) + names_code.pop(names_code.index(name)) \ No newline at end of file diff --git a/mult/main_up.py b/mult/main_up.py new file mode 100644 index 0000000..706c3ec --- /dev/null +++ b/mult/main_up.py @@ -0,0 +1,84 @@ +from subprocess import Popen,PIPE +from os import listdir +from os.path import isdir + +pool:dict = dict() +names_code:list = [] +names_alt:list = [] +vid:list = [] +paths = listdir() +while len(paths)!=0: + for path in paths: + paths.pop(paths.index(path)) + if isdir(path): + paths.extend([path+"/"+i for i in listdir(path)]) + if "tmp" in path: + continue + if path[-3:] in ["mp4", "flv"]: + vid.append(path) + +print(vid) +for path in vid: + names_code.append(path) + cmd = ['ffmpeg', + '-hwaccel', + 'cuda', + '-hwaccel_output_format', + 'cuda', + '-i', + path, + '-c:v', + 'h264_nvenc', + '-y', + 'tmp_'+path + ] + pool.update({path:Popen(cmd,stderr=open(path+"_ffmpeg.log","w",encoding="utf-8"))}) + while len(names_code)>3: + for name in names_code.copy(): # To avoid the infulence of names_code modification + if pool[name].poll() is not None: + ret = pool[name].poll() + print(ret) + if ret != 0: + print(f"'{name}' error") + elif pool[name].args[0] == "ffmpeg": + tmp = 'tmp_'+name + names_alt.append(tmp) + cmd = [ + "auto-editor", + "-mcut", + "1", + "-o", + "opt/"+name, + tmp + ] + pool.update({tmp:Popen(cmd,stderr=open(name+"_auto.log","w",encoding="utf-8"))}) + names_code.append(tmp) + elif pool[name].args[0] == "auto-editor": + print(f"'{name}' success") + pool.pop(name) + names_code.pop(names_code.index(name)) + +print(names_code,len(names_code),len(names_code)>0) +while len(names_code)>0: + for name in names_code.copy(): # To avoid the infulence of names_code modification + if pool[name].poll() is not None: + ret = pool[name].poll() + if ret != 0: + print(f"'{name}' error") + elif pool[name].args[0] == "ffmpeg": + tmp = 'tmp_'+name + names_alt.append(tmp) + cmd = [ + "auto-editor", + "-mcut", + "1", + "-o", + "opt/"+name, + tmp + ] + pool.update({tmp:Popen(cmd,stdout=open(name+"_auto.log","w",encoding="utf-8"))}) + names_code.append(tmp) + elif pool[name].args[0] == "auto-editor": + print(f"'{name}' success") + pool.pop(name) + names_code.pop(names_code.index(name)) \ No newline at end of file diff --git a/zxxk_dl/main.py b/zxxk_dl/main.py index 8d7c19b..32cc118 100644 --- a/zxxk_dl/main.py +++ b/zxxk_dl/main.py @@ -1,12 +1,13 @@ import requests from time import strftime -from re import findall +from re import findall, sub +from hashlib import md5 HTML_FORMAT =''' -{title} +{title} @@ -17,10 +18,13 @@ HTML_FORMAT =''' ''' def writefile(filename,text): + filename = sub(r"""[\*\/\\\|\<\>\? \:\.\'\"\!]""", "", filename) + unique = md5(text.encode()) + filename += "_"+unique.hexdigest()[:5] filename+=".html" - print(filename) - print("-=-=-=-=\n",text,"\n-=-=-=-=") - with open(filename+'.html', 'w') as f: + print("Writing "+filename) + # print("-=-=-=-=\n",text,"\n-=-=-=-=") + with open(filename+'.html', 'w', encoding="utf-8") as f: f.write(text) @@ -45,9 +49,10 @@ def main(): print(ret) except: print(ret) + exit(1) # replace "data-original" to "src" for showing in browser html=html.replace("data-original", "src") - writefile(strftime("%Y%m%d-%H%M"),html) + writefile(f"{softID}",html) else: print("is RAR") rar=ret['rarPreviewInfo'] @@ -56,9 +61,12 @@ def main(): title=file["SoftName"] # replace "data-original" to "src" for showing in browser # html=html.replace("data-original", "src") - urls=findall("(?<=data-original=\")https://preview.xkw.com/.+(?=\")",html) + urls=findall("(?<=data-original=\")https://preview.xkw.com/\\S+(?=\")",html) l=[] for url in urls: + if "jpg" in url: + l.append(f"") + continue page=requests.get(url,cookies=response.cookies) if not page.status_code==200: print(page) @@ -70,4 +78,5 @@ def main(): writefile(title,format_html) if __name__ == "__main__": - main() + while True: + main()