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: if parsed in DOWNLOAD_COMMANDS:
r = search.download_chosen() r = search.download_chosen()
print() print()
print(r) print(r)
return True print()
return not r.is_mild_failure
url = re.match(URL_REGGEX, query) url = re.match(URL_REGGEX, query)
if url is not None: 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) 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) cls._post_process_targets(song, temp_target)
return r return r

View File

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

View File

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