forked from xiyaowong/spiders
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqmgx.py
More file actions
30 lines (25 loc) · 984 Bytes
/
qmgx.py
File metadata and controls
30 lines (25 loc) · 984 Bytes
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
"""
全民搞笑 https://longxia.music.xiaomi.com/share/video/******
"""
import re
import requests
def get(url: str) -> dict:
"""
title、videoName、videos
"""
data = {}
vid = re.findall(r'video/(\d+)', url)
if vid:
api = 'https://longxia.music.xiaomi.com/api/share?contentType=video&contentId={}'.format(vid[0])
headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36'
}
rep = requests.get(api, headers=headers, timeout=5)
if rep.status_code == 200 and rep.json()['code'] == 200:
info = rep.json()['data']['videoInfo']['videoInfo']
data['title'] = data['videoName'] = info['desc']
data['videos'] = [info['url']]
return data
return {'msg': 'failed'}
if __name__ == "__main__":
print(get('https://longxia.music.xiaomi.com/share/video/6624743459453734912?sharerUserId'))