mirror of
https://github.com/Footsiefat/zspotify
synced 2021-12-21 22:06:14 +01:00
Added prefixes in case more than two songs have the same name
This commit is contained in:
parent
857b1d949a
commit
b340f92f29
@ -1,4 +1,5 @@
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
from typing import Any, Tuple, List
|
||||
|
||||
@ -80,9 +81,11 @@ def download_track(track_id: str, extra_paths='', prefix=False, prefix_value='',
|
||||
|
||||
# a song with the same name is installed
|
||||
if not check_id and check_name:
|
||||
# TODO: count songs with the same name but different id and add prefix based on that
|
||||
c = len([file for file in os.listdir(download_directory)
|
||||
if re.search(f'^{song_name}_', file)]) + 1
|
||||
|
||||
filename = os.path.join(
|
||||
download_directory, f'{song_name}_1.{EXT_MAP.get(ZSpotify.get_config(DOWNLOAD_FORMAT))}')
|
||||
download_directory, f'{song_name}_{c}.{EXT_MAP.get(ZSpotify.get_config(DOWNLOAD_FORMAT))}')
|
||||
|
||||
|
||||
except Exception as e:
|
||||
|
@ -27,7 +27,7 @@ def create_download_directory(download_path: str) -> None:
|
||||
with open(hidden_file_path, 'w', encoding='utf-8') as f:
|
||||
pass
|
||||
|
||||
def get_directory_song_ids(download_path: str) -> list[str]:
|
||||
def get_directory_song_ids(download_path: str) -> List[str]:
|
||||
""" Gets song ids of songs in directory """
|
||||
|
||||
song_ids = []
|
||||
|
Loading…
x
Reference in New Issue
Block a user