ソースを参照

公众信号,获取腾讯视频链接修改

罗俊辉 1 年間 前
コミット
5035ce4c3b
1 ファイル変更30 行追加6 行削除
  1. 30 6
      gongzhongxinhao/gongzhongxinhao/gongzhongxinhao_author.py

+ 30 - 6
gongzhongxinhao/gongzhongxinhao/gongzhongxinhao_author.py

@@ -61,12 +61,36 @@ class GZXHAuthor:
             # 获取腾讯视频下载链接
 
     def get_tencent_video_url(self, 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
+        # 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
+        # return video_url
+        url = "https://h5vv.video.qq.com/getinfo?vid={}&platform=101001&charge=0&otype=json&defn=shd".format(
+            video_id
+        )
+        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
+        time.sleep(random.randint(1, 5))
         return video_url
 
     def get_video_url(self, article_url):