This repository was archived by the owner on Apr 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 203
Expand file tree
/
Copy pathzuiyou_voice.py
More file actions
60 lines (51 loc) · 1.78 KB
/
zuiyou_voice.py
File metadata and controls
60 lines (51 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import json
from urllib.parse import urlparse
import requests
def get(url: str) -> dict:
"""
text、audios
"""
data = {}
headers = {
"Connection": "keep-alive",
"Content-Length": "209",
"Content-Type": "text/plain;charset=UTF-8",
"Host": "share.izuiyou.com",
"Origin": "https://share.izuiyou.com",
"Referer": url,
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-origin",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36"
}
post_url = "https://share.izuiyou.com/api/review/share_review"
path = urlparse(url).path
temp = path.split("/")
pid = temp[-2]
rid = temp[-1]
payload = {
"h_av": "3.0",
"h_dt": 9,
"h_nt": 9,
"h_ch": "web_app",
"ua":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36",
"pid": f"{pid}",
"rid": f"{rid}"
}
play_host = "http://tbvideo.ixiaochuan.cn/"
with requests.post(post_url, data=json.dumps(payload), headers=headers, timeout=10) as rep:
if rep.status_code == 200:
try:
audio_info = rep.json().get("data").get("review").get("audio")
voice_text = audio_info.get("voice_text")
# uri = audio_info.get("uri")
org_uri = audio_info.get("org_uri")
data["text"] = voice_text
data["audios"] = [play_host + org_uri]
except (TypeError, AttributeError):
data["msg"] = "获取失败"
else:
data["msg"] = "获取失败"
return data
if __name__ == "__main__":
print(get(input("url: ")))