mirror of
https://github.com/tubearchivist/tubearchivist.git
synced 2024-12-22 18:00:13 +00:00
handle download error
This commit is contained in:
parent
a7d9b4584b
commit
33f27f018f
@ -4,8 +4,6 @@ functionality:
|
|||||||
- handle yt-dlp errors
|
- handle yt-dlp errors
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from time import sleep
|
|
||||||
|
|
||||||
import yt_dlp
|
import yt_dlp
|
||||||
|
|
||||||
|
|
||||||
@ -30,14 +28,14 @@ class YtWrap:
|
|||||||
|
|
||||||
def download(self, url):
|
def download(self, url):
|
||||||
"""make download request"""
|
"""make download request"""
|
||||||
|
|
||||||
with yt_dlp.YoutubeDL(self.obs) as ydl:
|
with yt_dlp.YoutubeDL(self.obs) as ydl:
|
||||||
try:
|
try:
|
||||||
ydl.download([url])
|
ydl.download([url])
|
||||||
except yt_dlp.utils.DownloadError:
|
except yt_dlp.utils.DownloadError:
|
||||||
print(f"{url}: failed to download, retry...")
|
print(f"{url}: failed to download.")
|
||||||
sleep(3)
|
return False
|
||||||
ydl.download([url])
|
|
||||||
|
return True
|
||||||
|
|
||||||
def extract(self, url):
|
def extract(self, url):
|
||||||
"""make extract request"""
|
"""make extract request"""
|
||||||
|
Loading…
Reference in New Issue
Block a user