vqq.py 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # File : vqq.py
  4. # Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------
  5. # Date : 2022/10/24
  6. import requests
  7. import re
  8. time_out = 2
  9. cookie = """
  10. pgv_pvid=5805499462; iip=0; RK=yQaYRyNLbG; ptcz=2a0d041daba2e1e3872184cd999e01bf90678c0e492c5900527c802251d224ad; tvfe_boss_uuid=53b5e88a3ebeba2c; video_platform=2; _tc_unionid=78fa72d7-2485-49f5-abf3-e72f7122cbb5; pgv_pvi=1381712896; logTrackKey=613d40c3fea04aafb45fc9642dd67b99; main_login=qq; vqq_appid=101483052; vqq_openid=406CA2296D6A3B970597D6CF1605B6B7; vqq_vuserid=1260982452; pgv_info=ssid=s1368217315; pac_uid=1_434857005; vversion_name=8.2.95; video_omgid=3419ca23530808d22bb278e881e46647; _qpsvr_localtk=0.710205836458567; vqq_access_token=88AEE1A8BC32318537BC7D81586E44A4; vqq_refresh_token=2D85975A29FB056EB6F9A338CB8F1EF5; o_cookie=434857005; video_guid=3419ca23530808d22bb278e881e46647; video_bucketid=4; fqm_pvqid=0a2a19f9-b09d-48d2-835a-cee916bdb63f; fqm_sessionid=a2c625f7-98e9-4d69-adb4-ad82846832bc; uin=o0434857005; skey=@rZMv3mYSR; vqq_vusession=Xd5bba2m9ByWls30Vi2FSQ.N; vqq_next_refresh_time=6530; vqq_login_time_init=1666665341; login_time_last=2022-10-25 10:35:44
  11. """.strip()
  12. login_token = """
  13. vqq_appid=101483052; vqq_openid=406CA2296D6A3B970597D6CF1605B6B7; vqq_vuserid=1260982452;vqq_vusession=Xd5bba2m9ByWls30Vi2FSQ.N; vqq_refresh_token=2D85975A29FB056EB6F9A338CB8F1EF5;vqq_next_refresh_time=6530;
  14. """.strip()
  15. auth_token = """
  16. vqq_appid=101483052; vqq_openid=406CA2296D6A3B970597D6CF1605B6B7; vqq_vuserid=1260982452;vqq_vusession=
  17. """.strip()
  18. user_token = """
  19. pgv_pvid=5805499462;video_platform=2;o_cookie=434857005;ptui_loginuin=434857005;uid=o0434857005;uin=o0434857005;vqq_vuserid=1260982452;vversion_name=8.2.95;vqq_next_refresh_time=6530;vqq_login_time_init=1666665341; login_time_last=2022-10-25 10:35:44
  20. """.strip()
  21. cookie = login_token
  22. headers = {
  23. # "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36¬",
  24. "User-Agent": "qqlive",
  25. "cookie": cookie,
  26. }
  27. def get_vid(vipUrl):
  28. vid = None
  29. if vipUrl.find('v.qq.com/x/cover/') > -1:
  30. _type = vipUrl.split("v.qq.com/x/cover/")[1].split(".html")[0]
  31. if _type.find('/') > -1:
  32. vid = _type.split("/")[1]
  33. else:
  34. r = requests.get(vipUrl, headers=headers)
  35. html = r.text
  36. vid = html.split('<link rel="canonical" href="https://v.qq.com/x/cover/')[1].split('/')[1].split('.')[0]
  37. else:
  38. if re.search('/page/.*\.html', vipUrl):
  39. vid = vipUrl.split("/page/")[1].split(".html")[0]
  40. else:
  41. if vipUrl.find('&vid=') > -1:
  42. vid = vipUrl.split("&vid=")[1].split("&")[0]
  43. print(f'vid:{vid}')
  44. return vid
  45. def vqq_jx_rx(url):
  46. # 1080P画质
  47. vid = get_vid(url)
  48. api = f"https://vv.video.qq.com/getinfo?defn=fhd&platform=10801&otype=ojson&sdtfrom=v4138&appVer=7&vid={vid}&newnettype=1&fhdswitch=1&show1080p=1&dtype=3&sphls=2"
  49. print(api)
  50. r = requests.get(api, headers=headers, timeout=time_out)
  51. ret = r.json()
  52. try:
  53. urls = ret["vl"]["vi"][0]['ul']['ui']
  54. # url = urls[-1]['url']
  55. url = urls[0]['url']
  56. realUrl = url
  57. print(realUrl)
  58. except:
  59. print(ret)
  60. def vqq_jx(url):
  61. # 720P 画质
  62. vid = get_vid(url)
  63. api = f'https://vv.video.qq.com/getinfo?encver=2&defn=shd&platform=10801&otype=ojson&sdtfrom=v4138&appVer=7&dtype=3&vid={vid}&newnettype=1'
  64. print(api)
  65. r = requests.get(api,headers=headers,timeout=time_out)
  66. ret = r.json()
  67. try:
  68. urls = ret["vl"]["vi"][0]['ul']['ui']
  69. print(urls)
  70. url = urls[-1]['url']
  71. pt = urls[-1]['hls']['pt']
  72. realUrl = url + pt
  73. print(realUrl)
  74. except:
  75. print(ret)
  76. if __name__ == '__main__':
  77. # 斗罗大陆
  78. url = 'https://v.qq.com/x/cover/m441e3rjq9kwpsc/c00442r6ry6.html'
  79. # 复仇者联盟
  80. # url = 'https://v.qq.com/x/cover/v2098lbuihuqs11/m00314jtw6k.html'
  81. # vqq_jx(url)
  82. vqq_jx_rx(url)