feature/sponsorblock #17

Merged
Hazel merged 20 commits from feature/sponsorblock into experimental 2024-04-27 09:41:36 +00:00
3 changed files with 12 additions and 4 deletions
Showing only changes of commit a015b8918e - Show all commits

View File

@ -161,3 +161,8 @@ class Collection(Generic[T]):
def __getitem__(self, item: int):
return self._data[item]
def get(self, item: int, default = None):
if item >= len(self._data):
return default
return self._data[item]

View File

@ -26,6 +26,7 @@ from ..objects import (
)
from ..utils.config import logging_settings
from ..utils import string_processing, shared
from ..utils.string_processing import clean_song_title
from ..utils.support_classes.query import Query
from ..utils.support_classes.download_result import DownloadResult
@ -355,8 +356,10 @@ class Musify(Page):
if raw_id.isdigit():
_id = raw_id
return Song(
title=song_title,
title=clean_song_title(song_title, artist_name=artist_list[0].name if len(artist_list) > 0 else None),
main_artist_list=artist_list,
source_list=source_list
)
@ -502,7 +505,7 @@ class Musify(Page):
))
return Song(
title=track_name,
title=clean_song_title(track_name, artist_name=artist_list[0].name if len(artist_list) > 0 else None),
source_list=source_list,
lyrics_list=lyrics_list,
main_artist_list=artist_list,
@ -645,7 +648,7 @@ class Musify(Page):
))
return Song(
title=song_name,
title=clean_song_title(song_name, artist_name=artist_list[0].name if len(artist_list) > 0 else None),
tracksort=tracksort,
main_artist_list=artist_list,
source_list=source_list

View File

@ -93,7 +93,7 @@ def clean_song_title(raw_song_title: str, artist_name: Optional[str] = None) ->
break
substring = raw_song_title[open_bracket_index + 1:close_bracket_index]
if any(disallowed_substring in substring for disallowed_substring in DISALLOWED_SUBSTRING_IN_BRACKETS):
if any(disallowed_substring in substring.lower() for disallowed_substring in DISALLOWED_SUBSTRING_IN_BRACKETS):
raw_song_title = raw_song_title[:open_bracket_index] + raw_song_title[close_bracket_index + 1:]
else:
start = close_bracket_index + 1