Skip to content

Commit

Permalink
[record] Retry first part of VOD
Browse files Browse the repository at this point in the history
This part is the most important because it defines starting point of the stream.

Somethimes streamlink returns code 0 even if download has failed, so we need to check the output file.
  • Loading branch information
TheDrHax committed Oct 11, 2024
1 parent 49bc2d7 commit 00347dc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion twitch_utils/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,21 @@ def record(channel_name: str, vod_id: str, vod_url: Union[str, None] = None,
print('Starting download of VOD')

vod_result = -1
filename = generate_filename(vod_id, parts)

while vod_result != 0:
if vod_result > 0:
print('WARN: Could not download VOD (exit code '
f'{vod_result}), retrying in 60 seconds...')
sleep(60)

vod_result = vod.download(generate_filename(vod_id, parts))
vod_result = vod.download(filename)

if vod_result == 0:
try:
Clip(filename)
except Exception:
vod_result = 4095

parts += 1
print(f'Finished download of VOD (exit code: {vod_result})')
Expand Down

0 comments on commit 00347dc

Please sign in to comment.