Avatar image for wcarle
Posted by wcarle (314 posts) -

We have some awesome new API endpoints for video that just went live. One for getting running livestreams, and one for getting and setting video progress!

New APIs for Livestreams and Video Progress

We have two new video endpoints we've released for you developers to start testing:

Livestream Endpoint:

Want to know when a livestream is up and get the HLS (.m3u8) stream URL for broadcast in your app? Here's how!

Just make a GET request to this here URL!

Note: You'll need the user's API key (this is a premium only feed) So you'll need your user to complete the app auth flow, more info on that here

http://www.giantbomb.com/api/video/current-live/?api_key=<API Key>

This will return a result containing the live stream info (if there is a livestream currently running):

{

"success": 1,

"video": {

"title": "Dev Test Chat",

"image": "static.giantbomb.com/uploads/original/23/233047/2911522-friday-jason03.jpg",

"stream": "https://cbsigameslive2-lh.akamaihd.net/i/upf011317jvh_1@37386/master.m3u8?set-segment-duration=responsive"

}

}

Video Saved Progress for Third Party Apps:

You know those cool little bars under the video image that tell you where you left off in the video?

No Caption Provided

You can now send time data to our API to sync the time codes your users left off on.

Save Time For Video:

GET or POST: http://www.giantbomb.com/api/video/save-time/?video_id=<ID_OF_VIDEO>&time_to_save=<TIME_IN_SECONDS>&api_key=<USERS_API_KEY>

Retrieve Saved Time For Video:

GET: http://www.giantbomb.com/api/video/get-saved-time/?video_id=<ID_OF_VIDEO>&api_key=<USERS_API_KEY>

Result:

{

"success": 1,

"savedTime": "1516"

}

You can use these APIs to get the user's synced time from the site and submit your own, so a user can start watching the video on the site, continue where they left off on your app, then come back to the site to finish it later!

As a best practice I would recommend only calling the save-time endpoint only every 5 seconds or so, let's not send a billion requests to our servers as the user watches a video :)

If you have any problems or questions about these APIs please let me know! We'll be updating the official API docs with this info once we have all the problems sorted out!

Happy Programming!

Staff
Avatar image for alecgdouglas
#1 Posted by alecgdouglas (91 posts) -

Oh wow, this is huge! Can't wait to start integrating these features into my app. Awesome work.

Avatar image for szlifier
#2 Edited by Szlifier (1456 posts) -

Yes! Thanks for the video progress stuff, I already have some ideas for using this data.

It's surprising to see you exposing the stream URL officially. What are the rules for using it? Mobile only?

How about bulk list of saved progress? That would allow something like "Continue watching" on Netflix with a list of recently watched stuff.

Avatar image for scott-r
#3 Posted by Scott-R (11 posts) -

This is ace! I was already working on my own limited playback position syncing stuff, so this is great to see!

Avatar image for spencer
#4 Posted by Spencer (330 posts) -

This is the best. THANK YOU

Avatar image for wcarle
#5 Posted by wcarle (314 posts) -

@szlifier: we have had devs asking for that feature for a long time. I like to try and be more open whenever possible. We've put it behind API authentication so hopefully it won't be a problem. If we see any problems we'll just have to track down the API keys being used and ban them. Worst case scenario we can enable authentication on the stream URL itself but hopefully it won't come to that. As far as rules for using we would like to see it only used in apps like mobile and set top boxes, if we see sites re-hosting our content for free we'll have to shut down those API keys.

Staff
Avatar image for alecgdouglas
#6 Posted by alecgdouglas (91 posts) -

@szlifier: Getting a bulk list of saved progress would be great. Something like http://www.giantbomb.com/api/video_progress/?api_key=<USERS_API_KEY> that returns a list of all videos (just the IDs would suffice?) that user currently has progress for and the progress for each video.

Avatar image for wcarle
#7 Posted by wcarle (314 posts) -

@alecgdouglas: That's a good point, we're investigating that functionality for the site but aren't there yet, as soon as that functionality is available on the site we'll create an API for it!

Staff
Avatar image for szlifier
#8 Posted by Szlifier (1456 posts) -

@wcarle: Hey, I tried to use the video progress stuff on my site, but JSONP seems to be missing, so I can't make any requests from the client side.

Avatar image for thing2
#9 Posted by Thing2 (21 posts) -

Awesome! Perfect timing to roll support for this into our new app. Great work!

Avatar image for wcarle
#10 Posted by wcarle (314 posts) -

@szlifier: Ah good point, didn't think about JSONP for that one, I'll get that in there soon!

Staff
Avatar image for thing2
#11 Edited by Thing2 (21 posts) -

I'm rolling this in today,

@wcarle - Is it too late to change this?

GET Response for an id which you have no saved time returns "savedTime" as an int.

{

"success": 1,

"savedTime": -1,

"message": "No saved time for this video id"

}

--- GET Response for an id which you have saved some time against - returns a string with a Float or Double? Is it possible to unify and get them to both return the same type? Not a big thing but it'd be slightly nicer for those of us using statically typed languages.

{

"success": 1,

"savedTime": "20.186404"

}

Update: S'fine really, I support both now - leaving up in case you find the suggestion useful for some future enhancement. Working perfectly btw :D

Avatar image for trision
#12 Edited by Trision (188 posts) -

@wcarle Are you planning on adding "last updated" timestamps to the video progress API? Should make syncing more robust, as apps can then discard out of date progress (in cases where the user was offline then came back online).

Avatar image for szlifier
#13 Edited by Szlifier (1456 posts) -

@wcarle: Hey, just wanted to ask again for JSONP for get-saved-time. I can't really utilize this great feature on a website without it.

And since you already implemented the Continue Watching idea, how about making that list available through API? :)

I also have another request. It's not urgent, but I would love to have it.

Almost all videos and most podcasts (and podcast videos) are attached to wiki pages, mostly game pages. It would be great to have those associated wiki pages in the video endpoint. For example: the API info for Quick Look: Snake Pass would include "3030-57504" - indicating a game resource and the id.

Right now it's only possible the other way around. A game info in the API includes videos, podcasts and other wiki resources. EDIT: It looks like podcasts are not included in that list, only video versions of podcasts. Unfortunately this can only be done on a per-game basis (/game and not on /games).

This is something I've been asking for a very long time and it would be an awesome thing to have for my site. It would make game <-> video associations finally complete. Thanks.

Avatar image for wcarle
#14 Posted by wcarle (314 posts) -

@szlifier: Hey, sorry I forgot to post about the updated endpoints, JSONP should now work:

http://www.dev.giantbomb.com/api/video/get-saved-time/?video_id=11863&format=jsonp&callback=asdf

The get saved times api is available here (but it doesn't currently include the video information):

http://www.dev.giantbomb.com/api/video/get-all-saved-times/?format=jsonp&callback=asdf

I'll put that other API Request in on the list!

Staff
Avatar image for szlifier
#15 Posted by Szlifier (1456 posts) -

@wcarle: Thanks! This is fantastic.

Looks like the api key isn't required if you're logged in on GB in that browser. Cool stuff. I implemented it already on QLCrew.

Avatar image for alecgdouglas
#16 Posted by alecgdouglas (91 posts) -

@wcarle:That get-all-saved-times API is exactly what I was hoping for.

Quick question: the "savedOn" field - does that have a fixed timezone? (PST I'm guessing?)

Avatar image for alecgdouglas
#17 Posted by alecgdouglas (91 posts) -

@wcarle: Any plans to add the ability to delete/reset progress on a video?

I currently have that functionality in my app with saved time stored locally and I'm not sure how provide the same functionality with the save-time API since passing in time_to_save=0 fails (returns success = false).

Using time_to_save=-1 works fine (I could ignore results from get-saved-time/get-all-saved-times if savedTime = -1) but I don't want to be using the API in an unintended way and modifying user data to invalid values.

Avatar image for wcarle
#18 Posted by wcarle (314 posts) -

@alecgdouglas: Yes saved on is set to PT. We don't currently have a way to reset progress. I'm not sure why it's failing when you set it to 0, I'll look into that

Staff
Avatar image for alecgdouglas
#19 Posted by alecgdouglas (91 posts) -

@wcarle: Thanks for looking into it.

Regarding the live API, I've noticed that it's pretty consistently returning a result long after the live stream is actually over (e.g. Giant Beastcast is advertised as live via the API for many hours after the stream ends), and sometimes long before a live stream has actually started (e.g. it's been returning the April 28 GBE Playdate video as the live stream URL since last night with the title "GBE Megadate" which doesn't start until 11 AM today).

This is a bummer since there's not really a good way for an app to know if the current-live API is returning an actual live stream or not, which results in my app basically deceiving and confusing users by saying there's a live stream ongoing when there actually isn't.

Are there any plans to tighten up the results of the current-live API?