downloading can use tqdm

This commit is contained in:
retrozelda
2025-02-09 04:25:21 -05:00
parent 1be17e5f70
commit 7b6b51f9ea
2 changed files with 37 additions and 1 deletions

View File

@@ -5,6 +5,7 @@ import logging
import time
import re
from tqdm import tqdm
import progressbar
LOG_VERBOSE = 15
@@ -86,3 +87,37 @@ def run_ffmpeg_with_progress(command, progress_header: str = "Processing"):
progress_bar.finish()
logging.log(helpers.LOG_VERBOSE, f"Completed in {format_duration(time.time() - start_time)}")
def run_ffmpeg_with_tqdm(command, progress_header: str = "Processing"):
logging.log(helpers.LOG_VERBOSE, f"Executing ffmpeg")
logging.debug(f'{" ".join(command)}')
try:
process = subprocess.Popen(command, stderr=subprocess.PIPE, universal_newlines=True)
except Exception as e:
logging.error(f"Failed to start ffmpeg: {e}")
return
duration = None
progress_bar = None
start_time = time.time()
for line in process.stderr:
if duration is None:
duration = parse_ffmpeg_duration(line)
if duration:
progress_bar = tqdm(desc=progress_header, total=duration, unit='s', unit_scale=True)
if progress_bar and duration:
current_time = parse_ffmpeg_time(line)
if current_time:
if current_time > duration:
current_time = duration
progress_bar.update(current_time)
process.wait()
if progress_bar:
progress_bar = None
logging.log(helpers.LOG_VERBOSE, f"Completed in {format_duration(time.time() - start_time)}")

View File

@@ -2,4 +2,5 @@ selenium==4.23.1
requests==2.32.3
progressbar2==4.4.2
m3u8==6.0.0
click==8.1.7
click==8.1.7
tqdm==4.67.1