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"/>
  <link rel="metadata" href="https://movida.bebanjo.net/api/subtitles/13/metadata"/>
  <link rel="rendition" href="https://movida.bebanjo.net/api/rendition/1"/>
</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 robot_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"/>
  <link rel="metadata" href="https://movida.bebanjo.net/api/subtitles/13/metadata"/>
  <link rel="rendition" href="https://movida.bebanjo.net/api/rendition/39"/>
 </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"/>
  <link rel="metadata" href="https://movida.bebanjo.net/api/subtitles/14/metadata"/>
  <link rel="rendition" href="https://movida.bebanjo.net/api/rendition/39"/>
 </subtitle>
</subtitles>

Get a specific subtitle

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

$ curl --digest -u robot_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"/>
  <link rel="metadata" href="https://movida.bebanjo.net/api/subtitles/13/metadata"/>
  <link rel="rendition" href="https://movida.bebanjo.net/api/rendition/39"/>
</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"/>
  <link rel="metadata" href="https://movida.bebanjo.net/api/subtitles/13/metadata"/>
  <link rel="rendition" href="https://movida.bebanjo.net/api/rendition/39"/>
</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"/>
  <link rel="metadata" href="https://movida.bebanjo.net/api/subtitles/13/metadata"/>
  <link rel="rendition" href="https://movida.bebanjo.net/api/rendition/39"/>
</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"

File Name Validation

Note that the Movida API validates the file name for subtitle files. If the file name in a given request includes one or more restricted characters, then the response body for the 4xx error will include the “The request could not be processed by the server due to malformed syntax” message. Please review the Status Codes and Errors page for the full list of restricted characters and associated HTTP status codes.

Last updated September 10th, 2019.