I have a website that runs on node.js and express on the back end that in turn calls .py
script to download a user-requested audio using yt-dlp. When I run the website on the localhost, everything runs perfectly, and I get a .mp4 downloadable url that can be fed right into the JavaScript audio.
However, when I deploy my website on Heroku, the same .py
script gives me a .m3u8 url which is an audio playlist, and it requires extra steps such as hls
to be played with JavaScript.
My question is why this happens.
My Heroku buildpack contains nodejs
and python
. Am I missing FFmpegExtractAudio
here or some yt-dlp formatting options below?
My .py
script is
ydl_opts = {
'format': 'bestaudio/best',
'quiet': True,
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],}
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
try:
info = ydl.extract_info("ytsearch:%s" %
requestedAudio, download=False)['entries'][0]
# code follows...
except yt_dlp.utils.DownloadError or yt_dlp.utils.ExtractorError:
# code follows...