Sign inSign up

stdevel/radio_api

By stdevel

Updated over 5 years ago

Simple mplayer-based radio player controllable via REST API

Image
0

3.9K

stdevel/radio_api repository overview

radio_api

Simple mplayer-based radio player controllable via REST API

Overview

Stations are stored with their URL in a SQLite database.

Requirements

For using this application, you will need:

  • Python 3
  • Flask
  • SQLite 3

Docker container

There is a Dockerfile for running this application inside a container based on Ubuntu Linux. To create the image, run the following command:

$ docker build -t radio .

This will take a couple of minutes, afterwards you should see the image:

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
radio               latest              84572d3b8826        1 hour ago          504.8MB
...

To start a new container based on this image, execute:

$ docker run -d -p 5000:5000 radio
b4735f102afb6e288b0a35d17b0e63da4d6bd2652467709c5c28538088ae5d30

$ docker ps
CONTAINER ID        IMAGE                      COMMAND                   CREATED             STATUS                PORTS                                                                                                  NAMES
b4735f102afb        radio                      "/bin/sh -c \"/opt/jo…"   16 seconds ago      Up 14 seconds         0.0.0.0:5000->5000/tcp                                                                                 boring_chebyshev
...

It is also possible to use shipped docker-compose file:

$ docker-compose create
$ docker-compose up
Starting radio ... done
Attaching to radio
...
radio       |  * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)

API calls

There is also a pre-defined Postman collection.

CallMethodParametersDescription
/api/stationsGET-returns all available stations
/api/stations/<id/name>GETstation ID or namereturns a particular station
/api/stations/<id/name>/playGETstation ID or nameplays a particular station
/api/stationsPOST{ "item": { "url": "<str>" } }creates a new station
/api/stations/<id/name>PUT,POSTstation ID or name, { "item": {"id": <int>, "url": "<str>"} }updates an existing station
/api/stations/<id/name>DELETEstation ID or nameremoves a station
/api/nextGET-plays the next station
/api/previousGET-plays the previous station
/api/stopGET-stops the radio
/api/currentGET-returns the currently played station
/api/volumeGET-returns the current volume level
/api/volumePOST{ "level": <int> }sets volume to a specific level
/api/volume/upGET-increases the volume by 10%
/api/volume/downGET-decreases the volume by 10%

Database layout

stations
Field nameField typeDescription
station_idINTEGER PRIMARY KEY AUTOINCREMENTstation ID
station_nameTEXT NOT NULLstation name
station_urlTEXT NOT NULLstation URL

Tag summary

Content type

Image

Digest

Size

265.4 MB

Last updated

over 5 years ago

docker pull stdevel/radio_api