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 pathxinpianchang.py
More file actions
50 lines (39 loc) · 1.41 KB
/
xinpianchang.py
File metadata and controls
50 lines (39 loc) · 1.41 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
import re
import requests
def get(url: str) -> dict:
"""
title、imgs、videos(画质不同)
"""
data = {}
headers = {
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36"
}
session = requests.Session()
rep = session.get(url, headers=headers, timeout=10)
if rep.status_code != 200:
return {"msg": "获取失败"}
try:
vid = re.findall(r'vid: "(.*?)",', rep.text)[0]
except IndexError:
return {"msg": "获取失败"}
video_info_url = "http://openapi-vtom.vmovier.com/v3/video/{vid}?expand=resource".format(
vid=vid)
rep = session.get(video_info_url, headers=headers, timeout=10)
if rep.status_code != 200 or rep.json()["status"] != 0:
return {"msg": "获取失败"}
video_data = rep.json()["data"]
title = video_data["video"]["title"]
cover = video_data["video"]["cover"]
video_list = video_data["resource"]["progressive"] # type: list
# videos = []
# for item in video_list:
# videos.append(item.get("https_url") or item.get("url"))
video = video_list[0].get("https_url") or video_list[0].get("url")
data["title"] = title
data["imgs"] = [cover]
data["videos"] = [video]
return data
if __name__ == "__main__":
# url = "https://www.xinpianchang.com/a10628284"
url = input("url: ")
print(get(url))