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() r = search.download_chosen()
print() print()
print(r) print(r)
print(r._error_message_list)
return True return True
url = re.match(URL_REGGEX, query) 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 @dataclass
@ -7,6 +8,8 @@ class DownloadResult:
fail: int = 0 fail: int = 0
error_message: str = None error_message: str = None
_error_message_list: List[str] = field(default_factory=list)
@property @property
def success(self) -> int: def success(self) -> int:
return self.total - self.fail return self.total - self.fail
@ -17,11 +20,13 @@ class DownloadResult:
def merge(self, other: "DownloadResult"): def merge(self, other: "DownloadResult"):
if other.fatal_error: if other.fatal_error:
self._error_message_list.append(other.error_message)
self.total += 1 self.total += 1
self.fail += 1 self.fail += 1
else: else:
self.total += other.total self.total += other.total
self.fail += other.fail self.fail += other.fail
self._error_message_list.extend(other._error_message_list)
def __repr__(self): def __repr__(self):
if self.fatal_error: if self.fatal_error: