Support subfolders for each disc.

Must be enabled manually in zs_config.json
This commit is contained in:
Logykk 2021-10-23 21:04:02 +13:00 committed by GitHub
parent e75ea14faa
commit 8770de741d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 63 additions and 49 deletions

View File

@ -7,5 +7,6 @@
"FORCE_PREMIUM": false,
"ANTI_BAN_WAIT_TIME": 1,
"OVERRIDE_AUTO_WAIT": false,
"CHUNK_SIZE": 50000
"CHUNK_SIZE": 50000,
"SPLIT_ALBUM_DISCS": false
}

View File

@ -118,6 +118,7 @@ def client():
print("[ DETECTED FREE ACCOUNT - USING HIGH QUALITY ]\n\n")
QUALITY = AudioQuality.HIGH
while True:
if len(sys.argv) > 1:
if sys.argv[1] == "-p" or sys.argv[1] == "--playlist":
download_from_user_playlist()
@ -310,7 +311,8 @@ def download_episode(episode_id_str):
# print("### DOWNLOADING '" + podcast_name + " - " +
# episode_name + "' - THIS MAY TAKE A WHILE ###")
os.makedirs(ZS_CONFIG["ROOT_PODCAST_PATH"] + extra_paths, exist_ok=True)
os.makedirs(ZS_CONFIG["ROOT_PODCAST_PATH"] +
extra_paths, exist_ok=True)
total_size = stream.input_stream.size
with open(ZS_CONFIG["ROOT_PODCAST_PATH"] + extra_paths + filename + ".wav", 'wb') as file, tqdm(
@ -455,7 +457,8 @@ def convert_audio_format(filename):
bitrate = "320k"
else:
bitrate = "160k"
raw_audio.export(filename, format=ZS_CONFIG["MUSIC_FORMAT"], bitrate=bitrate)
raw_audio.export(
filename, format=ZS_CONFIG["MUSIC_FORMAT"], bitrate=bitrate)
def set_audio_tags(filename, artists, name, album_name, release_year, disc_number, track_number):
@ -610,6 +613,11 @@ def download_track(track_id_str: str, extra_paths="", prefix=False, prefix_value
if prefix:
song_name = f'{prefix_value.zfill(2)} - {song_name}' if prefix_value.isdigit(
) else f'{prefix_value} - {song_name}'
if ZS_CONFIG["SPLIT_ALBUM_DISCS"]:
filename = os.path.join(ZS_CONFIG["ROOT_PATH"], extra_paths, "Disc " + str(
disc_number) + '/' + song_name + '.' + ZS_CONFIG["MUSIC_FORMAT"])
else:
filename = os.path.join(ZS_CONFIG["ROOT_PATH"], extra_paths,
song_name + '.' + ZS_CONFIG["MUSIC_FORMAT"])
except Exception as e:
@ -635,7 +643,12 @@ def download_track(track_id_str: str, extra_paths="", prefix=False, prefix_value
track_id, VorbisOnlyAudioQuality(QUALITY), False, None)
# print("### DOWNLOADING RAW AUDIO ###")
os.makedirs(ZS_CONFIG["ROOT_PATH"] + extra_paths, exist_ok=True)
if ZS_CONFIG["SPLIT_ALBUM_DISCS"]:
os.makedirs(
ZS_CONFIG["ROOT_PATH"] + extra_paths + "/Disc " + str(disc_number) + '/', exist_ok=True)
else:
os.makedirs(ZS_CONFIG["ROOT_PATH"] +
extra_paths, exist_ok=True)
total_size = stream.input_stream.size
with open(filename, 'wb') as file, tqdm(