-
Notifications
You must be signed in to change notification settings - Fork 6
Movida Resource: Subtitle
This resource represents a specific Subtitle (either a subtitle file or a burnt in subtitle) for a given Movida Resource: Rendition. A subtitle can be in a given language, can be for-the-hearing-impaired or not and can be burnt in the video or within a given subtitle file that can accompany the rendition.
This is how a Subtitle looks like when accessed via the Movida API:
<?xml version='1.0' encoding='utf-8' ?>
<subtitle>
<id type="integer">13</id>
<language>eng</language>
<burnt-in type="boolean">false</burnt-in>
<for-the-hearing-impaired type="boolean">false</for-the-hearing-impaired>
<file-name>subtitle.srt</file-name>
<file-size type="integer">2345569434</file-size>
<file-md5>1bbc4c41ea7c9d3a7dc1509727f698b7</file-md5>
<link rel="self" href="http://movida.example.com/api/subtitles/13"/>
<link rel="file" href="http://wadus.bebanjo.net/subtitle.srt"/>
</subtitle>
Subtitles are accessed via the Rendition they belong to, as in the example below, through the link identified by the rel="subtitles" attribute. Refer to the Movida Resource: Rendition page to find out how to access a Rendition.
<?xml version='1.0' encoding='utf-8' ?>
<rendition>
<!-- ... -->
<link rel="subtitles" href="http://movida.example.com/api/renditions/39/subtitles"/>
<!-- ... -->
</rendition>
If we follow that link we can fetch the list of all subtitles for that rendition:
$ curl --digest -u roboot_user:password https://movida.example.com/api/renditions/39/subtitles
<?xml version="1.0" encoding="UTF-8"?>
<subtitles type="array">
<subtitle>
<id type="integer">13</id>
<language>eng</language>
<burnt-in type="boolean">false</burnt-in>
<for-the-hearing-impaired type="boolean">false</for-the-hearing-impaired>
<file-name>subtitle.srt</file-name>
<file-size type="integer">2345569434</file-size>
<file-md5>1bbc4c41ea7c9d3a7dc1509727f698b7</file-md5>
<link rel="self" href="http://movida.example.com/api/subtitles/13"/>
<link rel="file" href="http://wadus.bebanjo.net/subtitle.srt"/>
</subtitle>
<subtitle>
<id type="integer">14</id>
<language>spa</language>
<burnt-in type="boolean">false</burnt-in>
<for-the-hearing-impaired type="boolean">false</for-the-hearing-impaired>
<file-name>subtitle.srt</file-name>
<file-size type="integer">2345569433</file-size>
<file-md5>1bbc4c41ea7c9d3a7dc1509727f698b8</file-md5>
<link rel="self" href="http://movida.example.com/api/subtitles/14"/>
<link rel="file" href="http://wadus.bebanjo.net/subtitle.srt"/>
</subtitle>
</subtitles>
This is how we would recover information about a specific subtitle:
$ curl --digest -u roboot_user:password https://movida.example.com/api/subtitles/23
<?xml version="1.0" encoding="UTF-8"?>
<subtitle>
<id type="integer">13</id>
<language>eng</language>
<burnt-in type="boolean">false</burnt-in>
<for-the-hearing-impaired type="boolean">false</for-the-hearing-impaired>
<file-name>subtitle.srt</file-name>
<file-size type="integer">2345569434</file-size>
<file-md5>1bbc4c41ea7c9d3a7dc1509727f698b7</file-md5>
<link rel="self" href="http://movida.example.com/api/subtitles/13"/>
<link rel="file" href="http://wadus.bebanjo.net/subtitle.srt"/>
</subtitle>
To create a subtitle, you just need to POST a proper XML Rendition representation (similar to the ones you get when fetching a rendition) to the subtitles URL of a given rendition. As explained above, that URL is in the link node whose 'rel' attribute equals 'renditions'.
For example, the following XML issued as a POST to the subtitles URL of a rendition would create a subtitle (we’ll use curl’s @ option, which reads data to be posted from a file):
cat subtitle.xml
<subtitle>
<language>eng</language>
<burnt-in type="boolean">false</burnt-in>
<for-the-hearing-impaired type="boolean">false</for-the-hearing-impaired>
<file-name>subtitle.srt</file-name>
<file-size type="integer">2345569434</file-size>
<file-md5>1bbc4c41ea7c9d3a7dc1509727f698b7</file-md5>
<link rel="file" href="http://wadus.bebanjo.net/subtitle.srt"/>
</subtitle>
$ curl --digest -u robot_user:password -H "Content-Type: application/xml" -X POST -d @subtitle.xml "https://movida.example.com/api/renditions/39/subtitles"
Movida will return the full XML of the subtitle just created:
<?xml version="1.0" encoding="UTF-8"?>
<subtitle>
<id type="integer">13</id>
<language>eng</language>
<burnt-in type="boolean">false</burnt-in>
<for-the-hearing-impaired type="boolean">false</for-the-hearing-impaired>
<file-name>subtitle.srt</file-name>
<file-size type="integer">2345569434</file-size>
<file-md5>1bbc4c41ea7c9d3a7dc1509727f698b7</file-md5>
<link rel="self" href="http://movida.example.com/api/subtitles/13"/>
<link rel="file" href="http://wadus.bebanjo.net/subtitle.srt"/>
</subtitle>
As our Introduction and Conventions page suggests, you can update a subtitle issuing a PUT request to each subtitle URI:
cat subtitle_update.xml
<subtitle>
<language>spa</language>
<burnt-in>true</burnt-in>
<link rel="file" href="http://wadus.bebanjo.net/subtitle.spa.srt"/>
</subtitle>
curl --digest -u robot_user:password -H "Content-Type: application/xml" -X PUT -d @subtitle_update.xml "https://movida.example.com/api/subtitles/13"
As always Movida will return the full XML of the subtitle just updated:
<?xml version="1.0" encoding="UTF-8"?>
<subtitle>
<id type="integer">13</id>
<language>spa</language>
<burnt-in type="boolean">true</burnt-in>
<for-the-hearing-impaired type="boolean">false</for-the-hearing-impaired>
<file-name>subtitle.srt</file-name>
<file-size type="integer">2345569434</file-size>
<file-md5>1bbc4c41ea7c9d3a7dc1509727f698b7</file-md5>
<link rel="self" href="http://movida.example.com/api/subtitles/13"/>
<link rel="file" href="http://wadus.bebanjo.net/subtitle.spa.srt"/>
</subtitle>
Also you can delete a subtitle using DELETE request to each subtitle URI:
curl --digest -u robot_user:password -X DELETE "https://movida.example.com/api/subtitles/13"
-
language. The language attribute is validated and mandatory. List of possible languages as per ISO ISO 639-2/T codes by name. See http://en.wikipedia.org/wiki/List_of_ISO_639-2_codes.
-
file-name. The file-name attribute is validated when it is specified. It should be a valid filename without spaces and other special characters like #, $, [], {}, @...
-
rel='file'. This href attribute should be a valid URI