-
-
Save alexeygrigorev/a1bc540925054b71e1a7268e50ad55cd to your computer and use it in GitHub Desktop.
import requests | |
import base64 | |
from tqdm import tqdm | |
master_json_url = 'https://178skyfiregce-a.akamaihd.net/exp=1474107106~acl=%2F142089577%2F%2A~hmac=0d9becc441fc5385462d53bf59cf019c0184690862f49b414e9a2f1c5bafbe0d/142089577/video/426274424,426274425,426274423,426274422/master.json?base64_init=1' | |
base_url = master_json_url[:master_json_url.rfind('/', 0, -26) + 1] | |
resp = requests.get(master_json_url) | |
content = resp.json() | |
heights = [(i, d['height']) for (i, d) in enumerate(content['video'])] | |
idx, _ = max(heights, key=lambda (_, h): h) | |
video = content['video'][idx] | |
video_base_url = base_url + video['base_url'] | |
print 'base url:', video_base_url | |
filename = 'video_%d.mp4' % video['id'] | |
print 'saving to %s' % filename | |
video_file = open(filename, 'wb') | |
init_segment = base64.b64decode(video['init_segment']) | |
video_file.write(init_segment) | |
for segment in tqdm(video['segments']): | |
segment_url = video_base_url + segment['url'] | |
resp = requests.get(segment_url, stream=True) | |
if resp.status_code != 200: | |
print 'not 200!' | |
print resp | |
print segment_url | |
break | |
for chunk in resp: | |
video_file.write(chunk) | |
video_file.flush() | |
video_file.close() |
install python to your system, then in command line run
python -m pip install requests tqdm moviepy
save code above to vimeo.py file, then run
python vimeo.py
**Thanks a lot man!
By any chance is there a possibility to create a script in which we paste a bunch of original Vimeo URLs and it goes and retrieves the playlist.json and master.json link types for us and then proceeds to download them with a predefined mp4 output? (I have tons of videos to download, I'm tired boss...)**
install python to your system, then in command line run
python -m pip install requests tqdm moviepy
save code above to vimeo.py file, then run
python vimeo.py
**Thanks a lot man!
By any chance is there a possibility to create a script in which we paste a bunch of original Vimeo URLs and it goes and retrieves the playlist.json and master.json link types for us and then proceeds to download them with a predefined mp4 output? (I have tons of videos to download, I'm tired boss...)**
I wrote something like this quite a while back..i have no idea fi it is still working though. if it isnt pretty sure if you are famaliar with python it is just a liitle modiifcation that would be required. https://github.com/plutack1/vimeo-audio-video
I also have a problem with the new format of the vimeo vids. I usually use youtube-dl-web vercell online site and when the code is “master.json”, i just replace json with mpd and it works perfectly. But new one is “playlist.json?omit……” and it does not work at all. Is there any simple method using replacement as it was before? Thx!
I also have a problem with the new format of the vimeo vids. I usually use youtube-dl-web vercell online site and when the code is “master.json”, i just replace json with mpd and it works perfectly. But new one is “playlist.json?omit……” and it does not work at all. Is there any simple method using replacement as it was before? Thx!
Use the script posted above by @kbabanov
You need to install Python on your system tho, ChatGPT is your friend to compile it.
merging the streams with moviepy is slow because it does unnecessary conversions. You can use ffmpeg to just assemble an mp4 file copying the streams without conversion
subprocess.run(['ffmpeg', '-i', 'video.mp4', '-i', 'audio.mp4', '-c:v', 'copy', '-c:a', 'copy', name])
then you can delete these lines
video_clip = VideoFileClip(video_tmp_file)
audio_clip = AudioFileClip(audio_tmp_file)
video_clip_with_audio = video_clip.set_audio(audio_clip)
video_clip_with_audio.write_videofile(name)
Of course it does create a dependency to an external command but it is worth the time saving.
Also, I've just noticed that downloading a master.json type stream (the one that just offloads the download to youtube-dl, generates a video file without audio =(.
install python to your system, then in command line run
save code above to vimeo.py file, then run