mirror of
https://github.com/THIS-IS-NOT-A-BACKUP/zspotify.git
synced 2024-11-29 19:24:34 +01:00
Also save ext data in .song_ids file (filename, date, etc)
This commit is contained in:
parent
c836240b30
commit
cdd013b09e
@ -158,10 +158,10 @@ def download_track(mode: str, track_id: str, extra_keys={}, disable_progressbar=
|
||||
|
||||
# add song id to archive file
|
||||
if ZSpotify.CONFIG.get_skip_previously_downloaded():
|
||||
add_to_archive(scraped_song_id, artists[0], name)
|
||||
add_to_archive(scraped_song_id, filename, artists[0], name)
|
||||
# add song id to download directory's .song_ids file
|
||||
if not check_id:
|
||||
add_to_directory_song_ids(filedir, scraped_song_id)
|
||||
add_to_directory_song_ids(filedir, scraped_song_id, filename, artists[0], name)
|
||||
|
||||
if not ZSpotify.CONFIG.get_anti_ban_wait_time():
|
||||
time.sleep(ZSpotify.CONFIG.get_anti_ban_wait_time())
|
||||
|
@ -42,17 +42,17 @@ def get_previously_downloaded() -> List[str]:
|
||||
|
||||
return ids
|
||||
|
||||
def add_to_archive(song_id: str, author_name: str, song_name: str) -> None:
|
||||
def add_to_archive(song_id: str, filename: str, author_name: str, song_name: str) -> None:
|
||||
""" Adds song id to all time installed songs archive """
|
||||
|
||||
archive_path = os.path.join(os.path.dirname(__file__), ZSpotify.CONFIG.get_root_path(), ZSpotify.CONFIG.get_song_archive())
|
||||
|
||||
if os.path.exists(archive_path):
|
||||
with open(archive_path, 'a', encoding='utf-8') as f:
|
||||
f.write(f'{song_id}\t{datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")}\t{author_name}\t{song_name}\n')
|
||||
with open(archive_path, 'a', encoding='utf-8') as file:
|
||||
file.write(f'{song_id}\t{datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")}\t{author_name}\t{song_name}\t{filename}\n')
|
||||
else:
|
||||
with open(archive_path, 'w', encoding='utf-8') as f:
|
||||
f.write(f'{song_id}\t{datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")}\t{author_name}\t{song_name}\n')
|
||||
with open(archive_path, 'w', encoding='utf-8') as file:
|
||||
file.write(f'{song_id}\t{datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")}\t{author_name}\t{song_name}\t{filename}\n')
|
||||
|
||||
def get_directory_song_ids(download_path: str) -> List[str]:
|
||||
""" Gets song ids of songs in directory """
|
||||
@ -62,18 +62,18 @@ def get_directory_song_ids(download_path: str) -> List[str]:
|
||||
hidden_file_path = os.path.join(download_path, '.song_ids')
|
||||
if os.path.isfile(hidden_file_path):
|
||||
with open(hidden_file_path, 'r', encoding='utf-8') as file:
|
||||
song_ids.extend([line.strip() for line in file.readlines()])
|
||||
song_ids.extend([line.strip().split('\t')[0] for line in file.readlines()])
|
||||
|
||||
return song_ids
|
||||
|
||||
def add_to_directory_song_ids(download_path: str, song_id: str) -> None:
|
||||
def add_to_directory_song_ids(download_path: str, song_id: str, filename: str, author_name: str, song_name: str) -> None:
|
||||
""" Appends song_id to .song_ids file in directory """
|
||||
|
||||
hidden_file_path = os.path.join(download_path, '.song_ids')
|
||||
# not checking if file exists because we need an exception
|
||||
# to be raised if something is wrong
|
||||
with open(hidden_file_path, 'a', encoding='utf-8') as file:
|
||||
file.write(f'{song_id}\n')
|
||||
file.write(f'{song_id}\t{datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")}\t{author_name}\t{song_name}\t{filename}\n')
|
||||
|
||||
def get_downloaded_song_duration(filename: str) -> float:
|
||||
""" Returns the downloaded file's duration in seconds """
|
||||
|
Loading…
Reference in New Issue
Block a user