Skip to content

Commit

Permalink
release v3.9.5
Browse files Browse the repository at this point in the history
  • Loading branch information
xnetcat authored Apr 15, 2022
2 parents 597f5db + 859aaee commit 4bc6ec3
Show file tree
Hide file tree
Showing 12 changed files with 42,286 additions and 43,897 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[metadata]
version = 3.9.4
version = 3.9.5

name = spotdl
url = https://github.com/spotDL/spotify-downloader
Expand Down
1 change: 1 addition & 0 deletions spotdl/download/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ async def download_song(self, song_object: SongObject) -> None:
f'by "{song_object.contributing_artists[0]}" '
f'from video "{song_object.youtube_link}"'
)

return None

if downloaded_file_path_string is None:
Expand Down
27 changes: 21 additions & 6 deletions spotdl/providers/yt_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def search_and_get_best_match(
`str` `song_album_name` : name of song's album
`int` `song_duration` : duration of the song
`int` `song_duration` : duration of the song, in seconds
`str` `isrc` : code for identifying sound recordings and music video recordings
Expand Down Expand Up @@ -79,7 +79,6 @@ def _order_yt_results(
song_artists: List[str],
song_duration: int,
) -> dict:

# Assign an overall avg match value to each result
links_with_match_value = {}

Expand Down Expand Up @@ -114,9 +113,13 @@ def _order_yt_results(
for artist in song_artists:
# ! something like _match_percentage('rionos', 'aiobahn, rionos Motivation
# ! (remix)' would return 100, so we're absolutely corrent in matching
# ! artists to song name.
# ! artists to song name. Also allow for matching artist to video author.
if _match_percentage(
str(unidecode(artist.lower())), str(unidecode(result.title).lower()), 85
) or _match_percentage(
str(unidecode(artist.lower())),
str(unidecode(result.author).lower()),
85,
):
artist_match_number += 1

Expand All @@ -126,10 +129,22 @@ def _order_yt_results(
continue

artist_match = (artist_match_number / len(song_artists)) * 100
song_title = _create_song_title(song_name, song_artists).lower()

song_title = _create_song_title(song_name, song_artists)
name_match = round(
_match_percentage(
str(unidecode(result.title.lower())), str(unidecode(song_title)), 60
max(
# case where artist is included in title
_match_percentage(
str(unidecode(song_title.lower())),
str(unidecode(result.title.lower())),
60,
),
# case where artist is author and video title is only the track name
_match_percentage(
str(unidecode(song_name.lower())),
str(unidecode(result.title.lower())),
60,
),
),
ndigits=3,
)
Expand Down
18 changes: 11 additions & 7 deletions spotdl/search/song_gatherer.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,18 @@ def from_spotify_url(
)

# Ensure file name doesnt contain forbidden characters
filesystem_display_name = display_name # Create copy of display_name for filesystem use
if platform.system() == 'Windows':
for forbidden_letter in ['<', '>', ':', '"', '/', '\\', '|', '?', '*']:
converted_file_name = converted_file_name.replace(forbidden_letter, '')
filesystem_display_name = filesystem_display_name.replace(forbidden_letter, '')
filesystem_display_name = (
display_name # Create copy of display_name for filesystem use
)
if platform.system() == "Windows":
for forbidden_letter in ["<", ">", ":", '"', "/", "\\", "|", "?", "*"]:
converted_file_name = converted_file_name.replace(forbidden_letter, "")
filesystem_display_name = filesystem_display_name.replace(
forbidden_letter, ""
)
else: # Linux or MacOS
converted_file_name = converted_file_name.replace('/', '')
filesystem_display_name = filesystem_display_name.replace('/', '')
converted_file_name = converted_file_name.replace("/", "")
filesystem_display_name = filesystem_display_name.replace("/", "")

# If song name is too long use only first artist
if len(converted_file_name) > 250:
Expand Down
5 changes: 4 additions & 1 deletion spotdl/search/spotify_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ def init(cls, client_id: str, client_secret: str, user_auth: bool) -> "Singleton
)

# Create instance
cls._instance = super().__call__(auth_manager=credential_manager)
cls._instance = super().__call__(
auth_manager=credential_manager,
status_forcelist=(429, 500, 502, 503, 504, 404),
)

# Return instance
return cls._instance
Expand Down
Loading

0 comments on commit 4bc6ec3

Please sign in to comment.