Specifying Sequential Relationships: union

Establish sequential relationships to recommend series content in the correct order.

Note: Rather than constructing ad hoc requests (with individual parameters for each request), consider using discovery profiles to centralize your settings and recommendations behavior. Discovery profiles are defined configurations of settings created by you, which you then reuse by reference on the GET routes. For more information, see Discovery Profiles.

To establish sequential relationships, add a custom metadata entry to the asset and request the information when making an Ooyala Discovery request.

  1. Add metadata without replacing the current metadata by using PATCH with the /v2/assets route. The following example adds the JxbzdkMjqBEsO asset as the next piece of content in the series and the RTffTGterfdc asset as the highlight reel.
    [PATCH]/v2/assets/asset_id/metadata{  
       "next_item":"asset_id",
       "next_highlight":"asset_id"
    }

    Backlot returns a response similar to the following.

    {  
       "next_item":"asset_id",
       "next_highlight":"asset_id",
       "director":"A Director",
       "copyright":"2010",
       "category":"Adventure",
       "external_id":"external_id"
    }
  2. If you want to add the next item to the recommendations, use the union query string parameter and specify the position. The following example returns the four most popular videos for the day. However, it injects the next item from the series into position 0 and the highlight reel into position 2.
    [GET]/v2/discover/trending/top?countries=all&time=now&window=day&limit=4&union=next|next_item|0,union=next|next_highlight|2     

    Backlot returns a response similar to the following.

    {  
       "results":[  
          {  
             "name":"Extreme Paint Drying, Episode 243",
             "description":"Sunday! Sunday! Sunday! You watched episodes 1 through 242, now you are ready for 243!",
             "embed_code":"embed_code",
             "external_id":"external_id",
             "preview_image_url":"image_url",
             "duration":"91000",
             "hostedAtURL":null,
             "bucket_info":"bucket_info_id",
             "reason":"next_item"
          },
          {  
             "name":"More cats playing piano!",
             "description":"More cats playing piano!",
             "embed_code":"embed_code",
             "external_id":"external_id",
             "preview_image_url":"image_url",
             "duration":"91000",
             "hostedAtURL":null,
             "bucket_info":"bucket_info_id",
             "reason":"top"
          },
          {  
             "name":"Extreme Paint Drying Highlights",
             "description":"The best moments from the Extreme Paint Drying Series, including 23 minutes from the chartreuse episode.",
             "embed_code":"embed_code",
             "external_id":"external_id",
             "preview_image_url":"image_url",
             "duration":"91000",
             "hostedAtURL":null,
             "bucket_info":""bucket_info_id",
             "reason":"next_item"
          },
          {  
             "name":"Cat Video #1457",
             "description":"Even more cats playing piano!",
             "embed_code":"embed_code",
             "external_id":"external_id",
             "preview_image_url":""image_url",
             "duration":"91000",
             "hostedAtURL":null,
             "bucket_info":"bucket_info_id",
             "reason":"top"
          }
       ]
    }
  3. Get the information from each result to generate web page content. The following example contains simple HTML content.
    <div class="sidebar">
        <h4 class="sidebar-head">Popular Now</h4>
        <ul>
            <li>
                <p><a href="/video/JxbzdkMjqBEsO">Extreme Paint Drying, Episode 243</a></p>
                <p>Sunday! Sunday! Sunday! You watched episodes 1 through 242, now you are ready for 243!</p>
            </li>
            <li>
                <p><a href="/video/Jr8fdsNDrcK-TYHGlFIZuTlPoDZ_QkW3">Cat Video #1456</a></p>
                <p>More cats playing piano!</p>
            </li>
            <li>
                <p><a href="/video/RTffTGterfdc">Extreme Paint Drying Highlights</a></p>
                <p>The best moments from the Extreme Paint Drying Series, including 23 minutes from the chartreuse episode.</p>
            </li>
            <li>
                <p><a href="/video/3556csNDrcK-ZaRTYhuTlPoDZ_tyrD">Cat Video #1457</a></p>
                <p>Even more cats playing piano!</p>
            </li>        
        </ul>
    </div>    
Note:

Try out the code samples using your account credentials in the Ooyala Scratchpad. For information about using the Scratchpad, see Practice Making Requests with the Scratchpad. To launch the scratchpad, go to Ooyala API Scratchpad.

해당 내용이 도움 되었습니까?