Kethsar / ytarchive

Garbage Youtube livestream downloader
MIT License
1.01k stars 83 forks source link

Should be able to recover from tcp errors #190

Open thatstarcreator opened 2 months ago

thatstarcreator commented 2 months ago

Very frequently ytarchive hits a network error of some sort. Network interruption is typically only a matter of seconds, but it causes ytarchive to immediately stop the download in progress and begin final muxing when the stream in progress hasn't actually ended. ytarchive should instead attempt to retry and resume the download. This can also occur following the timer for waiting for stream to start, in which case the download never starts despite the stream being live.

Running v0.4.0 (Aug 20, 2023) on Windows 11 23H2.

See the following output:

2024/05/09 20:00:03 Selected quality: 1080p60 (h264)
2024/05/09 22:00:15 WARNING: Failed to retrieve data from https://www.youtube.com/watch?v=xxxxx: Get "https://www.youtube.com/watch?v=xxxxx": dial tcp: lookup www.youtube.com: i/o timeout

2024/05/09 22:00:15 ERROR: Error retrieving player response: unable to retrieve data from video page
Video Fragments: 7535; Audio Fragments: 7536; Total Downloaded: 4.10GiB
2024/05/09 22:00:15 Download Finished
2024/05/09 22:00:15 Muxing final file...
thatstarcreator commented 3 weeks ago

I suspect what is occurring is there is a DNS timeout when util.go DownloadData calls client.get during the hourly update interval, and the resulting error bubbles up in a way that everything stops. Perhaps a retry loop could be added around this call just in case the abnormal network condition fixes itself within three or four tries (which in my case it does).