[HELP]多进程调用下各子进程进度的显示 #12
Replies: 21 comments 5 replies
-
啊首先,日志文件无论如何也不会出现进度条信息,日志文件只会写如下载的关键信息,并不是将屏幕内容原样保存到文件 |
Beta Was this translation helpful? Give feedback.
-
至于混在一起,我看看你的py脚本,你可能需要改一些东西 |
Beta Was this translation helpful? Give feedback.
-
我用subprocess来监控N_m3u8DL-RE的输出信息时,发现输出不了进度条到窗口中。 import subprocess
import sys
command = ['N_m3u8DL-RE', 'https://f43.frontgross.com/hl/ta_miau/2024-01-03,06-51/index.m3u8?md5=2j-Va4Jg9bwxAM9sA9LYZg&expires=1707062670&origin=110&mid=9fcba76f-d852-4e58-83a2-ffb8e653682e&akey=6c9c01ce-07af-45c2-afb3-b60cf0017bcb&p=6002&request_id=', '-H', 'User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36', '--force-ansi-console', '--download-retry-count', '99', '--thread-count', '8']
# run the command and capture the output in real time
last_line = ""
progress_info = ""
with subprocess.Popen(command, stdout=subprocess.PIPE, bufsize=1, universal_newlines=True, encoding='utf-8-sig') as p:
while p.poll() is None: # while the process is still running
line = p.stdout.readline().strip() # read the next line
if "Progress:" in line:
progress_info = line # capture the progress information
last_line = line # capture the last line
print(line) # print the line
if "One or more errors occurred" in line:
print("请重新下载")
break
# print the progress and last line after the process ends
print("进度信息: ", progress_info)
print("最后一行: ", last_line) |
Beta Was this translation helpful? Give feedback.
-
import json
import string
import subprocess
import sys
command = ['N_m3u8DL-RE', 'https://f43.frontgross.com/hl/ta_miau/2024-01-03,06-51/index.m3u8?md5=2j-Va4Jg9bwxAM9sA9LYZg&expires=1707062670&origin=110&mid=9fcba76f-d852-4e58-83a2-ffb8e653682e&akey=6c9c01ce-07af-45c2-afb3-b60cf0017bcb&p=6002&request_id=', '-H', 'User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36', '--force-ansi-console', '--download-retry-count', '99', '--thread-count', '8']
# run the command and capture the output in real time
last_line = ""
progress_info = ""
with subprocess.Popen(command, stdout=subprocess.PIPE, bufsize=1, universal_newlines=True, encoding='gbk') as p:
while p.poll() is None: # while the process is still running
line = p.stdout.readline().strip() # read the next line
if line.isspace():
continue
if "%" in line:
print(line) # print the line
progress_info = line # capture the progress information
last_line = line # capture the last line
if "One or more errors occurred" in line:
print("请重新下载")
break
# print the progress and last line after the process ends
print("进度信息: ", progress_info)
print("最后一行: ", last_line) 用这个 |
Beta Was this translation helpful? Give feedback.
-
输出不了好像是python自己解码错误,多试试不同的编码,进度百分比可以用正则表达式获取,然后你批量调用的话输出每个任务的百分比就行了(输出完成/未完成也可以) |
Beta Was this translation helpful? Give feedback.
-
好的 我再试试 太感谢大佬了 |
Beta Was this translation helpful? Give feedback.
-
爬的啥啊stripchat吗,我之前写过一个录制监听+ffmpeg自动转码hevc的东西hhh 一开始用的这个但是不是怎么好用后来就自己写下载器了 |
Beta Was this translation helpful? Give feedback.
-
下载recu.me的视频 |
Beta Was this translation helpful? Give feedback.
-
哦这样,我推荐你看看stash这个项目,管理起来比较方便 |
Beta Was this translation helpful? Give feedback.
-
牛啊,我还不会自己写,毕竟我还只是入门阶段。我是用别人的程序ctbrec 录stripchat这个站 |
Beta Was this translation helpful? Give feedback.
-
感谢推荐 |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
大佬,我开了几十个线程同时下载,但是当分片下完后,Nm3u8dl会调用ffmpeg合并,然后下载也变慢了,因为很多个线程同时合并,硬盘也卡卡的。有没有什么办法只允许几个Nm3u8dl调用ffmpeg合并,让其他线程的Nm3u8dl调用ffmpeg合并的命令排在队列中呀? |
Beta Was this translation helpful? Give feedback.
-
试试挂起线程 |
Beta Was this translation helpful? Give feedback.
-
大佬,你所使用的ffmpeg录制直播流的命令可否分享一下?感谢 |
Beta Was this translation helpful? Give feedback.
-
不是ffmpeg,单独的小软件,录制结束后用ffmpeg过一遍修复一下错误的时间轴 |
Beta Was this translation helpful? Give feedback.
-
大佬我还想请教一个问题: 是关于这个站的https://www.popkontv.com/ ponkontv在获取直播流的请求头中需要加入authorization,好像是要在用账户密码登录后才会发放这个获取直播流的authorization,我用cookie方式登录不知道如何获取这个。于是后面我采用登录的方式获取authorization, 但是我在登录时遇到一个问题,在登录时会有如下面的一个base 开头的authorization,这个授权头貌似是js生成的,我换了几个浏览器和换了不同电脑 这个base开头的授权头都是一样,不知道是如何生成的,虽说现在可以用这个base开头的授权头来登录,但是万一哪天变化了,因此想请教一下,貌似是js生成的。 |
Beta Was this translation helpful? Give feedback.
-
你可以把他扔进node里面跑,混淆完了代码基本不能看了 |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
如果按照上面不加"--auto-select"就不会下载 加了就默认下载最大的 |
Beta Was this translation helpful? Give feedback.
-
在不开启 --force-ansi-console时,会显示各个进程的进度信息到最后一行,但只有百分比。日志文件中看不到进度条。

开启了force-ansi-console后,会出现各个进程的窗口混在一起的情况,日志文件中也还是看不到进度条。

Beta Was this translation helpful? Give feedback.
All reactions