feature/sponsorblock #17
@ -41,6 +41,7 @@ OPTION_FOREGROUND = BColors.OKBLUE
|
||||
def get_collection_string(
|
||||
collection: Collection[Base],
|
||||
template: str,
|
||||
ignore_titles: Set[str] = None,
|
||||
background: BColors = OPTION_BACKGROUND,
|
||||
foreground: BColors = OPTION_FOREGROUND
|
||||
) -> str:
|
||||
@ -50,17 +51,21 @@ def get_collection_string(
|
||||
foreground = foreground.value
|
||||
background = background.value
|
||||
|
||||
ignore_titles = ignore_titles or set()
|
||||
|
||||
r = background
|
||||
|
||||
element: Base
|
||||
for i, element in enumerate(collection):
|
||||
titel_list: List[str] = [element.title_string.strip() for element in collection if element.title_string not in ignore_titles]
|
||||
|
||||
for i, titel in enumerate(titel_list):
|
||||
delimiter = ", "
|
||||
if i == len(collection) - 1:
|
||||
delimiter = ""
|
||||
elif i == len(collection) - 2:
|
||||
delimiter = " and "
|
||||
|
||||
r += foreground + element.title_string + BColors.ENDC.value + background + delimiter + BColors.ENDC.value
|
||||
r += foreground + titel + BColors.ENDC.value + background + delimiter + BColors.ENDC.value
|
||||
|
||||
r += BColors.ENDC.value
|
||||
|
||||
@ -185,7 +190,7 @@ class Song(Base):
|
||||
@property
|
||||
def option_string(self) -> str:
|
||||
r = OPTION_FOREGROUND.value + self.title + BColors.ENDC.value + OPTION_BACKGROUND.value
|
||||
r += get_collection_string(self.album_collection, " from {}")
|
||||
r += get_collection_string(self.album_collection, " from {}", ignore_titles={self.title})
|
||||
r += get_collection_string(self.main_artist_collection, " by {}")
|
||||
r += get_collection_string(self.feature_artist_collection, " feat. {}")
|
||||
return r
|
||||
|
Loading…
Reference in New Issue
Block a user