feat: added color to couple error cases
This commit is contained in:
parent
2c504d3123
commit
206899e48a
@ -7,7 +7,8 @@ from .utils.config import logging_settings, main_settings, read_config
|
|||||||
read_config()
|
read_config()
|
||||||
from . import cli
|
from . import cli
|
||||||
|
|
||||||
if True:
|
|
||||||
|
if DEBUG:
|
||||||
import sys
|
import sys
|
||||||
sys.setrecursionlimit(100)
|
sys.setrecursionlimit(100)
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import random
|
||||||
from typing import Set, Type, Dict, List
|
from typing import Set, Type, Dict, List
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import re
|
import re
|
||||||
@ -134,7 +135,7 @@ def get_genre():
|
|||||||
|
|
||||||
def help_message():
|
def help_message():
|
||||||
print()
|
print()
|
||||||
print(main_settings["happy_messages"])
|
print(random.choice(main_settings["happy_messages"]))
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
|
||||||
@ -173,7 +174,7 @@ class Downloader:
|
|||||||
page_count = 0
|
page_count = 0
|
||||||
for option in self.current_results.formated_generator(max_items_per_page=self.max_displayed_options):
|
for option in self.current_results.formated_generator(max_items_per_page=self.max_displayed_options):
|
||||||
if isinstance(option, Option):
|
if isinstance(option, Option):
|
||||||
color = BColors.BOLD if self.pages.is_downloadable(option.music_object) else BColors.ENDC
|
color = BColors.BOLD if self.pages.is_downloadable(option.music_object) else BColors.GREY
|
||||||
print(f"{color}{option.index:0{self.option_digits}} {option.music_object.option_string}{BColors.ENDC}")
|
print(f"{color}{option.index:0{self.option_digits}} {option.music_object.option_string}{BColors.ENDC}")
|
||||||
else:
|
else:
|
||||||
prefix = ALPHABET[page_count % len(ALPHABET)]
|
prefix = ALPHABET[page_count % len(ALPHABET)]
|
||||||
@ -378,7 +379,7 @@ class Downloader:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
if processed_input != "help":
|
if processed_input != "help":
|
||||||
print("Invalid input.")
|
print(f"{BColors.WARNING}Invalid input.{BColors.ENDC}")
|
||||||
help_message()
|
help_message()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -401,9 +402,9 @@ def download(
|
|||||||
if code == 0:
|
if code == 0:
|
||||||
main_settings["hasnt_yet_started"] = False
|
main_settings["hasnt_yet_started"] = False
|
||||||
write_config()
|
write_config()
|
||||||
print("Restart the programm to use it.")
|
print(f"{BColors.OKGREEN}Restart the programm to use it.{BColors.ENDC}")
|
||||||
else:
|
else:
|
||||||
print("Something went wrong configuring.")
|
print(f"{BColors.FAIL}Something went wrong configuring.{BColors.ENDC}")
|
||||||
|
|
||||||
shell = Downloader(genre=genre, process_metadata_anyway=process_metadata_anyway)
|
shell = Downloader(genre=genre, process_metadata_anyway=process_metadata_anyway)
|
||||||
|
|
||||||
|
@ -2,12 +2,12 @@ from dataclasses import dataclass, field
|
|||||||
from typing import List, Tuple
|
from typing import List, Tuple
|
||||||
|
|
||||||
from ...utils.config import main_settings, logging_settings
|
from ...utils.config import main_settings, logging_settings
|
||||||
|
from ...utils.enums.colors import BColors
|
||||||
from ...objects import Target
|
from ...objects import Target
|
||||||
|
|
||||||
UNIT_PREFIXES: List[str] = ["", "k", "m", "g", "t"]
|
UNIT_PREFIXES: List[str] = ["", "k", "m", "g", "t"]
|
||||||
UNIT_DIVISOR = 1024
|
UNIT_DIVISOR = 1024
|
||||||
|
|
||||||
|
|
||||||
LOGGER = logging_settings["download_logger"]
|
LOGGER = logging_settings["download_logger"]
|
||||||
|
|
||||||
|
|
||||||
@ -83,16 +83,16 @@ class DownloadResult:
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
if self.is_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"success-rate:\t{int(self.success_percentage * 100)}%\n" \
|
||||||
f"failrate:\t{int(self.failure_percentage * 100)}%\n" \
|
f"fail-rate:\t{int(self.failure_percentage * 100)}%\n" \
|
||||||
f"total size:\t{self.formated_size}\n" \
|
f"total size:\t{self.formated_size}\n" \
|
||||||
f"skipped segments:\t{self.sponsor_segments}\n" \
|
f"skipped segments:\t{self.sponsor_segments}\n" \
|
||||||
f"found on disc:\t{self.found_on_disk}"
|
f"found on disc:\t{self.found_on_disk}"
|
||||||
|
|
||||||
if not self.is_mild_failure:
|
if not self.is_mild_failure:
|
||||||
return head
|
return head
|
||||||
|
|
||||||
_lines = [head]
|
_lines = [head]
|
||||||
_lines.extend(self._error_message_list)
|
_lines.extend(BColors.FAIL + s + BColors.ENDC for s in self._error_message_list)
|
||||||
return "\n".join(_lines)
|
return "\n".join(_lines)
|
||||||
|
Loading…
Reference in New Issue
Block a user