Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Youtube_dl extract mp3 file
-
Good day,
I just copied a simple code from a YouTube tutorial that is supposed to download the mp3 file of any YouTube video. Here’s my code:from __future__ import unicode_literals import youtube_dl import os from sys import argv # Download data and config download_options = { 'format': 'bestaudio/best', 'outtmpl': '%(title)s.%(ext)s', 'nocheckcertificate': True, 'postprocessors': [{ 'key': 'FFmpegExtractAudio', 'preferredcodec': 'mp3', 'preferredquality': '192', }], } # Song Directory if not os.path.exists('Songs'): os.mkdir('Songs') else: os.chdir('Songs') # Download Songs with youtube_dl.YoutubeDL(download_options) as dl: with open('../' + 'songs.txt', 'r') as f: for song_url in f: dl.download([song_url])
The issue is the line key': 'FFmpegExtractAudio',
Kassenerfolg it is because I do not have Libav installed. Stash doesn’t find the package release urls. Does anyone know how to fix this?
Thanks a lot -
Cant use ffmpeg on ios.
But I think you ought to be able to download the m4a without converting. Try getting rid of those post processing steps.I think iOS supports m4a audio directly.
-
Great thanks a lot,
I made it work. The only issue is that the downloaded files are 7 min long, whereas the Original Video is about 3-4 min long. Therefore he file has about 3 min without any sound. Any idea why?from __future__ import unicode_literals import youtube_dl import os from sys import argv # Download data and config download_options = { 'format': 'm4a', 'outtmpl': '%(title)s.%(ext)s', 'nocheckcertificate': True, 'preferredcodec': 'best', } # Song Directory if not os.path.exists('Songs'): os.mkdir('Songs') else: os.chdir('Songs') # Download Songs with youtube_dl.YoutubeDL(download_options) as dl: with open('../' + 'songs.txt', 'r') as f: for song_url in f: dl.download([song_url]) print('done')
-
The same code work for converting soundcloud to mp3 file?
-
@donaldcassey yes it should work with soundcloud. I didn’t test it, but the module contains a file for extracting data from soundcloud. If you want to use this, just copy the code into a new directory and create a file called ‘songs.txt’ . Then paste every link into a new line in the text file. The code does not work if the file contains empty lines, but you can fix that with by replacing
dl.download([song_url])
with
if not “\n” in song_url: dl.download([song_url])
-
This post is deleted! -
This post is deleted! -
This post is deleted! -
This post is deleted! -
This post is deleted! -
This post is deleted!