7

我想使用tumblr api(在收到其访问令牌后)代表用户将视频发布到 tumblr。它适用于 youtube/vimeo 视频,但在提供特定视频 url 时不起作用(实际上没有从头开始上传),例如this video。我希望我的视频可以在 tumblr 仪表板(以及用户的博客)上播放。

我正在使用以下端点:https ://api.tumblr.com/v2/blog/myblog.tumblr.com/postHere与这些参数:

params = {'type': 'video', 'caption': 'my cool video post!', 'embed': 'https://d22d7v2y1t140g.cloudfront.net/m_8386091_p64lvWa7cCG7.mov.mp4', 'format': "html"}

我怎样才能对其他类型的视频做类似的事情?

4

3 回答 3

2

这是一种推荐的方法,使用pytumblr外部库:

import pytumblr
client = pytumblr.TumblrRestClient(
    '<consumer_key>',
    '<consumer_secret>',
    '<oauth_token>',
    '<oauth_secret>',
)
# Now that you're established, look at the client.create_video method.
client.create_video(**kwargs)

要进一步了解它需要什么参数,请参阅 source,特别是datavalue,它是要上传的本地路径的字符串,或者embedvalue,它将加载您的外部托管视频的 HTML 代码部分。

有关嵌入标签应该是什么样子的信息,您可以在示例 api 的响应对象中看到它:

{
  "width": 250,
  "embed_code": "<object width=\"248\" height=\"169\"><param
     name=\"movie\" value=\"http:\/\/www.youtube.com\/
     v\/4Q1aI7xPo0Y&rel=0&egm=0&
     showinfo=0&fs=1\"><\/param><param name=\"wmode\"
     value=\"transparent\"><\/param><param name=\"
     allowFullScreen\" value=\"true\"><\/param><embed
     src=\"http:\/\/www.youtube.com\/v\/
     4Q1aI7xPo0Y&rel=0&egm=0&showinfo=
     0&fs=1\" type=\"application\/x-shockwave-flash\"
     width=\"248\" height=\"169\" allowFullScreen=\"true\"
     wmode=\"transparent\"><\/embed><\/object>"

}

于 2013-11-24T09:37:54.330 回答
1

以下是 tumblr 中视频帖子的参数

$params = array(
   'type' => 'video',
   'caption' => 'caption',
   'embed'=> '<iframe 
                 width="560" 
                 height="315" 
                 src="you youtube url" 
                 frameborder="0" 
                 allow="autoplay; encrypted-media" 
                 allowfullscreen></iframe>'
);
于 2018-06-27T07:39:49.167 回答
0

您可以通过嵌入 HTML5 视频从服务器发送视频文件,如下所示:

$params = array(
   'type' => 'video',
   'caption' => 'caption',
   'embed'=> '<video width="100%" height="auto" controls><source src="/path/to/video" type="video/mp4">Your browser does not support the video tag.</video>'
);
于 2018-08-24T18:21:23.487 回答