test.py文件
# -*- coding: utf-8 -*-
import json
import threading
import requests
import subprocess, sys, os
def check_json_format(raw_msg):
""" 用于判断一个字符串是否符合Json格式 :param self: :return: """
if isinstance(raw_msg, str): # 首先判断变量是否为字符串
try:
json.loads(raw_msg, encoding='utf-8')
except ValueError:
return False
return True
else:
return False
def response(flow):
#例如:
# https://open.com/43567890/TYUI678/678iu.m3u8
# http://abc.com/api/play/5678?uuid=tyu567tyu789&device=0
url = 'api/play'
if url in flow.request.url:
text = flow.response.text
if check_json_format(text):
data_json = json.loads(text)
if data_json and data_json.get('resp').get('path'): #判断json中有这些节点
rescont = data_json.get('resp')
videopath = rescont.get('path')
title = rescont.get('title')
print(videopath)
filename = title + '.mp4'
print(filename)
t = threading.Thread(target=exec_cmd(videopath, filename)) # 创建一个线程
t.start() # 启动线程
print( filename,'下载完成')
def exec_cmd(videopath, filename):
cmd = 'ffmpeg -i ' + videopath + ' -c copy ' + filename
print(cmd)
cmd = cmd.encode(sys.getfilesystemencoding())
print(cmd)
subprocess.call(cmd, shell=True)
brew install ffmpeg
brew install mitmproxy
mitmdump -s test.py -p 8888
192.168.0.xxx
),端口8888
1.修改网络
2.显示高级选项
3.选代理、手动,填ip、端口连上代理后,手机浏览器打开http://mitm.it/
按页面说明步骤操作(ios,android各不同)
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/100402.html原文链接:
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有