I'd like to post a video to tumblr on behalf of the user using the tumblr api (after receiving its access token). It works fine with youtube/vimeo videos, but not when giving a specific video url (without actually uploading it from scratch), such as this video. I want my video to be playable on the tumblr dashboard (and in the user's blog).
I'm using the following endpoint: https://api.tumblr.com/v2/blog/myblog.tumblr.com/postHere with these paramters:
params = {'type': 'video', 'caption': 'my cool video post!', 'embed': 'https://d22d7v2y1t140g.cloudfront.net/m_8386091_p64lvWa7cCG7.mov.mp4', 'format': "html"}
How can I do something similar for other types of videos?
Here's one recommended way, using the pytumblr
external library:
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)
For a further look into what params it takes, see the source, particularly the data
value, which is a string of a local path to upload or the embed
value, which is the section of HTML code which will load your externally hosted video.
For info on what the embed tag should look like, you can see it in the 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>"
}