Template Examples
The following are some template examples for use with Universal Syndication as part of the Backlot API.
Upload a Template
[PUT] /v2/syndications/{id}/template
<feed header> Happy Header </feed header>
{% for asset in assets %}
<item>
<title> {{asset.name}} </title>
<video_info> {{asset.description}} </video_info>
</item>
{% endfor assets %}
The above template would generate a feed similar to the one below:
<feed header> Happy Header </feed header>
<item>
<title> Title for Video 1 </title>
<video_info> Description for Video 1 </video_info>
</item>
<item>
<title> Title for Video 2 </title>
<video_info> Description for Video 2 </video_info>
</item>
The 'next_page' property can be used to retrieve the next page if the feed contains too many assets to fit on a single page.
<feed header> Happy Header </feed header>
{% for asset in assets %}
<item>
<title> {{asset.name}} </title>
<video_info> {{asset.description}} </video_info>
</item>
{% endfor assets %}
{% if {{next_page}} %}
<next_page><![CDATA[{{next_page}}]]></next_page>
{% endif %}
Print URL of Smallest iPad-Compatible Stream
Here is a simple feed template that prints the URL of the smallest iPad-compatible stream.
{% for asset in assets %}
Name: {{asset.name}}
URL: {{ asset.streams[ipad, min file_size].url }}
{% endfor %}
Include Labels in Response
Here is a simple feed template that includes labels in the response.
<items>
{% for asset in assets %}
<item>
<title> {{asset.name}} </title>
<labels>
{% for label in asset.labels %}
<label>
<id>{{label.id}}</id>
<fullname>{{label.full_name}}</fullname>
<name>{{label.name}}</name>
</label>
{% endfor %}
</labels>
</item>
{% endfor %}
</items>
Feed With Next Page URL
Here is a simple XML feed with a next page URL.
{% for asset in assets %}
<name>{{asset.name}}</name>
<link>{{asset.stream_urls.source_file}}</link>
{% endfor %}
{% if {{next_page}} %}
<next_page><![CDATA[{{next_page}}]]></next_page>
{% endif %}
Feed Containing High-Definition Stream
Here is a feed containing a high definition stream if one exists, or a note to upload one if it doesn't.
{% for asset in assets %}
{% if asset.streams[video_width >= 720].exists %}
<stream type="hd">
<url>{{ asset.streams[iphone].url }}</url>
</stream>
{% else %}
<placeholder>HD stream needed</placeholder>
{% endif %}
{% endfor %}
Assets By Date
Include only assets that were created after Sept 1, 2012:
{% for asset in assets %}
{% if {{asset.created_at}} > "2012-09-01" %}
{{asset.name}}
{% endif %}
{% endfor %}
Assets By Metadata Keys
Include only assets that have the metadata key "syndicate" equal to "true":
{% for asset in assets %}
{% if {{asset.metadata['syndicate']}} == "true" %}
{{asset.name}}
{% endif %}
{% endfor %}
Simple CSV Feed Template
Here is a simple CSV feed template.
Name, Embed_Code
{% for asset in assets %}
{{asset.name}}, {{asset.embed_code}}
{% endfor %}
Simple MRSS Feed Template for Uploaded Videos
Here is a simple MRSS Feed template for uploaded videos.
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:fh="http://purl.org/syndication/history/1.0">
<channel>
<title>Sample MRSS Feed</title>
<description>Sample MRSS Feed using Universal Syndications</description>
<link>http://www.exampledomain.com</link>
{% for asset in assets %}
{% if asset.asset_type == "video" %}
<item>
<title>{{asset.name | escape}}</title>
<description>{{asset.description | escape}}</description>
<guid isPermaLink="false">{{asset.embed_code}}</guid>
<media:title>{{asset.name | escape}}</media:title>
<media:description>{{asset.description | escape}}</media:description>
<media:category scheme="http://www.ooyala.com">/Universal Syndicatiom</media:category>
<link>{{ asset.streams[flash_enabled].url | escape }}</link>
<media:content url="{{asset.streams[flash_enabled].url | escape}}"
fileSize="{{asset.streams[flash_enabled].file_size}}"
duration="{{asset.duration | divided_by:100}}"
medium="video"
expression="full">
</media:content>
<dcterms:valid>start={{asset.flight_start_time}};
end={{asset.flight_end_time}};scheme=W3C-DTF</dcterms:valid>
</item>
{% endif %}
{% endfor %}
</channel>
</rss>