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

Rule

Movida’s rules let you define how to schedule your series or features for catch-up taking the transmissions in your linear channels as a reference

This is how a rule looks like:

<rule>
  <id type="integer">4</id>
  <external-id>RR12-4</external-id>
  <starts type="date">2010-10-10</starts>
  <ends type="date">2011-10-10</ends>
  <episode-selection-type>except</episode-selection-type>
  <episode-selection>1,7-9</episode-selection>
  <link rel="self" href="https://movida.bebanjo.net/api/rules/4"/>
  <link rel="content" href="https://movida.bebanjo.net/api/title_groups/1"/>
  <link rel="specific_platforms" href="https://movida.bebanjo.net/api/rules/4/specific_platforms"/>
</rule>

Valid attributes

  • id (required): Movida internal identifier of the rule.

  • external-id (optional): Identifier of the rule in the external system.

  • starts (required): Timestamp representing when the rule starts.

  • ends (required): Timestamp representing when the rule ends.

  • start-offset-value (optional): Define when the rule starts. Allowed values are positive integers. If specified you need to provide <start-offset-unit> and <start-offset-reference> to define the start completely.

  • start-offset-unit (optional): Define when the rule starts. Allowed values are: minutes, hours, days, weeks, months, years. If specified you need to provide <start-offset-value> and <start-offset-reference> to define the start completely.

  • start-offset-reference (optional): Define when the rule starts. Allowed values are: before_tx_starts, after_tx_starts, after_tx_ends and after_date. If specified you need to provide <start-offset-value> and <start-offset-reference> to define the start completely.

  • reference-start-date (optional): Define when the rule starts. If the <start-offset-reference> is after_date you must need to provide a value (of type date) for this attribute.

  • end-offset-value (optional): Define when the rule ends. Allowed values are positive integers. If specified you need to provide <end-offset-unit> and <end-offset-reference> to define the end completely.

  • end-offset-unit (optional): Define when the rule ends. Allowed values are: minutes, hours, days, weeks, months, years. If specified you need to provide <end-offset-value> and <end-offset-reference> to define the end completely.

  • end-offset-reference (optional): Define when the rule ends. Allowed values are: after_start, after_tx_ends and after_last_episode. If specified you need to provide <end-offset-value> and <end-offset-unit> to define the end completely.

  • reference-tx-nth (optional): A transmission ordinal reference to stablish the start offset. Allowed values are: 1 2 3 4 5 6 7 8 9 10 11 12 and all.

  • episode-selection-type (optional): This attribute only makes sense for rules defined on series or collections. Can take three different values:

    • all: The rule applies to all episodes in the series or all titles in the collection.

    • only: The rule applies to the episode/title specified in the attribute <episode-selection>.

    • except: The rule applies to all episodes/title except those specified in the attribute <episode-selection>.

  • episode-selection (optional): This attribute only makes sense when <episode-selection-type> has the values only or except. Its purpose is to specify a range of episodes/titles, separating the episode numbers by commas or by a dash. A dash range means that all the episodes in that range are included. For example:

    • 1,3-5,7,9 range includes the episodes 1, 3, 4, 5, 7 and 9

    • 1-3,9,11-13 range includes the episodes 1, 2, 3, 9, 11, 12 and 13

Get a list of all rules in the current account

Rules are linked from the root of the API, through the link identified with the rel="rules" attribute:

<?xml version="1.0" encoding="UTF-8"?>
<movida>
  <!-- ... -->
  <link rel="rules" href="https://movida.bebanjo.net/api/rules">
</movida>

Following that link, we can fetch the list of rules in the current account.

$ curl --digest -u robot_user:password https://movida.bebanjo.net/api/rules
<?xml version="1.0" encoding="UTF-8"?>
<rules>
  <total-entries>113</total-entries>
  <link rel="next" href="https://movida.bebanjo.net/api/rules?page=1"/>
  <link rel="prev" href="https://movida.bebanjo.net/api/rules?page=3"/>
  <rule>
    <id type="integer">5</id>
    <external-id>RR12-5</external-id>
    <!-- ... -->
  </rule>
  <rule>
    <id type="integer">6</id>
    <external-id>RR11-5</external-id>
    <!-- ... -->
  </rule>
  <!-- ... -->
<rules>

Note: This is a paginated resource. By default, only 50 Rules will be included in each page but you can override this default by using the per_page parameter described in the next section. The total-entries attribute will indicate the total number of entries and the links rel="next" and rel="prev" should be used to get the next and the previous pages.

Valid attributes

You can filter the list of Rules returned using the following parameters:

  • external_id: It will return only the Rule with the exact given external_id (if any).

  • per_page: Number of elements returned in each page. The maximum value allowed is 200 and the default is 50.

  • page: Number of the page you want to be returned.

Get a list of rules from a feature, series or collection

Given an existing feature, for example:

  <title>
    <id type="integer">12</id>
    <name>Silicon Computers</name>
    <title>Silicon Computers</title>
    <external-id nil="true"/>
    <title-type>feature</title-type>
    <tags></tags>
    <link href="https://staging-movida.bebanjo.net/api/titles/12" rel="self"/>
    <link href="https://staging-movida.bebanjo.net/api/titles/12/schedule" rel="schedule"/>
    <link href="https://staging-movida.bebanjo.net/api/titles/12/availability_windows" rel="availability_windows"/>
    <link href="https://staging-movida.bebanjo.net/api/titles/12/title_groups" rel="title_groups"/>
    <link href="https://staging-movida.bebanjo.net/api/licensors/114" rel="licensor"/>
    <link href="https://staging-movida.bebanjo.net/api/titles/12/images" rel="images"/>
    <link href="https://staging-movida.bebanjo.net/api/titles/12/assets" rel="assets"/>
    <link href="https://staging-movida.bebanjo.net/api/titles/12/metadata" rel="metadata"/>
    <link href="https://staging-movida.bebanjo.net/api/titles/12/blackouts" rel="blackouts"/>
    <link href="https://staging-movida.bebanjo.net/api/titles/12/rights" rel="rights"/>
    <link href="https://staging-movida.bebanjo.net/api/titles/12/rules" rel="rules"/>
    <link href="https://staging-movida.bebanjo.net/api/titles/12/trailers" rel="trailers"/>
  </title>

All the rules of that feature can be obtained by following the link rel="rules":

$ curl --digest -u robot_user https://movida.bebanjo.net/api/titles/12/rules
<rules type="array">
  <rule>
    <id type="integer">7</id>
    <external-id>FR2</external-id>
    <starts type="date">2013-10-10</starts>
    <ends type="date">2014-10-10</ends>
    <link rel="self" href="https://movida.bebanjo.net/api/rules/7"/>
    <link rel="content" href="https://movida.bebanjo.net/api/titles/12"/>
    <link rel="specific_platforms" href="https://movida.bebanjo.net/api/rules/7/specific_platforms"/>
  </rule>
  <rule>
    <id type="integer">8</id>
    <starts type="date">2011-11-10</starts>
    <ends type="date">2012-10-10</ends>
    <link rel="self" href="https://movida.bebanjo.net/api/rules/8"/>
    <link rel="content" href="https://movida.bebanjo.net/api/titles/12"/>
    <link rel="specific_platforms" href="https://movida.bebanjo.net/api/rules/8/specific_platforms"/>
  </rule>
</rules>

Get a single rule

Just do a GET to the URI of the rule (the one in the attribute rel="self"):

$ curl --digest -u robot_user https://movida.bebanjo.net/api/rules/6
<rule>
  <id type="integer">6</id>
  <external-id>RR12-5</external-id>
  <starts type="date">2013-01-10</starts>
  <ends type="date">2015-01-00T00:00</ends>
  <link rel="self" href="https://movida.bebanjo.net/api/rules/6"/>
  <link rel="content" href="https://movida.bebanjo.net/api/titles/3"/>
  <link rel="specific_platforms" href="https://movida.bebanjo.net/api/rules/6/specific_platforms"/>
</rule>

Creating a rule inside a feature

As our introduction to REST APIs page suggests, you can create a rule issuing a POST request to each rule URI:

cat rule_create.xml
<rule>
  <external-id>RR12-5</external-id>
  <starts type="date">2013-01-10</starts>
  <ends type="date">2015-01-00T00:00</ends>
</rule>
$ curl --digest -u robot_user:password -H "Content-Type: application/xml" -X POST -d @rule_create.xml "https://movida.bebanjo.net/api/titles/1/rules"

As always Movida will return the full XML of the rule just created:

<?xml version="1.0" encoding="UTF-8"?>
<rule>
  <id type="integer">13</id>
  <external-id>RR12-5</external-id>
  <starts type="date">2013-01-10</starts>
  <ends type="date">2015-01-00T00:00</ends>
  <reference-tx-nth>1</reference-tx-nth>
  <link rel="self" href="https://movida.bebanjo.net/api/rules/13"/>
  <link rel="content" href="https://movida.bebanjo.net/titles/1"/>
  <link rel="specific_platforms" href="https://movida.bebanjo.net/rules/13/specific_platforms"/>
</rule>

Creating a rule inside a title group

As our introduction to REST APIs page suggests, you can create a rule issuing a POST request to each rule URI:

cat rule_create.xml
<rule>
  <external-id>RR12-5</external-id>
  <starts type="date">2013-01-10</starts>
  <ends type="date">2015-01-00T00:00</ends>
</rule>
$ curl --digest -u robot_user:password -H "Content-Type: application/xml" -X POST -d @rule_create.xml "https://movida.bebanjo.net/api/title_groups/1/rules"

As always Movida will return the full XML of the rule just created:

<?xml version="1.0" encoding="UTF-8"?>
<rule>
  <id type="integer">13</id>
  <external-id>RR12-5</external-id>
  <starts type="date">2013-01-10</starts>
  <ends type="date">2015-01-00T00:00</ends>
  <reference-tx-nth>1</reference-tx-nth>
  <episode-selection-type>all</episode-selection-type>
  <link rel="self" href="https://movida.bebanjo.net/api/rules/13"/>
  <link rel="content" href="https://movida.bebanjo.net/title_groups/1"/>
  <link rel="specific_platforms" href="https://movida.bebanjo.net/rules/13/specific_platforms"/>
</rule>

Updating a rule

As our introduction to REST APIs page suggests, you can update a rule issuing a PUT request to each rule URI:

cat rule_update.xml
<rule>
  <episode-selection-type>only</episode-selection-type>
  <episode-selection>1,2</episode-selection>
</rule>
$ curl --digest -u robot_user:password -H "Content-Type: application/xml" -X PUT -d @rule_update.xml "https://movida.bebanjo.net/api/rules/13"

As always Movida will return the full XML of the rule just updated:

<?xml version="1.0" encoding="UTF-8"?>
<rule>
  <id type="integer">13</id>
  <external-id>RR12-4</external-id>
  <starts type="date">2010-10-10</starts>
  <ends type="date">2011-10-10</ends>
  <episode-selection-type>only</episode-selection-type>
  <episode-selection>1,2</episode-selection>
  <link rel="self" href="https://movida.bebanjo.net/api/rules/13"/>
  <link rel="content" href="https://movida.bebanjo.net/title_groups/1"/>
  <link rel="specific_platforms" href="https://movida.bebanjo.net/rules/13/specific_platforms"/>
</rule>

Deleting a rule

Also you can delete a rule using DELETE request to each rule URI:

$ curl --digest -u robot_user:password -X DELETE "https://movida.bebanjo.net/api/rules/13"

The DELETE request doesn’t return anything, as that rule is now gone.

Last updated September 19th, 2017.