File size: 294 Bytes
4b8361a
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
import requests
from pathlib import Path

def download_song(url: str, out_dir: str, file_type="mp3"):
    response = requests.get(url)
    filename = url.split("/")[-1]
    out_file = Path(out_dir, f"{filename}.{file_type}")
    with open(out_file, "wb") as f:
        f.write(response.content)