Python 获取虎课网 M3U8 视频链接

虎课网是超过 1800 万用户信赖的自学平台,拥有海量设计、绘画、摄影、办公软件、职业技能等优质的高清教程视频,用户可以根据行业和兴趣爱好,自主选择学习内容,每天免费学习一个教程。

Python

  1. # -*- coding:utf-8 -*-  
  2. # Time: 2022/7/9 11:00  
  3. # Author: 佚名  
  4.   
  5. import requests  
  6. import re  
  7.   
  8. def get_m3u8(page_id):  
  9.     url = 'https://huke88.com/course/%s.html' % page_id  
  10.     response = requests.get(url, headers=headers)  
  11.     response.encoding = 'utf-8'  
  12.     html = response.text  
  13.     # _csrf-frontend  
  14.     token = re.findall('csrf-token" content="(.*?)">', html)[0]  
  15.     videoplayurl = 'https://asyn.huke88.com/video/video-play'  
  16.     data = {  
  17.         'id': page_id,  
  18.         '_csrf-frontend:': token  
  19.     }  
  20.     response = requests.post(videoplayurl, headers=headers, data=data).json()  
  21.     tx_file_id = response['tx_file_id']  
  22.     app_id = response['app_id']  
  23.     token = response['token']  
  24.     key = '0000000000000000'  
  25.     overlayKey = key.encode().hex()  
  26.     overlayIv = key.encode().hex()  
  27.     url = 'https://playvideo.qcloud.com/getplayinfo/v4/%s/%s?psign=%s&overlayKey=%s&overlayIv=%s' % (app_id, tx_file_id, token, overlayKey, overlayIv)  
  28.   
  29.     response = requests.get(url, headers=headers).json()  
  30.     # title = response['media']['basicInfo']['name']  
  31.     m3u8_url = response['media']['streamingInfo']['drmOutput'][0]['url']  
  32.     drmToken = response['media']['streamingInfo']['drmToken']  
  33.     # m3u8 url  
  34.     m3u8 = m3u8_url.replace('adp.12.m3u8', 'voddrm.token.%s.video_12_3.m3u8' % drmToken)  
  35.     # key url  
  36.     url = 'https://drm.vod2.myqcloud.com/getlicense/v1?drmType=SimpleAES&token=' + drmToken  
  37.     print(m3u8)  
  38.   
  39. if __name__ == '__main__':  
  40.     number = 1  
  41.     page_id = '51207' #课程页面链接数字  
  42.     headers = {  
  43.         'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1',  
  44.         'cookie': '虎课 cookie'  
  45.     }  
  46.     get_m3u8(page_id)  

使用说明

通过以上 Python 代码获取到 M3U8 视频链接复制至 N_m3u8DL-CLI-SimpleG 内下载即可。因未有虎课 VIP 账号故无法批量获取,如有 VIP 账号可发送邮件至 admin@manwuji.com。

Python 获取虎课网 M3U8 视频链接

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
搜索