Tutorial
In this tutorial, you will learn how to set up Onzr and the basic philosophy behind it.
Tip
While following this tutorial, you will be invited to type shell commands. Every command appears in a code block as follow:
You can copy or type them in your terminal and type return at the end of the instruction to execute them.
Install Onzr
Requirements
Onzr is a Python package, but it depends on VLC media player to play your music. You need to make sure it's installed on your machine; don't be afraid most (every?) operating systems are compatible.
Python should also be installed in your machine. If
you are using a UNIX-based operating system such as MacOS or GNU/Linux, it
should already be installed. Make sure your version of python is at least
Python 11.0 by typing the following command in your favorite terminal:
Example output may be something like: Python 3.12.8
Install Onzr in your user space
Tip
Make sure pip is installed for your Python version by typing the following
command in a terminal:
This command should not fail and the output may look like:
If pip is not installed, please follow the official
documentation to install it.
We will use the pip package manager to install onzr in your user space:
Use your preferred installation method
In this tutorial, we invite you to install Onzr in your user space, but you can choose to install it globally (for all users), or using another package manager than Pip. It's up to you to choose the most convenient method to install a Python package in your machine.
Once installed, the onzr command can be called from your favorite terminal.
You can test it by typing:
Configure Onzr
A basic configuration file is required to run Onzr. It should be created once
using the dedicated init command.
Tip
Before running this command, we invite you to get your ARL token that will be used to authenticate your requests to the Deezer API. This token value can be found stored in a session cookie once connected to deezer.com using your favorite web browser (see detailed instructions).
When prompted, copy/paste your ARL token and validate by pressing Enter
That's it: Onzr is now configured ๐ A configuration file (settings.yaml)
should have been generated at the following path (depending on your OS):
- MacOS:
~/Library/Application Support/onzr/settings.yaml - Windows:
%appdata%\watson\config, which usually expands toC:\Users\<user>\AppData\Roaming\onzr\settings.yaml - Linux:
~/.config/onzr/settings.yaml
You can check the configuration path using the config -p command:
And the configuration content using:
You should see at least two defined settings:
Edit your configuration
Feel free to customize Onzr's behavior by changing your settings such as the default audio quality:
Configuration can be edited using the onzr config -e command.
For a complete list of configurable settings and configuration tips, please refer to the configuration documentation.
Run the web server
Onzr has been designed as a web server that streams and plays your music using FastAPI and VLC respectively. It provides an HTTP API to interact with it, e.g. control the player and the tracks queue.
To use Onzr you should run the web server by using the serve command:
If Onzr is properly installed and configured, you should see logs from the web server displayed in your terminal. And as it's running as a foreground process, you will need to start a new terminal to run new commands to act on it.
Tip
If you want to run the Onzr server as a background process, we recommend to lower the log-level so that it won't disturb your terminal flow:
Make sure Onzr server is running by using the state command:
If the server is up and running, you should get a description of the server state. Meaning we can start playing with it and stream our favorite tracks.
Search albums, artists and tracks
Onzr CLI uses Deezer API to explore available music tracks. When beginning with Onzr, the first step is often a search. Let's say you want to explore Radiohead's discography. The first step is to get its artist identifier (ID):
The command output should look like:
Search results
โโโโโโโโโโโโโณโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ID โ Artist โ
โกโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฉ
โ 399 โ Radiohead โ
โ 177930417 โ Mau P โ
โ 171883 โ NTO โ
โ 7888234 โ Kelly Lee Owens โ
โ 2762 โ Easy Star All-Stars โ
โ 53477202 โ DJ Radiohead โ
โ 12189436 โ Radio Head โ
โ 258886601 โ radiohead two โ
โ 271721572 โ Coldplay, Radiohead, Hozier โ
โ 14009761 โ Radiohead Tribute Band โ
โ 4674537 โ Radiodread โ
โโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
The identifier we are interested in for Radiohead is 399. We can then use
this identifier to explore the artist top tracks:
The output should look like:
Artist collection
โโโโโโโโโโโโโณโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโณโโโโโโโโโโโโโโโณโโโโโโโโโโโโ
โ ID โ Track โ Album โ Artist โ
โกโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฉ
โ 138547415 โ Creep โ Pablo Honey โ Radiohead โ
โ 138539979 โ Let Down โ OK Computer โ Radiohead โ
โ 138539157 โ No Surprises โ No Surprises โ Radiohead โ
โ 138539981 โ Karma Police โ OK Computer โ Radiohead โ
โ 138539977 โ Exit Music (For A Film) โ OK Computer โ Radiohead โ
โ 138547587 โ Everything In Its Right Place โ Kid A โ Radiohead โ
โ 138546819 โ Jigsaw Falling Into Place โ In Rainbows โ Radiohead โ
โ 138539973 โ Paranoid Android โ OK Computer โ Radiohead โ
โ 138546811 โ All I Need โ In Rainbows โ Radiohead โ
โ 138546809 โ Weird Fishes / Arpeggi โ In Rainbows โ Radiohead โ
โโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโดโโโโโโโโโโโโ
In this top track list, we can find the track identifiers, title and album.
Pro tip for power users โข
An alternative way to achieve the previous suite of commands is to leverage the
power of UNIX shells by using the pipe operator (| character) that send the
output of a command as input of another command (we say it is "piped" to the
second command):
- Only display identifiers using the
--idsoption - Restrict to the first match using
headcommand - Use the
-special flag so that Onzr expects identifiers coming from the standard input
And if we want the artist discography, we can use the --albums option:
- The
--limitoption is used here to avoid being limited to the 10 latest albums (API default page size it10).
The output should look like:
Artist collection
โโโโโโโโโโโโโณโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโณโโโโโโโโโโโโณโโโโโโโโโโโโโ
โ ID โ Album โ Artist โ Released โ
โกโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฉ
โ 792320571 โ Hail to the Thief (Live Recordings 2003-2009) โ Radiohead โ 2025-08-13 โ
โ 265569082 โ KID A MNESIA โ Radiohead โ 2021-11-05 โ
โ 14879823 โ A Moon Shaped Pool โ Radiohead โ 2016-05-09 โ
โ 14880501 โ TKOL RMX 1234567 โ Radiohead โ 2011-10-10 โ
โ 14880315 โ The King Of Limbs โ Radiohead โ 2011-02-18 โ
โ 14880659 โ In Rainbows โ Radiohead โ 2007-12-28 โ
โ 14879789 โ Com Lag: 2+2=5 โ Radiohead โ 2004-03-24 โ
โ 14879739 โ Hail To the Thief โ Radiohead โ 2003-06-09 โ
โ 14879753 โ I Might Be Wrong โ Radiohead โ 2001-11-12 โ
โ 14879749 โ Amnesiac โ Radiohead โ 2001-03-12 โ
โ ... โ ... โ ... โ ... โ
โ 14880711 โ Pablo Honey โ Radiohead โ 1993-02-22 โ
โ 14880307 โ Anyone Can Play Guitar โ Radiohead โ 1993-01-25 โ
โ 14880783 โ Creep โ Radiohead โ 1992-09-21 โ
โ 423524437 โ Creep EP โ Radiohead โ 1992-09-21 โ
โ 121893052 โ Drill EP โ Radiohead โ 1992-05-05 โ
โโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโดโโโโโโโโโโโโโ
I hear you from here saying:
โ Ok that great, but we are here to listen to music, not get creepy identifiers!
Loud and clear, let's continue to the next section to listen good music!
Add tracks to queue
Onzr queue should be considered as a volatile playlist that you can modify
on-the-fly. You may add tracks to the queue using the add command:
In this case, we've added the track with the 138539157 identifier to the
queue. Since you may not remember Deezer identifier from your favorite tracks,
the add command is often the last command of a more complete pipeline,
e.g.:
onzr search --artist "Radiohead" --ids | # (1) \
head -n 1 | \
onzr artist --top --ids - | # (2) \
onzr add - # (3)
- Note that we use the
--idsoption to only display artists identifiers - Note that we use the
--idsoption to only display tracks identifiers - Note that the
addcommand also accepts the-special operator to read identifiers from the standard input (stdint)
In this case, we will add Radiohead's top-10 tracks to the queue. This is a classical pipeline.
Tip
If you want a fresh start and remove all queued tracks, use the clear
command:
Note that this will also stop the player.
Enjoy your music
Once you filled Onzr's queue, you can start playing it!
By default, if the queue has just been filled and left untouched, the play
command will start playing the first track. If the player is paused, it will
resume playing.
If you prefer playing a particular queued track, you can also start playing
from its rank in the queue. To get the list of queued tracks, you can use the
queue command, get the rank of your favorite track and then play it:
The output should look like:
Queued tracks
โโโโโโโโณโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโณโโโโโโโโโโโโโโโณโโโโโโโโโโโโ
โ Rank โ Track โ Album โ Artist โ
โกโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฉ
โ 1 โ Creep โ Pablo Honey โ Radiohead โ
โ 2 โ No Surprises โ No Surprises โ Radiohead โ
โ 3 โ Let Down โ OK Computer โ Radiohead โ
โ 4 โ Karma Police โ OK Computer โ Radiohead โ
โ 5 โ Everything In Its Right Place โ Kid A โ Radiohead โ
โ 6 โ Exit Music (For A Film) โ OK Computer โ Radiohead โ
โ 7 โ Jigsaw Falling Into Place โ In Rainbows โ Radiohead โ
โ 8 โ All I Need โ In Rainbows โ Radiohead โ
โ 9 โ Weird Fishes / Arpeggi โ In Rainbows โ Radiohead โ
โ 10 โ Paranoid Android โ OK Computer โ Radiohead โ
โโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโดโโโโโโโโโโโโ
If you want to start playing Jigsaw Falling Into Place use its rank:
Control the player
As you may expect, there are few commands that do what they say to control the player:
pause: toggle pausenext: play next track in queueprevious: play previous track in queuestop: stop the player without clearing the queue
Tip
If you want to follow currenly played tracks in real-time you may use the
now command:
Create playlists on-the-fly
One last thing: the mix command is Onzr's secret sauce! This command can
create playlists on the fly given a list of artists names. Let's see it in
action:
onzr mix "avishai cohen" "go go penguin" "yom" --limit 20 --ids | # (1) \
shuf | # (2) \
shuf | \
onzr add -
- Note that we use quotes for each artist (since they may have spaces or special characters in their names)
- The
shufcommand shuffles standard input lines
With this command we add 60 tracks to the queue (20 tracks per artist) in a
random order. By default, we consider the --limit first artist's top-tracks
(defaults to 10).
So if you want to go deeper and discover artists inspired from the ones you
choose, use the --deep option to get tracks from each artist's radio. There
is a great chance that you discover new sounds:
onzr mix --deep "avishai cohen" "go go penguin" "yom" --limit 20 --ids | \
shuf | \
shuf | \
onzr add -
Tip
The cool thing about this mix --deep command is that if you run it twice,
you won't have the same mix, since artist's radio are randomly created.