Initial upload
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
YouTube Audio Music downLoader
|
||||||
|
|
||||||
|
|
||||||
|
$ python3 -m venv .venv
|
||||||
|
$ source .venv/bin/activate
|
||||||
|
$ pip install -r requirements.txt
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
yt-dlp
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import json
|
||||||
|
import yt_dlp
|
||||||
|
|
||||||
|
|
||||||
|
def download_playlist_for_cd(playlist_url: str, output_folder: str = "cd_audio"):
|
||||||
|
"""Downloads YouTube audio directly into 44.1kHz 16-bit WAV files
|
||||||
|
|
||||||
|
ideal for burning directly to Audio CDs without secondary re-encoding loss.
|
||||||
|
"""
|
||||||
|
if not os.path.exists(output_folder):
|
||||||
|
os.makedirs(output_folder)
|
||||||
|
|
||||||
|
ydl_opts = {
|
||||||
|
# Grab best audio stream available
|
||||||
|
"format": "bestaudio/best",
|
||||||
|
# Prefix with track index (01, 02...) so CD track order matches playlist order
|
||||||
|
"outtmpl": os.path.join(output_folder, "%(playlist_index)s - %(title)s.%(ext)s"),
|
||||||
|
"postprocessors": [
|
||||||
|
{
|
||||||
|
"key": "FFmpegExtractAudio",
|
||||||
|
"preferredcodec": "wav", # Lossless format native to CD Burning
|
||||||
|
}
|
||||||
|
],
|
||||||
|
# Enforce Red Book CD Standard audio resampling (44.1 kHz)
|
||||||
|
"postprocessor_args": [
|
||||||
|
"-ar", "44100", # Set sample rate to 44.1 kHz (CD Standard)
|
||||||
|
"-ac", "2", # Force 2 channels (Stereo)
|
||||||
|
],
|
||||||
|
"ignoreerrors": True,
|
||||||
|
}
|
||||||
|
|
||||||
|
print(f"Downloading audio optimized for CD burning: {playlist_url}")
|
||||||
|
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
||||||
|
ydl.download([playlist_url])
|
||||||
|
|
||||||
|
print("\nDownload complete! Import these .wav files directly into your CD burner.")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def parse_file(filename):
|
||||||
|
|
||||||
|
with open(filename, "r") as file:
|
||||||
|
data = json.load(file)
|
||||||
|
|
||||||
|
links = data.get("yt-links", {})
|
||||||
|
|
||||||
|
return links
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
if len(sys.argv) == 1:
|
||||||
|
url = input("Enter YouTube playlist URL: ").strip()
|
||||||
|
if url:
|
||||||
|
download_playlist_for_cd(url)
|
||||||
|
|
||||||
|
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")
|
||||||
Reference in New Issue
Block a user