Can you tell why you can't download vimeo and youtube videos with this code? Would they have a solution?
import requests
url = "https://vimeo.com/133436413"
r = requests.get(url, stream = True)
with open("test.mp4","wb") as a:
for chunk in r.iter_content(chunk_size=1024):
if chunk:
a.write(chunk)
That's just the hosting Vimeo address,not the real download link.
Can try to scrape it out address,but this can be difficult.
Can use
youtube-dl,it's written in Python.
It's has a really big code base look at
Github.
It works for 100's of sites also Vimeo.
pip install youtube-dl
Command line:
G:\1_youtube
λ youtube-dl https://vimeo.com/133436413
Output:
.....
[download] Destination: Radiohead - Codex-133436413.fdash-fastly_skyfire_sep-video-392276614.mp4
[download] 100% of 84.77MiB in 01:21
[dashsegments] Total fragments: 49
[download] Destination: Radiohead - Codex-133436413.fdash-fastly_skyfire_sep-audio-392276614.m4a
From code:
import youtube_dl
ydl_opts = {
'format': 'bestvideo[height<=?720]+bestaudio/best',
'outtmpl': '%(title)s.%(ext)s',
'noplaylist' : True,
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download(['https://vimeo.com/133436413'])
I installed the pytube library (
https://pypi.org/project/pytube/). Do you know?
Could you tell how do I download multiple videos at the same time, having the video link?
If possible, would you be able to provide sources so that I can study?
print("Downloading...")
from pytube import YouTube
YouTube('https://www.youtube.com/watch?v=j7oQEPfe-O8').streams.first().download()
print("Finish")
https://pypi.org/project/pytube/ has examples
from pytube import Playlist
pl = Playlist("https://www.youtube.com/watch?v=Edpy1szoG80&list=PL153hDY-y1E00uQtCVCVC8xJ25TYX8yPU")
pl.download_all()
# or if you want to download in a specific directory
pl.download_all('/path/to/directory/')
(Dec-07-2019, 10:50 PM)arthur_cti Wrote: [ -> ]I installed the pytube library (https://pypi.org/project/pytube/). Do you know?
Yes,that's specific to download from Youtube and will not work for sites like Vimeo as youtube-dl do.
(Dec-07-2019, 10:50 PM)arthur_cti Wrote: [ -> ]Could you tell how do I download multiple videos at the same time, having the video link?.
If using playlist url as posted bye @
Axel_Erfurt it will download all video's in that playlist,work the same in youtube-dl.
An other way is to put url in list and loop over it,will download all in list
For all to start same time most look into Threading eg
concurrent.futures — Launching parallel tasks
arthur_cti Wrote:If possible, would you be able to provide sources so that I can study?
All code is available on Github
pytube |
youtube-dl.
For more basic web-scraping look at
Web-Scraping part-1.
@
snippsat
I have a problem with youtube_dl. Downloading is too slow (vimeo). Knew how to speed up the download, found nothing in the information document.
(Dec-08-2019, 05:21 AM)arthur_cti Wrote: [ -> ]I have a problem with youtube_dl. Downloading is too slow (vimeo). Knew how to speed up the download, found nothing in the information document.
There is nothing much you can do for a single file it depend or your network speed of host that get file from.
I have never been worried about speed as just let it run in background if eg dowlod a playlist.
What to mean bye slow?
youtube-dl https://vimeo.com/133436413
It's not super fast,but not that slow either.
Output:
[inline][download] 100% of 84.77MiB in 01:18][/inline