Open zhiyu-zeng opened 3 years ago
得不到返回值
@zzy0711 os.system and os.popen 好像都不能实现效果 你可以曲线救国创建bat脚本用os.system调用 请参考文章52论坛
用的最新构建 https://github.com/nilaoda/N_m3u8DL-CLI/actions/runs/1157247671
import subprocess
import sys
cmd=r'"D:\N_m3u8DL-CLI.exe" "http://defaultts.tc.qq.com/gzc_1000102_0b53k4adaaaakeakwhaw6bq4av6dgbnqanca.f321004.ts.m3u8?ver=4"'
process = subprocess.Popen(cmd,shell=True,
stdout=sys.stdout,
stderr=sys.stderr,
cwd=r"D:\Downloads")
process.communicate()
生成单条命令行(可以添加环境变量)
cmd = "N_m3u8DL-CLI \"%s\" --workDir \"%s\" --saveName \"%s\" --enableDelAfterDone --disableDateInfo" % (
source_url, target_dir, source_name)
批量还是单个执行
liner = 0 #是否线性执行
if liner == 1:
bat_file_name = "批量下载M3U8-" + time.strftime("%Y%m%d%H%M%S", time.localtime()) + ".bat"
bat_file = open(bat_file_name, 'w', encoding='gbk', errors="ignore")
if bat_file:
bat_file.write('@echo off\n')
for item in cmd_list:
bat_file.write(item + '\n')
bat_file.write('pause')
bat_file_path = os.getcwd() + '\\' + bat_file_name
print("开始执行...")
os.system("start cmd /k " + bat_file_path)
else:
for item in cmd_list:
os.system("start cmd /k " + item)
time.sleep(2)
print("开始执行...")
只管执行 不管结果 哈哈
import subprocess import sys cmd=r'"D:\N_m3u8DL-CLI.exe" "http://defaultts.tc.qq.com/gzc_1000102_0b53k4adaaaakeakwhaw6bq4av6dgbnqanca.f321004.ts.m3u8?ver=4"' process = subprocess.Popen(cmd,shell=True, stdout=sys.stdout, stderr=sys.stderr, cwd=r"D:\Downloads") process.communicate()
N_m3u8DL-CLI version 2.9.9 2018-2021 built date: 20211123
δ��������쳣: System.IO.IOException: �����Ч��
�� System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
�� System.Console.GetBufferInfo(Boolean throwOnNoConsole, Boolean& succeeded)
�� System.Console.get_WindowWidth()
�� N_m3u8DL_CLI.LOGGER.PrintLine(String text, Int32 printLevel)
�� N_m3u8DL_CLI.NetCore.Program.DoWork(MyOptions o)
�� CommandLine.ParserResultExtensions.WithParsed[T](ParserResult1 result, Action
1 action)
�� N_m3u8DL_CLI.NetCore.Program.Main(String[] args)
import subprocess import sys cmd=r'"D:\N_m3u8DL-CLI.exe" "http://defaultts.tc.qq.com/gzc_1000102_0b53k4adaaaakeakwhaw6bq4av6dgbnqanca.f321004.ts.m3u8?ver=4"' process = subprocess.Popen(cmd,shell=True, stdout=sys.stdout, stderr=sys.stderr, cwd=r"D:\Downloads") process.communicate()
Python 3.7.9 测试没问题
import subprocess import sys cmd=r'"D:\N_m3u8DL-CLI.exe" "http://defaultts.tc.qq.com/gzc_1000102_0b53k4adaaaakeakwhaw6bq4av6dgbnqanca.f321004.ts.m3u8?ver=4"' process = subprocess.Popen(cmd,shell=True, stdout=sys.stdout, stderr=sys.stderr, cwd=r"D:\Downloads") process.communicate()
Python 3.7.9 测试没问题
python3.9 测试就有问题了呀,大佬能支持下端口调用吗?类似于post m3u8信息,实现自动批量这种的
os.system 不可以吗