mirror of
https://github.com/KevinMidboe/spotify-downloader.git
synced 2026-02-12 04:19:23 +00:00
Download while simultaneously encoding
This commit is contained in:
20
spotdl/helpers.py
Normal file
20
spotdl/helpers.py
Normal file
@@ -0,0 +1,20 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user