Liam Green-Hughes

getting clips and trailers into atlas

I’ve been working on a feature that allows clips from YouTube to be linked to programmes in Atlas. From a user perspective the process to link clips to programmes has been designed to be as easy as possible. From a technical perspective the work has thrown up a few challenges as integrating systems often does.

simple for the user

We have tried to keep the process as simple as possible from a user perspective. Every programme in Atlas is assigned an alphanumeric ID making it easy to reference a programme. To link a YouTube hosted clip to an Atlas item the user does not need to leave the YouTube video editor, they can assign a tag to the item in the form of “atlas:” followed by the unique ID. We have an internal system called Coyote which can send metadata from YouTube to Atlas. Coyote can now see that specially formatted tag and construct a clip for a programme and post this to Atlas.

accessing youtube tags

It is possible to access most of the metadata about a video on YouTube with an API key. However, one piece of metadata that will be missing is the tags! This is because YouTube decided to make tags a private property to help improve their search algorithms. In order to get the tags from YouTube we have to authenticate the request to the API as the user who owns the video.

Thankfully it is possible to do this with OAuth. A small application was built that enabled users to log into their YouTube account and provide us with an OAuth token that we can use to access the tags. OAuth has many advantages. Firstly, it avoids the need to store username and password combinations which is a potential security risk. Secondly, it puts the user firmly in control. They can revoke our access to their YouTube account at any time and for any reason. Thirdly, it allows to the scope of the access to be limited, so users can see that we are only reading information.

Interestingly YouTube uses refresh tokens, so when an OAuth token is issued it is typically only valid for an hour. An additional call has to be made to obtain a fresh token before any other calls can be made. Coyote was upgraded with code to check and refresh OAuth tokens so that we could access the private tag information.

Finding out the channels for a user from the YouTube API meant that we could relate channels to OAuth keys. When Coyote sees a video with one of these channels, it now knows to access the metadata using the OAuth token instead of using an API key.

sending the clip to atlas

Coyote takes data from YouTube, converts it into the Atlas format and POSTs the data over HTTP to Atlas. Normally it would take the video and turn it into a standalone item for Atlas but it has now been modified so that when it sees one of the specially constructed Atlas tags it triggers a “clips mode”. When this mode is being used for an item Coyote will post an item to Atlas that has most elements absent apart from one clip. The information for the clip is created from the metadata for the video.

Atlas has a feature, called equivalence where it is able to merge information from several different sources together to provide one item with merged data. Thanks to this Coyote does not need to know the information for the parent item, instead it can set an explicit equivalence for the item which tells Atlas directly the the item should be linked to another item when it is merging data. This allows a user of Atlas to get complete information for the item including a clip.

the future

We are excited about this feature and work is in progress to expand it. Work is being carried out to add the capability for users to link their YouTube accounts to Atlas through the new self service Atlas Admin web application. We also have many more ideas about how to use Atlas to bring YouTube and the broadcast world a little bit closer together for TV channels.

If you would like to know more about this work or have any comments on it please get in touch by leaving a comment below or chatting to us on Twitter.

blog comments powered by Disqus