这是一种推荐的方法,使用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,特别是data
value,它是要上传的本地路径的字符串,或者embed
value,它将加载您的外部托管视频的 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>"
}