download fails pretty much work

This commit is contained in:
Hellow 2023-04-04 20:28:14 +02:00
parent 787084d9e7
commit 5f5649a0f3
2 changed files with 7 additions and 1 deletions

View File

@ -65,6 +65,7 @@ def cli():
r = search.download_chosen()
print()
print(r)
print(r._error_message_list)
return True
url = re.match(URL_REGGEX, query)

View File

@ -1,4 +1,5 @@
from dataclasses import dataclass
from dataclasses import dataclass, field
from typing import List
@dataclass
@ -7,6 +8,8 @@ class DownloadResult:
fail: int = 0
error_message: str = None
_error_message_list: List[str] = field(default_factory=list)
@property
def success(self) -> int:
return self.total - self.fail
@ -17,11 +20,13 @@ class DownloadResult:
def merge(self, other: "DownloadResult"):
if other.fatal_error:
self._error_message_list.append(other.error_message)
self.total += 1
self.fail += 1
else:
self.total += other.total
self.fail += other.fail
self._error_message_list.extend(other._error_message_list)
def __repr__(self):
if self.fatal_error: