feat: highlight downloadebel options

This commit is contained in:
Hazel 2024-01-16 10:08:08 +01:00
parent fd0d22b751
commit b3ac152220
4 changed files with 17 additions and 3 deletions

View File

@ -10,7 +10,7 @@
> s: r: #a an Artist #r some random Release
```
Searches for an url, or an query
Searches for an url, or a query
### Query Syntax
@ -33,6 +33,10 @@ To download something, you either need a direct link, or you need to have alread
> d: https://musify.club/release/some-random-release-183028492
```
## Results
If options are printed in **bold** they can be downloaded. Else they may or maybe can't be downloaded
## Misc
### Exit

View File

@ -173,7 +173,8 @@ class Downloader:
page_count = 0
for option in self.current_results.formated_generator(max_items_per_page=self.max_displayed_options):
if isinstance(option, Option):
print(f"{option.index:0{self.option_digits}} {option.music_object.option_string}")
color = BColors.BOLD if self.pages.is_downloadable(option.music_object) else BColors.ENDC
print(f"{color}{option.index:0{self.option_digits}} {option.music_object.option_string}{BColors.ENDC}")
else:
prefix = ALPHABET[page_count % len(ALPHABET)]
print(

View File

@ -94,6 +94,15 @@ class Pages:
music_object.merge(self._page_instances[page_type].fetch_details(music_object=music_object, stop_at_level=stop_at_level))
return music_object
def is_downloadable(self, music_object: DatabaseObject) -> bool:
_page_types = set(self._source_to_page)
for src in music_object.source_collection.source_pages:
if src in self._source_to_page:
_page_types.add(self._source_to_page[src])
audio_pages = self._audio_pages_set.intersection(_page_types)
return len(audio_pages) > 0
def download(self, music_object: DatabaseObject, genre: str, download_all: bool = False, process_metadata_anyway: bool = False) -> DownloadResult:
if not isinstance(music_object, INDEPENDENT_DB_OBJECTS):

View File

@ -11,4 +11,4 @@ class BColors:
FAIL = "\033[91m"
ENDC = "\033[0m"
BOLD = "\033[1m"
UNDERLINE = "\033[4m"
UNDERLINE = "\033[4m"