一个城市的信仰

getkey

getkey

import requests
import base64


def get_key_from_url(url: str, userid: str) -> str:
    """
    通过请求m3u8文件中的key的url,获取解密视频key的base64字符串密钥
    :param url: m3u8文件中获取key的url
    :param userid: 用户id,放视频时飘动的那一串
    :return: key的base64字符串
    """
    # url拼接uid参数
    url += f'&uid={userid}'
    # 发送get请求
    rsp = requests.get(url=url)
    rsp_data = rsp.content
    if len(rsp_data) == 16:
        userid_bytes = bytes(userid.encode(encoding='utf-8'))
        result_list = []
        for index in range(0, len(rsp_data)):
            result_list.append(
                rsp_data[index] ^ userid_bytes[index])
        print(result_list)
        return base64.b64encode(bytes(result_list)).decode()
    else:
        print(f"获取异常,请求返回值:{rsp.text}")
        return ''


if __name__ == '__main__':
    _url = 'https://app.xiaoe-tech.com/xe.basic-platform.material-center.distribute.vod.pri.get/1.0.0?app_id=apppmCY5yCr8527&mid=m_U3S2JhWzSM6sP_4NCBjvpk&urld=3efe807cb7e838ea89d0b0da90cdab7f'
    _uid = 'u_6101473b22723_Gr5kj0LxaD'
    base64_key = get_key_from_url(url=_url, userid=_uid)
    print(base64_key)
赞(0) 打赏
未经允许不得转载:东东 » getkey

相关推荐

评论 抢沙发

登录

找回密码

注册