handle download error

This commit is contained in:
simon 2022-05-24 10:18:33 +07:00
parent a7d9b4584b
commit 33f27f018f
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
1 changed files with 4 additions and 6 deletions

View File

@ -4,8 +4,6 @@ functionality:
- handle yt-dlp errors
"""
from time import sleep
import yt_dlp
@ -30,14 +28,14 @@ class YtWrap:
def download(self, url):
"""make download request"""
with yt_dlp.YoutubeDL(self.obs) as ydl:
try:
ydl.download([url])
except yt_dlp.utils.DownloadError:
print(f"{url}: failed to download, retry...")
sleep(3)
ydl.download([url])
print(f"{url}: failed to download.")
return False
return True
def extract(self, url):
"""make extract request"""