gpt4 book ai didi

python - 如何使用 Tumblr API 将嵌入的视频发布到 Tumblr?

转载 作者:太空狗 更新时间:2023-10-29 21:55:19 26 4
gpt4 key购买 nike

我想代表用户使用 tumblr api 将视频发布到 tumblr (在收到其访问 token 后)。它适用于 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"}

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

最佳答案

这是一种推荐的方法,使用 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)

要进一步了解它需要哪些参数,see the source ,特别是 data 值,它是要上传的本地路径的字符串或 embed 值,它是将加载外部托管视频的 HTML 代码部分。

有关嵌入标签应该是什么样子的信息,您可以在 response object of the example 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>"

关于python - 如何使用 Tumblr API 将嵌入的视频发布到 Tumblr?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20172736/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com