Skip to content

Commit

Permalink
release v3.9.4
Browse files Browse the repository at this point in the history
  • Loading branch information
xnetcat authored Apr 3, 2022
2 parents 5a32848 + 4a06d5a commit 597f5db
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 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.3
version = 3.9.4

name = spotdl
url = https://github.com/spotDL/spotify-downloader
Expand Down
13 changes: 12 additions & 1 deletion spotdl/search/song_gatherer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from pathlib import Path
from typing import Dict, List
import platform

from spotdl.providers import (
metadata_provider,
Expand Down Expand Up @@ -58,6 +59,16 @@ def from_spotify_url(
song_name, [artist["name"] for artist in raw_track_meta["artists"]]
)

# 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, '')
else: # Linux or MacOS
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:
converted_file_name = SongObject.create_file_name(
Expand All @@ -67,7 +78,7 @@ def from_spotify_url(
converted_file_path = Path(".", f"{converted_file_name}.{output_format}")

# Alternate file path.
alternate_file_path = Path(".", f"{display_name}.{output_format}")
alternate_file_path = Path(".", f"{filesystem_display_name}.{output_format}")

# if a song is already downloaded skip it
if converted_file_path.is_file() or alternate_file_path.is_file():
Expand Down

0 comments on commit 597f5db

Please sign in to comment.