7

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?

limlim
  • 3,115
  • 2
  • 34
  • 46
  • Why can't you use [Video Posts](http://www.tumblr.com/docs/en/api/v2#video-posts) with an HTML5 video/Flash embed? – jazzpi Nov 24 '13 at 09:37

3 Answers3

2

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>"

}

VooDooNOFX
  • 4,674
  • 2
  • 23
  • 22
  • Thanks! It works for flash videos. Two issues left: 1. In is not compatible on mobile (non-flash player..). 2. In the tumblr dashboard there is no thumbnail picture for the video. How can I fix that? – limlim Nov 24 '13 at 11:54
  • 1
    The example showed how to embed a flash player, but you could also embed an HTML5 video player. Here's an example: http://www.newbreedmarketing.com/blog/embed-html5-video#.UpJSSGTF2aU – VooDooNOFX Nov 24 '13 at 19:25
  • Not sure if this helps, but not all video hosting sites provide thumbnails on Tumblr: http://stackoverflow.com/questions/17481898/video-posts-with-auto-thumbnaillike-in-facebook-in-tumblr-com/17544279#17544279 – mikedidthis Nov 25 '13 at 09:52
1

Below is parameter for video post in 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>'
);
amdev
  • 6,703
  • 6
  • 42
  • 64
0

You can send the video file from your server by embedding an HTML5 video like this:

$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>'
);
Uriahs Victor
  • 1,049
  • 14
  • 32