Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Import youtube_dl.YoutubeDL External Python Program #4662
Comments
|
This is not documented anywhere so it may change in the future:
import youtube_dl
ydl_opts = {
'format': 'bestvideo+bestaudio/best'
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
test_url = 'http://www.youtube.com/watch?v=BaW_jenozKc'
info = ydl.extract_info(test_url, download=False)
if info.get('requested_formats') is not None:
# we got DASH formats
video_format, audio_format = info['requested_formats']
video_url = video_format['url']
audio_url = audio_format['url']
else:
video_url = info['url']
|
|
Thank You for the helpful code, however; this version appears to ignore the "download=False" and continues to download. |
|
It works fine here (and should work with quite old versions), could you run this script and post the output?: from youtube_dl.version import __version__
print('version: %s' % __version__)
import youtube_dl
ydl_opts = {
'format': 'bestvideo+bestaudio/best',
'verbose': True,
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
test_url = 'http://www.youtube.com/watch?v=BaW_jenozKc'
ydl.print_debug_header()
info = ydl.extract_info(test_url, download=False)
if info.get('requested_formats') is not None:
# we got DASH formats
video_format, audio_format = info['requested_formats']
video_url = video_format['url']
audio_url = audio_format['url']
else:
video_url = info['url']Posting the script you are using would help. |
|
Sorry, my mistake...forgot to disable a bash script that was calling youtube-dl. The code works perfectly!!! Now to figure out how to combine the audio and video. I ran youtube-dl with the --verbose option, which gave me the command to use. This allows me to combine the wonderful Web and Android GUI of pyLoad with the powerful extractor of youtube-dl. |
|
Cool, I can make use of all these available options in ydl_opts. Available options:
|
|
One last question... Looks like there is a progress hook. Can I get that percentage using this code? Thank You |
|
Yes: def hook(ph):
percent = float(ph['downloaded_bytes'])/float(ph['total_bytes']) * 100.0 |
|
Thanks again. |
Hi,
So I am integrating youtube-dl with the Youtube plugin for the PyLoad download manager, because youtube-dl supports DASH video.
I have the code working below. Questions:
If not, I can just check for DASH and call the code below a 2nd time with "bestaudio" for the 'format'
"youtube-dl -f 137+bestaudio/best --youtube-include-dash-manifest --prefer-ffmpeg https://www.youtube.com/watch?v=B99SxGxHs6U"
Can I still leverage the youtube-dl post-processor to merge the video and audio using the code below? I realize using PyLoad external download manager may have created problems with timing for merging. Youtube-dl downloads the video 1st and then calls the postprocessor after the audio is downloaded and merges.