This commit is contained in:
Hellow 2023-04-04 21:18:56 +02:00
parent 46eab5cbb0
commit cbb0d5255b
4 changed files with 16 additions and 8 deletions

View File

@ -63,9 +63,12 @@ def cli():
if parsed in DOWNLOAD_COMMANDS:
r = search.download_chosen()
print()
print(r)
return True
print()
return not r.is_mild_failure
url = re.match(URL_REGGEX, query)
if url is not None:

View File

@ -491,7 +491,7 @@ class Page:
r = cls._download_song_to_targets(source=sources[0], target=temp_target, desc=song.title)
if not r.fatal_error:
if not r.is_fatal_error:
cls._post_process_targets(song, temp_target)
return r

View File

@ -25,11 +25,15 @@ class DownloadResult:
return self.fail / self.total
@property
def fatal_error(self) -> bool:
def is_fatal_error(self) -> bool:
return self.error_message is not None
@property
def is_mild_failure(self) -> bool:
return self.failure_percentage > SHOW_DOWNLOAD_ERRORS_THRESHOLD
def merge(self, other: "DownloadResult"):
if other.fatal_error:
if other.is_fatal_error:
LOGGER.debug(other.error_message)
self._error_message_list.append(other.error_message)
self.total += 1
@ -40,13 +44,13 @@ class DownloadResult:
self._error_message_list.extend(other._error_message_list)
def __str__(self):
if self.fatal_error:
if self.is_fatal_error:
return self.error_message
head = f"{self.fail} from {self.total} downloads failed:\n" \
f"successrate:\t{int(self.success_percentage*100)}%\n" \
f"failrate:\t\t{int(self.failure_percentage*100)}%"
f"failrate:\t{int(self.failure_percentage*100)}%"
if self.failure_percentage <= SHOW_DOWNLOAD_ERRORS_THRESHOLD:
if not self.is_mild_failure:
return head
_lines = [head]

View File

@ -22,7 +22,7 @@ HAPPY_MESSAGES: List[str] = [
"🏳️‍⚧️🏳️‍⚧️ Trans women are women, trans men are men. 🏳️‍⚧️🏳️‍⚧️",
"🏴‍☠️🏴‍☠️ Unite under one flag, fuck borders. 🏴‍☠️🏴‍☠️",
"Join my Matrix Space: https://matrix.to/#/#music-kraken:matrix.org",
"Gotta love BPJM!! :/"
"Gotta love the BPJM!! :/"
]
@ -54,6 +54,7 @@ GENIUS_LOGGER = logging.getLogger("genius")
ENCYCLOPAEDIA_METALLUM_LOGGER = logging.getLogger("ma")
DOWNLOAD_LOGGER = logging.getLogger("download")
TAGGING_LOGGER = logging.getLogger("tagging")
NOT_A_GENRE = ".", "..", "misc_scripts", "Music", "script", ".git", ".idea"
MUSIC_DIR = Path(os.path.expanduser("~"), "Music")