✨ feat: update
Former-commit-id: 675e932431ea8000277a664896ba8f4c9fb80a94 Former-commit-id: 99dacc5ebe0dfe1c2ab4c0d5e9c7fc47aa586aab
This commit is contained in:
60
English_listen_gen/main.py
Normal file
60
English_listen_gen/main.py
Normal file
@ -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'<break time="{delay.group(1)}" />')
|
||||||
|
t = float(delay.group(1))
|
||||||
|
delay_text = ""
|
||||||
|
if t>5:
|
||||||
|
delay_text = '<break time="5s" />'*int(t//5)+f'<break time="{t%5}s" />'
|
||||||
|
else:
|
||||||
|
delay_text = f'<break time="{t}s" />'
|
||||||
|
if "</voice>" in rst[-1]:
|
||||||
|
rst[-1] = rst[-1].replace("</voice>",delay_text+'</voice>')
|
||||||
|
else:
|
||||||
|
rst.append(f'<voice name="zh-CN-YunfengNeural"><break time="{delay_text}s" /</voice>')
|
||||||
|
raise RuntimeWarning("Why there is a delay at the very beginning?")
|
||||||
|
continue
|
||||||
|
who, con = line.split(': ')
|
||||||
|
if who == "B":
|
||||||
|
fmt = f'<voice name="zh-CN-YunfengNeural"><prosody rate="-30%">{con}</prosody></voice>'
|
||||||
|
elif who == "W":
|
||||||
|
fmt = f'<voice name="en-US-JennyMultilingualNeural"><prosody rate="-5%" pitch="0%">{con}</prosody></voice>'
|
||||||
|
elif who == "M":
|
||||||
|
fmt = f'<voice name="en-US-EricNeural"><mstts:silence type="Sentenceboundary" value="100ms"/><prosody rate="10%" pitch="0%">{con}</prosody></voice>'
|
||||||
|
else:
|
||||||
|
raise AssertionError("Not a valid text format: {}->{}".format(who,con))
|
||||||
|
rst.append(fmt)
|
||||||
|
SSML_MODEL='''<speak xmlns="http://www.w3.org/2001/10/synthesis" xmlns:mstts="http://www.w3.org/2001/mstts" xmlns:emo="http://www.w3.org/2009/10/emotionml" version="1.0" xml:lang="en-US">{}</speak>'''
|
||||||
|
lines = rst
|
||||||
|
totLines = len(lines)
|
||||||
|
content = []
|
||||||
|
i = 0
|
||||||
|
while i < totLines:
|
||||||
|
tem = ""
|
||||||
|
while tem.count("<voice name=") < 49 and i < totLines:
|
||||||
|
tem += lines[i]
|
||||||
|
tem += "\n"
|
||||||
|
i += 1
|
||||||
|
# tem = escape(tem)
|
||||||
|
content.append(SSML_MODEL.format(tem))
|
||||||
|
return content
|
||||||
|
|
||||||
|
def syn(content:list[str]):
|
||||||
|
spe=SpeechConfig()
|
||||||
|
for i,con in enumerate(content):
|
||||||
|
opt_cfg=AudioOutputConfig(filename="%02d.mp3" % i)
|
||||||
|
print(SpeechSynthesizer(spe,opt_cfg,debug=True).speak_ssml(con))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
print(read("input.txt")[0])
|
||||||
|
syn(read("input.txt"))
|
85
down/down.py
Normal file
85
down/down.py
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
from re import search
|
||||||
|
from requests import get, post
|
||||||
|
from json import dumps
|
||||||
|
from urllib.parse import unquote
|
||||||
|
from base64 import b64decode
|
||||||
|
from subprocess import run
|
||||||
|
# from pandas import DataFrame
|
||||||
|
|
||||||
|
shareKey = [
|
||||||
|
"HQeA-W81Sh",
|
||||||
|
"HQeA-KW1Sh",
|
||||||
|
"HQeA-421Sh",
|
||||||
|
"HQeA-G21Sh"
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class Get123pan:
|
||||||
|
page = "https://www.123pan.com/s/{}"
|
||||||
|
share_get = "https://www.123pan.com/a/api/share/get?limit=100&next=1&orderBy=share_id&orderDirection=desc&shareKey={share}&ParentFileId={par}&Page=1"
|
||||||
|
down = "https://www.123pan.com/a/api/share/download/info"
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_page(shareKey:str):
|
||||||
|
res = get(Get123pan.page.format(shareKey))
|
||||||
|
res.raise_for_status()
|
||||||
|
t = res.text
|
||||||
|
fileId = search(r'(?<=\"FileId\"\:)\d{7}',t)
|
||||||
|
if fileId is None:
|
||||||
|
print("No `FileId` is found!")
|
||||||
|
print(t)
|
||||||
|
exit(1)
|
||||||
|
return int(fileId.group())
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_share(shareKey:str,fileId:int):
|
||||||
|
res = get(Get123pan.share_get.format(share=shareKey,par=str(fileId)))
|
||||||
|
res.raise_for_status()
|
||||||
|
json = res.json()
|
||||||
|
assert json['message'] == "ok" and json["code"] == 0
|
||||||
|
data = json["data"]["InfoList"][0]
|
||||||
|
data = {
|
||||||
|
"FileID": data["FileId"],
|
||||||
|
"S3keyFlag": data["S3KeyFlag"],
|
||||||
|
"Size": data["Size"],
|
||||||
|
"Etag": data["Etag"]
|
||||||
|
}
|
||||||
|
return data
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_url(data):
|
||||||
|
res = post(Get123pan.down,data=dumps(data))
|
||||||
|
res.raise_for_status()
|
||||||
|
json = res.json()
|
||||||
|
assert json['code'] == 0 and json["message"] == "success"
|
||||||
|
url = json["data"]["DownloadURL"]
|
||||||
|
url = search(r"(?<=params=).+",url)
|
||||||
|
assert url is not None
|
||||||
|
url = url.group()
|
||||||
|
url = b64decode(url).decode()
|
||||||
|
url = unquote(url)
|
||||||
|
return url
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get(shareKey:str):
|
||||||
|
fileId = Get123pan.get_page(shareKey)
|
||||||
|
data = Get123pan.get_share(shareKey,fileId)
|
||||||
|
down_body = {
|
||||||
|
"ShareKey": shareKey,
|
||||||
|
}
|
||||||
|
down_body.update(data)
|
||||||
|
# print(DataFrame(data=down_body))
|
||||||
|
return Get123pan.get_url(down_body)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
for key in shareKey:
|
||||||
|
url = Get123pan.get(key)
|
||||||
|
print("url: {}".format(url))
|
||||||
|
cmd = [
|
||||||
|
'aria2c.exe',
|
||||||
|
'-x8',
|
||||||
|
'-s8',
|
||||||
|
url
|
||||||
|
]
|
||||||
|
r=run(cmd)
|
||||||
|
print("aria2c finished with {}".format(r.returncode))
|
84
mult/main.py
Normal file
84
mult/main.py
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
from subprocess import Popen,PIPE
|
||||||
|
from os import listdir
|
||||||
|
from os.path import isdir
|
||||||
|
|
||||||
|
pool:dict[str,Popen] = dict()
|
||||||
|
names_code:list[str] = []
|
||||||
|
names_alt:list[str] = []
|
||||||
|
vid:list[str] = []
|
||||||
|
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))
|
84
mult/main_up.py
Normal file
84
mult/main_up.py
Normal file
@ -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))
|
@ -1,12 +1,13 @@
|
|||||||
import requests
|
import requests
|
||||||
from time import strftime
|
from time import strftime
|
||||||
from re import findall
|
from re import findall, sub
|
||||||
|
from hashlib import md5
|
||||||
|
|
||||||
HTML_FORMAT ='''
|
HTML_FORMAT ='''
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<titile>{title}</titile>
|
<title>{title}</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
@ -17,10 +18,13 @@ HTML_FORMAT ='''
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
def writefile(filename,text):
|
def writefile(filename,text):
|
||||||
|
filename = sub(r"""[\*\/\\\|\<\>\? \:\.\'\"\!]""", "", filename)
|
||||||
|
unique = md5(text.encode())
|
||||||
|
filename += "_"+unique.hexdigest()[:5]
|
||||||
filename+=".html"
|
filename+=".html"
|
||||||
print(filename)
|
print("Writing "+filename)
|
||||||
print("-=-=-=-=\n",text,"\n-=-=-=-=")
|
# print("-=-=-=-=\n",text,"\n-=-=-=-=")
|
||||||
with open(filename+'.html', 'w') as f:
|
with open(filename+'.html', 'w', encoding="utf-8") as f:
|
||||||
f.write(text)
|
f.write(text)
|
||||||
|
|
||||||
|
|
||||||
@ -45,9 +49,10 @@ def main():
|
|||||||
print(ret)
|
print(ret)
|
||||||
except:
|
except:
|
||||||
print(ret)
|
print(ret)
|
||||||
|
exit(1)
|
||||||
# replace "data-original" to "src" for showing in browser
|
# replace "data-original" to "src" for showing in browser
|
||||||
html=html.replace("data-original", "src")
|
html=html.replace("data-original", "src")
|
||||||
writefile(strftime("%Y%m%d-%H%M"),html)
|
writefile(f"{softID}",html)
|
||||||
else:
|
else:
|
||||||
print("is RAR")
|
print("is RAR")
|
||||||
rar=ret['rarPreviewInfo']
|
rar=ret['rarPreviewInfo']
|
||||||
@ -56,9 +61,12 @@ def main():
|
|||||||
title=file["SoftName"]
|
title=file["SoftName"]
|
||||||
# replace "data-original" to "src" for showing in browser
|
# replace "data-original" to "src" for showing in browser
|
||||||
# html=html.replace("data-original", "src")
|
# 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=[]
|
l=[]
|
||||||
for url in urls:
|
for url in urls:
|
||||||
|
if "jpg" in url:
|
||||||
|
l.append(f"<img src={url} />")
|
||||||
|
continue
|
||||||
page=requests.get(url,cookies=response.cookies)
|
page=requests.get(url,cookies=response.cookies)
|
||||||
if not page.status_code==200:
|
if not page.status_code==200:
|
||||||
print(page)
|
print(page)
|
||||||
@ -70,4 +78,5 @@ def main():
|
|||||||
writefile(title,format_html)
|
writefile(title,format_html)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
while True:
|
||||||
|
main()
|
||||||
|
Reference in New Issue
Block a user