We use cookies (just for analytics) on this website. If you continue we will assume you are happy with it. ok

BeBanjo

Back to index

Subtitle

This resource represents a specific subtitle (either a subtitle file or a burnt in subtitle) for a given 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="https://movida.bebanjo.net/api/subtitles/13"/>
  <link rel="file" href="https://wadus.bebanjo.net/subtitle.srt"/>
</subtitle>

Valid attributes

  • language: The language attribute is validated and required. List of possible languages as per 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

Get a list of all subtitles for a rendition

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="https://movida.bebanjo.net/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.bebanjo.net/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="https://movida.bebanjo.net/api/subtitles/13"/>
  <link rel="file" href="https://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="https://movida.bebanjo.net/api/subtitles/14"/>
  <link rel="file" href="https://wadus.bebanjo.net/subtitle.srt"/>
 </subtitle>
</subtitles>

Get a specific subtitle

This is how we would recover information about a specific subtitle:

$ curl --digest -u roboot_user:password https://movida.bebanjo.net/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="https://movida.bebanjo.net/api/subtitles/13"/>
 <link rel="file" href="https://wadus.bebanjo.net/subtitle.srt"/>
</subtitle>

Creating subtitles for a rendition

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="https://wadus.bebanjo.net/subtitle.srt"/>
</subtitle>
$ curl --digest -u robot_user:password -H "Content-Type: application/xml" -X POST -d @subtitle.xml "https://movida.bebanjo.net/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="https://movida.bebanjo.net/api/subtitles/13"/>
 <link rel="file" href="https://wadus.bebanjo.net/subtitle.srt"/>
</subtitle>

Updating a subtitle

As our introduction to REST APIs guide 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="https://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.bebanjo.net/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="https://movida.bebanjo.net/api/subtitles/13"/>
 <link rel="file" href="https://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.bebanjo.net/api/subtitles/13"

Last updated September 19th, 2017.