Skip to content

Commit

Permalink
Add fix for special characters in final song name from meta
Browse files Browse the repository at this point in the history
  • Loading branch information
deepjyoti30 committed Aug 27, 2023
1 parent 2fe8cec commit e2fe3f8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions ytmdl/dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def cleanup(TRACK_INFO, index, datatype, remove_cached=True, filename_passed=Non

dest_filename = os.path.join(
DIR, __replace_special_characters(SONG_NAME))

logger.debug("Final name: ", dest_filename)
shutil.move(SONG, dest_filename)

if remove_cached:
Expand Down
11 changes: 8 additions & 3 deletions ytmdl/song.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from ytmdl import prepend, defaults
from simber import Logger
from ytmdl.meta import preconfig
from ytmdl.dir import __replace_special_characters
# import traceback

logger = Logger("song")
Expand Down Expand Up @@ -227,13 +228,17 @@ def set_MP3_data(song, song_path):

data.save()

defaults.DEFAULT.SONG_NAME_TO_SAVE = song.track_name + '.mp3'
defaults.DEFAULT.SONG_NAME_TO_SAVE = __replace_special_characters(
song.track_name) + '.mp3'

# Rename the downloaded file
os.rename(SONG_PATH, os.path.join(
to_save_as = os.path.join(
defaults.DEFAULT.SONG_TEMP_DIR,
defaults.DEFAULT.SONG_NAME_TO_SAVE
))
)
logger.debug("Renaming file from: `{}` to `{}`".format(
SONG_PATH, to_save_as))
os.rename(SONG_PATH, to_save_as)

return IS_IMG_ADDED

Expand Down

0 comments on commit e2fe3f8

Please sign in to comment.