updated formatting

This commit is contained in:
2026-11-05 15:34:22 +00:00
parent 6be8655393
commit 4af2527ab7
2 changed files with 470 additions and 9 deletions
+79 -9
View File
@@ -39,14 +39,76 @@ def download_playlist_for_cd(playlist_url: str, output_folder: str = "cd_audio")
def download_single_video(url, song_num, artist, title):
output_folder = "cd_audio"
if not os.path.exists(output_folder):
os.makedirs(output_folder)
ytdl_opts = {
"format": "bestaudio/best",
"noplaylist": True,
"outtmpl": os.path.join(output_folder, f"{song_num} - {artist} - {title}.%(ext)s"),
"postprocessors": [
{
"key": "FFmpegExtractAudio",
"preferredcodec": "wav",
}
],
"postprocessor_args": [
"-ar", "44100", # Set sample rate to 44.1 kHz (CD Standard)
"-ac", "2", # Force 2 channels (Stereo)
"-metadata", f"artist={artist}",
"-metadata", f"title={title}",
],
"ignoreerrors": True,
}
with yt_dlp.YoutubeDL(ytdl_opts) as ytdl:
ytdl.download([url])
def parse_file(filename):
class Track:
def __init__(self, track: int, title: str, url: str):
self.track = track
self.title = title
self.url = url
class Album:
def __init__(self, artist: str, album: str):
self.artist = artist
self.album = album
self.tracks = []
def add_track(self, track: Track):
self.tracks.append(track)
with open(filename, "r") as file:
data = json.load(file)
links = data.get("yt-links", {})
return links
albums = []
for album in data:
try:
new_album = Album(
album["artist"],
album["album"])
for video in album["tracks"]:
new_album.add_track(Track(
video["track"],
video["title"],
video["url"]
))
except KeyError as e:
print(e)
continue
albums.append(new_album)
return albums
@@ -60,9 +122,17 @@ if __name__ == "__main__":
else:
data = parse_file(" ".join(sys.argv[1:]))
for album, link in data.items():
if link:
print(f"Album: {album}")
print(f"Link: {link}\n")
else:
print(f"Album: {album}\n")
for album in data:
print(f"Band: {album.artist}")
print(f"Album: {album.album}")
for video in album.tracks:
print(f"\tTrack {video.track}: {video.title}")
if album.album == "Even In Arcadia":
download_single_video(
video.url,
video.track,
f"{album.artist} - {album.album}",
video.title
)