Skip to content

Movida Resource: Subtitle

rnaveiras edited this page Apr 12, 2012 · 30 revisions

Introduction

The subtitle resource represents todo

This is how an Subtitle looks through the 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>

GET a list for all subtitles for a rendition

Subtitle are accessed via a Rendition. Refer to the Movida Resource: Rendition page to find out how to access a Rendition. Inside a Rendition, one of the related link nodes identified by the rel attribute: Like here:

<?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'd 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>

Get a specific subtitle

This a good way to 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>

Creating subtitles for a rendition

For create subtitle, you just need to POST a proper XML Subtitle representation (similar to the ones you get when fetching an subtitle) to the proper URL. That URL can be found in a link whose rel is subtitles.

For example, this POST 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>

Updating a subtitle

As our Introduction and Conventions suggests, you can update a subtitle using 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>

Deleting a 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"

Valid Attributes

  • Field language The field language 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.

  • Field file-name The field file-name is validated when it's specified. It's should be a valid filename without spaces and other special characters like #, $, [], {}, @...

  • Field rel='file' This field should be a valid url.

Clone this wiki locally