Here is a working python3 program able to download songs from youtube
source in text below
import os
import sys
from pytube import YouTube
def download_audio(link):
try:
yt = YouTube(link)
audio = yt.streams.filter(only_audio=True).first()
out_file = audio.download(output_path=".")
return out_file
except Exception as e:
print("Error downloading audio:", e)
if len(sys.argv) > 1:
link = sys.argv[1]
file_path = download_audio(link)
if file_path:
print(f"Audio saved to {file_path}")
else:
print("Please provide a link as a command line argument.")
No comments:
Post a Comment