Universal Syndication Template Language

The Universal Syndication Template Language (USTL) enables you to create asset templates in any format that meets your needs. For example, you can create a list of assets and their metadata in an XML, JSON, CSV, or any other text format.

Description

The USTL is based on Liquid. Language design details are available online.

Note: To create a feed, you must create a universal syndication. After you create the syndication, you upload the template by performing a put against the syndication with the template in the body of the request. For more information, see Syndications
Note: If Universal Syndication is not enabled on your account, contact Sales, your Customer Success Manager, or Technical Support.

Asset Properties

The following table lists the asset attributes that you can display.

Route Attribute Description
asset.name Name of the asset
asset.description Description of the asset
asset.metadata["key"] Metadata for the asset. If you specify the key, only that key's metadata is returned.
asset.duration The duration of the asset
asset.external_id The identifier of an asset used in a system external to Ooyala
asset.flight_start_time The start time when the asset can be played
asset.flight_end_time The end time when the asset can be played
asset.created_at When the asset was created
asset.updated_at When the asset was most recently updated
asset.embed_code The embed code or content ID for the asset
asset.asset_type The type of asset
asset.hosted_at The permanent URL where you embed the video
asset.uploaded_by_user User that uploaded the video
asset.aspect_ratio The ratio of width to height of the picture format
asset.original_file_name Name of the original file
asset.closed_captions_url URL of the closed captions file
asset.status The status of the asset
asset.streams The Flash streams associated with the asset. Not applicable for remote assets.
asset.abr_stream_urls The ABR streams associated with the asset. Not applicable for remote assets.
asset.abr_stream_urls.iphone The iPhone-compatible ABR streams associated with the asset. Not applicable for remote assets.
asset.abr_stream_urls.ipad The iPad-compatible ABR streams associated with the asset. Not applicable for remote assets.
asset.stream_urls The URLs for streams associated with the asset. Not applicable for remote assets.
asset.streams.audio_codec The audio codec associated with the asset. Not applicable for remote assets.
asset.streams.container The container associated with the asset (MP4, 3GP, and so on) . Not applicable for remote assets.
asset.streams.file_size The size of the stream, in bytes. Not applicable for remote assets.
asset.streams.url The URL of the stream. You cannot filter on this attribute. Not applicable for remote assets.
asset.streams.video_bitrate The bit rate of the stream, in Kbps (kilobits per second). Not applicable for remote assets.
asset.streams.video_codec The video codec associated with the asset. Not applicable for remote assets.
asset.streams.video_height The height of the stream, in pixels. Not applicable for remote assets.
asset.streams.video_width The width of the stream, in pixels. Not applicable for remote assets.
asset.stream_urls.flash Remote assets only. The URL of the Flash stream.
asset.stream_urls.iphone Remote assets only. The URL of the iPhone stream.
asset.stream_urls.ipad Remote assets only. The URL of the iPad stream.
asset.stream_urls.itunes Remote assets only. The URL of the iTunes stream.
asset.stream_urls.source_file Remote assets only. The URL of the source stream. The source is used as a fallback if the device is not capable of playing any of the other defined streams.
asset.preview_image.url The URL of the preview image
asset.preview_image.width The width of the preview image, in pixels
asset.preview_image.height The height of the preview image, in pixels
label.id The identifier of a lable
label.name A label's name
label.full_name A label's full name
asset.primary_entry_point Live streams only. URL for stream.
asset.backup_entry_point Live streams only.
asset.is_flash Live streams only. Stream is for Flash player.
asset.is_ios Live streams only. Stream is for iOS device.
asset.encodings Live streams only. Stream encodings.
asset.labels The collection of labels for an asset.
assets.first The first asset in the collection.
assets.last The last asset in the collection.
labels.first The first label in the collection.
labels.last The last label in the collection.

Output Markup

Output markup enables you to display asset properties. For example:

"{{asset.name}}" was a great movie.
As your closest friend, I recommend that you see it right away.
{{asset.description}}
It is only {{asset.duration}} minutes long.
   

You can also apply transformations to the output. For example:

WATCH "{{asset.name | upcase}}" RIGHT NOW!!! 
   

The following table lists output markup and provides example input and output:

Markup Description Example Input Example Output
capitalize Capitalizes words in the input sentence {{'hello' | capitalize }} Hello
downcase Converts string to lowercase {{'Hello' | downcase }} hello
upcase Converts string to uppercase {{'hello' | upcase }} HELLO
size Returns the size of the string {{'hello' | size }} 5
strip_html Strips HTML from the string {{'<p>hello</p>' | strip_html }} hello
strip_newlines Strips newlines (\n) from the string {{'hello \n hello \n hello' | strip_newlines }} hello hello hello
newline_to_br Replaces newlines (\n) with an HTML break (<br/>) {{'hello \n hello \n hello' | newline_to_br }} hello <br/> hello <br/> hello
replace Replaces each occurrence within the string. {{'hello' | replace:'goodbye' }} goodbye
replace_first Replaces the first occurrence within the string. {{'goodbye goodbye' | replace_first:'hello','goodbye' }} hello goodbye
remove Removes each occurrence within the string. {{'hello goodbye' | remove:'goodbye' }} hello
remove_first Removes the first occurrence within the string.. {{'hello hello hello' | remove_first:'hello ' }} hello hello
truncate Truncates the string. {{'goodbye' | truncate:4 }} good
truncatewords Truncates the string to the specified number of words. {{ 'My name is Matt and I would like to talk with you about the miracle of multi-level marketing' | truncatewords:4 }} My name is Matt
prepend Prepends the specified text to the string. {{ 'goodbye' | prepend:'hello ' }} hello goodbye
append Appends the specified text to the string. {{ 'hello' | append:' goodbye' }} hello goodbye

Tag Markup

Tag markup enables you to apply logic to your template. Tag markup includes the following:

  • for
  • if
  • case/when
  • unless
  • comment

The following table lists tag markup and provides example input and output:

Logic Description Example Example Output
for Loops over collections.
{% for asset in assets %}
  {{ asset.name }}: {{ asset.duration }} minutes
{% endfor assets %}  
    

Lord of the Rings Trilogy: 560 minutes Lord of the Rings Special Extended Edition: 718 minutes

if/else Displays information if conditions are met.
{% for asset in assets %}
   {% if asset.name == "Blade Runner" and asset.duration = 117 %}
     {{ asset.name }} is a great movie!
   {% elsif asset.name == "Blade Runner" and asset.duration = 116 %}  
     You really should watch the 25th Anniversary Edition of {{ asset.name }}.
   {% else %}
     {{ asset.name }} is an okay movie.
  {% endif %}
{% endfor assets %}     
    

Blade Runner is a great movie!

when Conditionally displays content
{% for asset in assets %}
Name: {{ asset.name }}
{% case template %}
{% when "description" %}
Description: {{ asset.description }}
{% endcase %}
{% endfor assets %}   
     

Blade Runner Deckard, a blade runner, has to track down and terminate four replicants who hijacked a ship in space and have returned to earth seeking their maker.

comment Comments out information.
There are some things that you know{% comment %} 
and others that you don't{% endcomment %}.

There are some things that you know.

Stream and Preview Image Filters

You can apply filters to limit the results returned for streams and preview images.

Filters accept the following:

  • =
  • >
  • <
  • >=
  • <=
  • max
  • min

The following examples return the URL for the preview image if the filtering criteria is met:

asset.preview_image[height > 400].url
asset.preview_image[height <= 640].url
asset.preview_image[width >= 400].url
asset.preview_image[width = 320].url
asset.preview_image[max height].url
asset.preview_image[max width].url
asset.preview_image[min height].url
asset.preview_image[min width].url
   

The following examples return the width for the preview image with the largest width:

asset.preview_image[max width].width
   

Examples

This example creates a simple asset feed:

<feed header>List of My Assets</feed header>
{% for asset in assets %}
  <item>
    <title> {{asset.name}} </title>
    <video_info> {{asset.description}} </video_info>
  </item>
{% endfor assets %}

    

Backlot generates a feed similar to the following:

<feed header>List of My Assets</feed header>
<item>
  <title>Presidential Speech #125784</title>
  <video_info>The president said something important today about something that happened.</video_info>
</item>
  <title>Presidential Speech #125785</title>
  <video_info>The president said something important today about something that should happen.</video_info>
</item>

    

You might want to create lists of your assets that can be imported into a spreadsheet. This example creates an inventory of assets that specifies their IDs (from metadata), names, owners (from metadata), and durations:

{% for asset in assets %}
Name, Duration, Content Owner
{{ asset.metadata ["my_id"] }}, {{ asset.name }}, {{ asset.metadata ["owner"] }}, { asset.duration }}
{% endfor assets %}       
    

Backlot generates a feed similar to the following:

 asset_01245344, Lord of the Rings: The Fellowship of the Ring, New Line, 228
 asset_01245856, Blade Runner, Warner, 117
 asset_01232844, Pulp Fiction, Miramax, 154
    

This example video settings for all streams:

{% for stream in asset.streams %}
  width:{{stream.video_width}}
  height:{{stream.video_height}}
{% endfor %}	

    

Backlot generates a feed similar to the following:

640
480
1024
768	
	
    

This example returns assets that have iPhone streams:

{% if asset.streams[iphone].exists %}
  <stream type="iphone">
    <url>{{ asset.streams[iphone].url }}</url>
  </stream>
{% endif %}
    

Backlot generates a feed similar to the following:

  <stream type="iphone">
    <url>http://iphone_url1</url>
    <url>http://iphone_url2</url>
    <url>http://iphone_url3</url>
  </stream>
    

This example returns a high resolution stream if it exists and a note to upload one if it doesn't:

   
{% if asset.streams[video_width >= 720].exists %}
<stream type="hd">
  <url>{{ asset.streams[iphone].url }}</url>
</stream>
{% else %}
   <placeholder>HD stream needed</placeholder>
{% endif %}
    

If there are multiple pages of results, Backlot generates each page. In the following example, if there is another page of results, Backlot displays a link to the next page.

{% for asset in assets %}
  <name>{{asset.name}}</name>
  <link>{{asset.stream_urls.source_file}}</link>
  {% if {{page_token}} %}
    <page_token>&lt;![CDATA[{{page_token}}]]&gt;</page_token>
  {% endif %}
{% endfor %}    
    
Note: In this example, marking the URL as character data prevents characters such as ampersands from causing XML issues.

Was this article helpful?