Retry transient HLS network failures

This commit is contained in:
Dymas
2026-09-07 23:09:00 +02:00
parent a5401873cb
commit 91228d58e0
5 changed files with 53 additions and 2 deletions
+33
View File
@@ -4758,6 +4758,39 @@ https://shard-102.snapcdn.top/anime/show/episode/seg-f1-00083.css
self.assertEqual(fetch_bytes.call_count, 2)
sleep.assert_called_once()
def test_fetch_bytes_with_retries_recovers_from_temporary_dns_failure(self):
error = urllib.error.URLError(OSError(-3, "Temporary failure in name resolution"))
with mock.patch.object(
provider_downloader,
"fetch_bytes",
side_effect=[error, b"video"],
) as fetch_bytes, mock.patch.object(provider_downloader.time, "sleep") as sleep:
data = provider_downloader.fetch_bytes_with_retries(
"https://cdn.example/video/raw-segment",
retries=1,
retry_label="segment",
)
self.assertEqual(data, b"video")
self.assertEqual(fetch_bytes.call_count, 2)
sleep.assert_called_once()
def test_fetch_bytes_with_retries_raises_dns_failure_after_limit(self):
error = urllib.error.URLError(OSError(-3, "Temporary failure in name resolution"))
with mock.patch.object(provider_downloader, "fetch_bytes", side_effect=error), mock.patch.object(
provider_downloader.time, "sleep"
) as sleep:
with self.assertRaises(urllib.error.URLError):
provider_downloader.fetch_bytes_with_retries(
"https://cdn.example/video/raw-segment",
retries=1,
retry_label="segment",
)
sleep.assert_called_once()
def test_provider_stream_candidates_returns_resolved_sources(self):
with mock.patch.object(
provider_downloader,