Demo Application

Learn how to integrate different endpoints of the Dailymotion Data API with the help of a Django application.

Introduction

This lesson walks us through a Django application that integrates Dailymotion Data API. We'll use the following operations in the application workflow:

  1. Retrieving videos
  2. Retrieving playlists
  3. Retrieving channels

Workflow

We have our demo application in the widget below. In the file views.py, lines 10 to 55 are the functions that perform API calls. The application works as follows:

  • Lines 10–17: We define the index function, which calls the videos endpoint.
  • Lines 19–26: We define the popularChannels function, which calls the channels endpoint and sorts the channels based on their popularity.
  • Lines 28–35: We define the playlists function, which calls the playlists endpoint to show all the playlists.
  • Lines 37–45: We define the channelVideos function, which calls the channel/channel_id/videos endpoint to get all the videos belonging to a channel.
  • Lines 47–55: We define the playlistVideos function, which calls the playlist/playlist_id/videos endpoint that returns the videos from a playlist.

Run the application

Click the “Run” button in the widget below to run the application. Once the server has started, click the URL against “Your app can be found at:” to view the application.

  1. After running the code below, the home page shows some videos from the Dailymotion website that we can play and watch.
  2. The playlist page displays the list of playlists. We can also retrieve a specific playlist by clicking it.
  3. The channel page displays the channel’s ID, name, and description. We can retrieve videos of a specific channel by clicking the channel's ID.

Note: The following widget only shows the necessary files required to explain the Dailymotion Data APIs.

Get hands-on with 1400+ tech skills courses.