hls_m3u8_downloader.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:HLS_m3u8_downloader 作者: djstava 项目源码 文件源码
def execute(self, item):
        if item[1]:
            url = item[1] + "/" + item[2]
        else:
            url = item[2]
            item[2] = os.path.basename(urllib.parse.urlparse(url).path)

        if item[3]:
            backend = default_backend()
            r = requests.get(item[3].uri)
            key = r.content
            cipher = Cipher(algorithms.AES(key), modes.CBC(bytes.fromhex(item[3].iv[2:])), backend=backend)
            decryptor = cipher.decryptor()

        r = requests.get(url, stream=True)
        with open(os.path.join(self.location, item[2]), 'wb') as f:
            for chunk in r.iter_content(chunk_size=1024):
                if chunk:
                    if item[3]:
                        f.write(decryptor.update(chunk))
                    else:
                        f.write(chunk)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号