Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get video post URL #98

Open
sexavet94 opened this issue Jun 14, 2018 · 3 comments
Open

How to get video post URL #98

sexavet94 opened this issue Jun 14, 2018 · 3 comments

Comments

@sexavet94
Copy link

Hi,
When i upload video post my response is:

object(stdClass)#1151 (3) { ["id"]=> float(174874832676) ["state"]=> string(11) "transcoding" ["display_text"]=> string(75) "Your video is still processing, please wait a few minutes for it to appear." }

When video transcoding is finished , new video post id changed and https://xxxxxx.tumblr.com/post/174874832676 - link returnd "Not found".

How i can get video post id after transcoding finished?

@ravimisra
Copy link

I fear that there is no direct way to find out the URL.
Though, you can set up a poll for that as follows:
Assuming $posting_init_on initialized to the DateTime of the time when we posted the video and $source_url to the source URL for the post.

$remote_url = null;
$attempts = 0;
$found = false;
do {
    $info = $client->getBlogPosts($blogName, ['type' => 'video', 'limit' => 1]);
    if (!empty($info) && !empty($info->posts) && !empty($info->posts[0])) {
        if ($info->posts[0]->timestamp >= $posting_init_on->timestamp) {
            $url = $info->posts[0]->source_url;
            $parsed_source_url = parse_url($url);
            $query = $parsed_source_url['query'];
            if (!empty($query)) {
                parse_str($query, $parsed_query);
                if (!empty($parsed_query) && $parsed_query['z'] == $source_url) {
                    $remote_url = $info->posts[0]->post_url;
                    $found = true;
                }
            }
        }
    }
    $attempts++;
    sleep(($attempts + 1) * 5);
} while ($attempts < 15 && $found === false);

@oligriffiths
Copy link

https://xxxxxx.tumblr.com/post/174874832676 Is the correct url, however video transcoding takes a few minutes to a few hours depending upon the size of the video and how many other videos are being processed at the same time. Your best bet is to periodically check if the video url returns a non 404.

@ravimisra
Copy link

@oligriffiths, the id returned in the transcoding response is just to reference transcoding process, it never matches with the final post id.
So https://xxxxxx.tumblr.com/post/174874832676 is wrong URL for the final post.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants