Compare commits

..

No commits in common. "c2f57323515e6f5ce4d4474ed8ebc31623d614a9" and "171163b3d917951d8366be1fb7707c6f67b3710e" have entirely different histories.

1 changed files with 2 additions and 28 deletions

View File

@ -1,7 +1,6 @@
#!/usr/bin/env python3
from pathlib import Path
import subprocess
import time
import click
@ -60,32 +59,7 @@ def download(allow_unknown, base_dir, channel_file):
'--write-thumbnail',
url
]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=target_dir)
prev_output = ''
while p.poll() is None:
try:
stdout_data, stderr_data = p.communicate(timeout=0.5)
except subprocess.TimeoutExpired as e:
if e.output:
print(e.output[len(prev_output):].decode('utf-8'), end='')
prev_output = e.output or ''
else:
print(stdout_data[len(prev_output):].decode('utf-8'))
stdout_lines = stdout_data.decode('utf-8').splitlines()
if p.returncode == 0:
return
if p.returncode == 101:
pass
elif p.returncode == 1 and stdout_lines[-1] and 'Finished downloading playlist' in stdout_lines[-1]:
pass
else:
breakpoint()
raise subprocess.CalledProcessError(returncode=p.returncode, cmd=cmd)
sleep_seconds = 5
print(f"Sleeping {sleep_seconds}s")
time.sleep(sleep_seconds)
subprocess.run(cmd, check=True, cwd=target_dir)
if __name__ == '__main__':