Parcourir la source

更新 tencent_video_url 获取方法

罗俊辉 il y a 1 an
Parent
commit
efa93b2a10
1 fichiers modifiés avec 19 ajouts et 5 suppressions
  1. 19 5
      gongzhonghao/gongzhonghao_author/gongzhonghao_author.py

+ 19 - 5
gongzhonghao/gongzhonghao_author/gongzhonghao_author.py

@@ -121,11 +121,25 @@ class GongzhonghaoAuthor:
     @classmethod
     def get_tencent_video_url(cls, video_id):
         url = 'https://vv.video.qq.com/getinfo?vids=' + str(video_id) + '&platform=101001&charge=0&otype=json'
-        response = requests.get(url=url).text.replace('QZOutputJson=', '').replace('"};', '"}')
-        response = json.loads(response)
-        url = response['vl']['vi'][0]['ul']['ui'][0]['url']
-        fvkey = response['vl']['vi'][0]['fvkey']
-        video_url = url + str(video_id) + '.mp4?vkey=' + fvkey
+        headers = {
+            "Host": "h5vv.video.qq.com",
+            "xweb_xhr": "1",
+            "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36 MicroMessenger/6.8.0(0x16080000) NetType/WIFI MiniProgramEnv/Mac MacWechat/WMPF XWEB/30817",
+            "Content-Type": "application/x-www-form-urlencoded",
+            "Accept": "*/*",
+            "Sec-Fetch-Site": "cross-site",
+            "Sec-Fetch-Mode": "cors",
+            "Sec-Fetch-Dest": "empty",
+            "Referer": "https://servicewechat.com/wx5fcd817f3f80aece/3/page-frame.html",
+            "Accept-Language": "en"
+        }
+        response = requests.get(url, headers=headers)
+        result = json.loads(response.text.replace("QZOutputJson=", "")[:-1])
+        vl = result["vl"]['vi'][0]
+        key = vl['fvkey']
+        name = vl['fn']
+        folder = vl['ul']['ui'][0]['url']
+        video_url = folder + name + "?vkey=" + key
         return video_url
 
     @classmethod