mirror of
https://github.com/THIS-IS-NOT-A-BACKUP/zspotify.git
synced 2025-07-01 15:23:15 +00: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 os
|
||||||
|
import re
|
||||||
import time
|
import time
|
||||||
from typing import Any, Tuple, List
|
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
|
# a song with the same name is installed
|
||||||
if not check_id and check_name:
|
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(
|
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:
|
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:
|
with open(hidden_file_path, 'w', encoding='utf-8') as f:
|
||||||
pass
|
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 """
|
""" Gets song ids of songs in directory """
|
||||||
|
|
||||||
song_ids = []
|
song_ids = []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user