Vimeo API:获取下载所有视频文件的链接列表 [英] Vimeo API: get a list of links for downloading all video files

查看:38
本文介绍了Vimeo API:获取下载所有视频文件的链接列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

美好的一天.

我正在尝试从 Vimeo 帐户获取所有视频文件的列表(指向直接下载的链接).

I'm trying to get a list of all video files (links to direct downloading) from Vimeo account.

有没有办法在 1 个 GET 请求中做到这一点?好的,如果是 API 限制,则为 100 次.

Is there a way to do it in a 1 GET request? OK, times to 100, if it is restriction of API.

我有硬编码脚本,我在其中发出 12 个 GET 请求(1100 多个视频,根据文档,请求受 100 个结果的限制),然后发出超过 1000 个请求以接收直接链接.

I had hardcoded script, where I am making 12 GET request (1100+ videos, according to documentation, request is limited by 100 results), and then making over 1 000 requests to receive direct links.

有没有办法通过向服务器发出一个 API 请求来接收从 Vimeo 下载 videous 的链接列表?

PS 帐户是专业版

import vimeo
import json
import config #token is here

client = vimeo.VimeoClient(
    token = config.token
)
per_page = 100
answerDataAll = []
for i in range(12):
    page=i+1
    getString = 'https://api.vimeo.com/me/videos?per_page='+str(per_page) + '&page=' + str(page)
    dataFromServer = client.get(getString).json()['data']
    answerDataAll.extend(dataFromServer)    

# creating list of videos
listOfItems = []
for item in answerDataAll:
    listOfItems.append( item ['uri'])

# creating list of direct links, it is the goal
listOfUrls = []

for item in listOfItems:
    # isolating digits
    videoID = ""
    for sign in item:
        if sign.isdigit():
            videoID = videoID + sign 

    requestForDownloading = client.get ('http://player.vimeo.com/video/' + videoID + '/config').json()['request']['files']['progressive']
    for itm in requestForDownloading:
        if itm['width']==640:
            urlForDownloading = itm['url']
            listOfUrls.append(urlForDownloading)

推荐答案

每个请求最多可以获取 100 个视频,但要了解像/me/videos 这样的请求将返回每个视频的完整元数据,即大量数据需要解析.当 Vimeo 的服务器尝试呈现您的请求时,API 或您的客户端也可能会超时.

You can get up to 100 videos per request, but understand that a request like that to /me/videos will return the full metadata for each video, which is a lot of data to parse through. The API or your client may also timeout while Vimeo's servers try to render your request.

您应该使用 fields 参数,以便只返回您需要的下载元数据.您还应该指定排序和方向,以便您知道视频返回的确切顺序.请求 uri 的格式应如下所示:

You should use the fields parameter so that only the download metadata you need is returned. You should also specify the sort and direction, so you know exactly order the videos should be returning in. The request uri should be formatted like this:

https://api.vimeo.com/me/videos?fields=uri,name,download&page=1&per_page=100&sort=date&direction=desc

可以在此处找到这些参数的文档:

Documentation of those parameters is found here:

https://developer.vimeo.com/api/common-formats#json-过滤器

https://developer.vimeo.com/api/common-formats#using-the-pagination-parameter

https://developer.vimeo.com/api/common-formats#using-the-sort-parameters

这篇关于Vimeo API:获取下载所有视频文件的链接列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆