Files
spotify-downloader/spotdl/helpers.py
2020-03-23 18:29:23 +05:30

21 lines
526 B
Python

import subprocess
import threading
def download(url, path=".", progress_bar=True, ):
command = ("ffmpeg", "-y", "-i", "-", "output.wav")
content = pytube.YouTube("https://www.youtube.com/watch?v=SE0nYFJ0ZvQ")
stream = content.streams[0]
response = urllib.request.urlopen(stream.url)
process = subprocess.Popen(command, stdin=subprocess.PIPE)
while True:
chunk = response.read(16 * 1024)
if not chunk:
break
process.stdin.write(chunk)
process.stdin.close()