download error recovering

This commit is contained in:
Simon 2023-06-16 15:47:38 +07:00
parent 5927ced485
commit 247808563a
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
3 changed files with 23 additions and 5 deletions

View File

@ -114,7 +114,13 @@ class PendingInteract:
def update_status(self):
"""update status of pending item"""
if self.status == "priority":
data = {"doc": {"status": "pending", "auto_start": True}}
data = {
"doc": {
"status": "pending",
"auto_start": True,
"message": None,
}
}
else:
data = {"doc": {"status": self.status}}

View File

@ -49,7 +49,10 @@ class YtWrap:
try:
ydl.download([url])
except yt_dlp.utils.DownloadError as err:
print(f"{url}: failed to download.")
print(f"{url}: failed to download with message {err}")
if "Temporary failure in name resolution" in str(err):
raise ConnectionError("lost the internet, abort!") from err
return False, str(err)
return True, True
@ -61,8 +64,17 @@ class YtWrap:
except cookiejar.LoadError:
print("cookie file is invalid")
return False
except (yt_dlp.utils.ExtractorError, yt_dlp.utils.DownloadError):
print(f"{url}: failed to get info from youtube")
except yt_dlp.utils.ExtractorError as err:
print(f"{url}: failed to extract with message: {err}, continue...")
return False
except yt_dlp.utils.DownloadError as err:
if "This channel does not have a" in str(err):
return False
print(f"{url}: failed to get info from youtube with message {err}")
if "Temporary failure in name resolution" in str(err):
raise ConnectionError("lost the internet, abort!") from err
return False
return response

View File

@ -113,7 +113,7 @@ class BaseTask(Task):
"""callback for task failure"""
print(f"{task_id} Failed callback")
message, key = self._build_message(level="error")
message.update({"messages": ["Task failed"]})
message.update({"messages": [f"Task failed: {exc}"]})
RedisArchivist().set_message(key, message, expire=20)
def on_success(self, retval, task_id, args, kwargs):