Hands-on tutorial
In this tutorial, you’ll start with a basic content integration script (sushi chef)
and extend the code to construct a bigger channel based on your own content.
In the process you’ll learn about all the features of the ricecooker
framework.
Prerequisite steps
The steps in this tutorial assume you have:
Completed the Installation steps
Created an account on Kolibri Studio and obtained your access token, which you’ll need to to use instead of the text
<your-access-token>
in the examples belowSuccessfully managed to run the basic chef example in the Getting started tutorial
Step 1: Setup your environment
Create a directory called tutorial
where you will run this code.
In general it is recommended to have separate directories for each content
integration script you will be working on.
In order to prepare for the upcoming Step 6, find a .pdf
document,
a small .mp4
video file, and an .mp3
audio file.
Save these files somewhere inside the tutorial
directory.
Step 2: Copy the sample code
To begin, download the sample code from here and save it as the file sushichef.py in the tutorial directory.
Note all the TODO
items in the code. These are the places left for you to edit.
Step 3: Edit the channel metadata
Open your terminal and
cd
into the folder wheresushichef.py
is located.Open
sushichef.py
in a text editor.Change
<yourdomain.org>
to any domain. The source domain specifies who is supplying the content.Change
<yourid>
to any id. The source_id will distinguish your channel from other channels.Change
The Tutorial Channel
to any channel name.
Try running the sushi chef by entering the following command in your terminal:
python sushichef.py --token=<your-access-token>
Click the link to Kolibri Studio that shows up in the final step and make sure your channel looks OK.
Step 4: Create a Topic
Locate the first TODO in the
sushichef.py
file. Here, you will create your first topic.Copy/paste the example code and change
exampletopic
tomytopic
.Set the
source_id
to be something other thantopic-1
(thesource_id
will distinguish your node from other nodes in the tree)Set the title.
Go to the next TODO and add
mytopic
to channel (use example code as guide)
Check Run sushi chef from your terminal. Your channel should look like this:
Channel
| Example Topic
| Your Topic
Step 5: Create a Subtopic
Go to the next TODO in the
sushichef.py
file. Here, you will create a subtopicCopy/paste the example code and change
examplesubtopic
tomysubtopic
Set the
source_id
andtitle
Go to the next TODO and add
mysubtopic
tomytopic
(use example code as guide)
Check Run the sushi chef from your terminal. Your channel should look like this:
Channel
| Example Topic
| | Example Subtopic
| Your Topic
| | Your Subtopic
Step 6: Create Files
Go to the next TODO in the sushichef.py file. Here, you will create a pdf file
Copy/paste the example code and change
examplepdf
tomypdf
.DocumentFile(...)
will automatically download a pdf file from the given path.Set the
source_id
, thetitle
, and thepath
(any url to a pdf file)Repeat steps 1-3 for video files and audio files.
Finally, add your files to your channel (see last ** statements)
Check: Run the sushi chef from your terminal. Your channel should look like this:
Channel
| Example Topic
| | Example Subtopic
| | | Example Audio
| | Example Video
| Your Topic
| | Your Subtopic
| | | Your Audio
| | Your Video
| Example PDF
| Your PDF
Next steps
You’re now ready to start writing your own content integration scripts. The following links will guide you to the next steps: