Getting Video ID
|
|
How does one get the VideoID of a video which has just been uploaded via the API? So, my user uploads his video directly to HW via a form on my site. I want to show him an encode link, but I need to know the VideoID for that video. How do I find it out if there are several other raw videos which have been uploaded by other users? |
|
|
When a video has been uploaded from your site, you will receive a ping (if you enable it) with all the info about the new video (including the video id). See the howto on the wiki, it will help you. |
|
|
this should probably be a post in the suggestions forum, but: having to develop/enable a REST API just to get the video ID seems like a big hurdle, or maybe I am missing something (and as a never-as-smart-as-I’d-like-to-be developer, I find it a lot easier to use an API than to develop/provide one). if the typical use case is to upload a video, have it encoded and get it back to me… then I really should be able to predict the filename of the encode right from the upload point, either from a) info I provide you in my upload, or b) by a response I get from you after the upload. EXAMPLE: I set up auto FTP transfer, perhaps even auto-encode. I then use the API or a form to upload a video. Either the response or (if I used a form) the querystring/post of the success redirect should give me an ID or a “name”. If I either i) code my app to issue an encode request after the upload, or ii) have my user on the redirect page trigger the encode, or iii) have set up auto encoding, I should expect that when things are done (encode/FTP), I will find a file in my FTP folder called something like VIDEOID_ENCODEID.mov or VIDEONAME_ENCODEID.flv or something like that. If I am having my user upload a video as part of some user “post” (like a blog, etc.) then I want to be able to build that blog post in my app right then and there. I can’t really – at least not without developing an api to respond to the ping. I need to wait and do some back-and-forth stuff to figure out what my final video path/filename will be. I don’t mind that the video won’t be available right away (when people try to access it, I can do a simple file check (or API check) and give a ‘waiting’ status if the video isn’t ready yet), but I would like to know what it will be called when it gets here. |
|
|
If you activate the ping after upload, you will receive something like this:
You have the video id: 1018. When you receive a ping after encode, you get the filename. So, you should find the encoded video by this filename easily in your FTP. Note that the thumb is uploaded too: filename.jpg |
|
|
I did see that. It’s just that an intermediate developer would have a much easier time extracting the info (video ID) from the response (either the upload API call, or a form > success redirect). An intermediate developer will be far more intimidated by trying to develop a page or API that reacts, parses and extracts from your ping and marries the upload_ID to the upload API call that just finished, then marry the video ID to the user post on their site. I’d like to think I am a bit better than “intermediate”, and I am intimidated. Bruno, do you have any simple sample code of what a PHP page might look like at the ping-after-upload URL, as far as parsing the mix of array + XML you send back? It’s also unfortunate that auto-encode (and auto FTP) is an option, but tracking encoded video by the upload_ID isn’t possible. Not much saved if you have to get the video ID from the upload ID, and then get the encoded video ID from the video ID. |
|
|
If I decided to marry XML and parameters, it is because you maybe need other info than the ID. Instead of pinging http://heywatch.com/video/ID.xml, you have all the info directly. The upload_id you receive by ping is not important for you. The most important is the “your_site_user_id”, having this value, you can do the relation between the video object and the user (from your site). To get what you want is easy (not tested):
So, I don’t see the point. Unfortunately, I have no complete PHP sample, I’m not a PHP guy :) Here is the whole process, maybe you will understand it better: If you upload from the disk (3 steps):
If you transfer from the web (4 steps):
Keep in mind that automatic encode and send to FTP/S3 are for general purpose and you can’t track all the process that way. If you need to track from the beginning to the ending or need something more specific, you have to do it ‘manually’ and follow the steps I wrote. |
|
|
thanks for the reply.
perhaps I missed something:
are you saying that the upload already does return info about the video (in the form of a response)? or are you just talking about the xml ping? as per “your_site_user_id” being the important thing, I am seeing videos being married to “posts” on my site, not just users. Ideally, I want the user – perhaps in a multistep form – to upload, then add description, tags, etc. I’d like to build the post right then, right there, and know that I can expect to find the encoded video id when it is ready. “your_site_user_id” may be problematic if the user uploads several videos in a short span – will I have trouble marrying the right video to the right ‘post’ on my end. I think I can do everything else I need to by contacting your API and without building my own an API to parse the XML ping, except for getting my hands on the video ID. A different perspective, I suppose, and obviously I am working from a phobia around building an API to react to your ping (as opposed to parsing a simple response to the original upload request). I suppose I could re-purpose “your_site_user_id” as “post_id” from my end. Bruno, I have to say I am impressed with your API and your involvements in these forums. Thanks for the discussion. |
|
|
Yes, when the upload is done, you’ve get in response the new video in XML with all the info, no need of ping. But you want your users upload directly from your site via an HTML form, so the only possibility is the ping. In fact, you can put whathever you want in custom parameters. In your case, of course post_id, user_id are the fields you must include in the form to track the process. It’s really simple, following what you said:
“your_user_id” is just an example ;) The custom parameters are unlimited, you can put all you want. Via this form, you will receive all the values via the ping request. You can track your user, the post and the raw video. To continue the process: Lets say you have a hwjob table (id, user_id, post_id, video_id, job_id[default=NULL], encoded_video_id[default=NULL])
It’s just an example, I don’t know what you’re trying to do, but I think you have the key ;) |