[英]time.strftime not updating in while loop
I am trying to record live streams. 我正在尝试录制实时流。 I want to periodically check if the stream is live and then record with streamlink and save the file with a unique date/time.
我想定期检查流是否为实时流,然后使用流链接进行记录并使用唯一的日期/时间保存文件。
from subprocess import call
import sys
import time
streamURL = str(sys.argv[1])
streamQuality = str(sys.argv[2])
streamName = str(sys.argv[3])
streamBuilder = []
streamBuilder.append("streamlink")
streamBuilder.append(streamURL)
streamBuilder.append(streamQuality)
streamBuilder.append("-o")
streamBuilder.append("/download/"+streamName+"-"+time.strftime("%Y%m%d%H%M%S")+".mkv")
while True:
call(streamBuilder)
time.sleep(60)
With the current code, the name does not change each time the stream is live. 使用当前代码,每次直播时名称都不会更改。
I think that you need to change the laste value of the streamBuilder at each iteration 我认为您需要在每次迭代时更改streamBuilder的laste值
while True:
call(streamBuilder)
time.sleep(60)
streamBuilder[-1] = "/download/"+streamName+"-"+time.strftime("%Y%m%d%H%M%S")+".mkv"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.