2022-07-05 12:08:00 -04:00
|
|
|
### Possible endpoints
|
2022-06-23 16:39:13 -04:00
|
|
|
|
|
|
|
Run the API thru the systemd service, or like:
|
|
|
|
|
|
|
|
```BASH
|
2022-07-05 12:08:00 -04:00
|
|
|
ffpapi -l 127.0.0.1:8000
|
2022-06-23 16:39:13 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
For all endpoints an (Bearer) authentication is required.\
|
|
|
|
`{id}` represent the channel id, and at default is 1.
|
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
#### User Handling
|
|
|
|
|
|
|
|
**Login**
|
|
|
|
|
|
|
|
```BASH
|
|
|
|
curl -X POST http://127.0.0.1:8000/auth/login/ -H "Content-Type: application/json" \
|
|
|
|
-d '{ "username": "<USER>", "password": "<PASS>" }'
|
|
|
|
```
|
|
|
|
**Response:**
|
2022-06-23 16:39:13 -04:00
|
|
|
|
|
|
|
```JSON
|
|
|
|
{
|
2022-07-05 12:08:00 -04:00
|
|
|
"id": 1,
|
|
|
|
"mail": "user@example.org",
|
|
|
|
"username": "<USER>",
|
|
|
|
"token": "<TOKEN>"
|
2022-06-23 16:39:13 -04:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
From here on all request **must** contain the authorization header:\
|
|
|
|
`"Authorization: Bearer <TOKEN>"`
|
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
**Get current User**
|
2022-06-23 16:39:13 -04:00
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
```BASH
|
|
|
|
curl -X GET 'http://localhost:8000/api/user' -H 'Content-Type: application/json' \
|
|
|
|
-H 'Authorization: Bearer <TOKEN>'
|
|
|
|
```
|
2022-06-30 12:44:42 -04:00
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
**Update current User**
|
2022-06-23 16:39:13 -04:00
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
```BASH
|
|
|
|
curl -X PUT http://localhost:8000/api/user/1 -H 'Content-Type: application/json' \
|
|
|
|
-d '{"mail": "<MAIL>", "password": "<PASS>"}' -H 'Authorization: <TOKEN>'
|
2022-06-23 16:39:13 -04:00
|
|
|
```
|
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
**Add User**
|
2022-06-23 16:39:13 -04:00
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
```BASH
|
|
|
|
curl -X POST 'http://localhost:8000/api/user/' -H 'Content-Type: application/json' \
|
|
|
|
-d '{"mail": "<MAIL>", "username": "<USER>", "password": "<PASS>", "role_id": 1, "channel_id": 1}' \
|
|
|
|
-H 'Authorization: Bearer <TOKEN>'
|
|
|
|
```
|
|
|
|
|
|
|
|
#### ffpapi Settings
|
2022-06-30 12:44:42 -04:00
|
|
|
|
2022-07-18 16:55:18 -04:00
|
|
|
**Get Settings from Channel**
|
2022-07-05 12:08:00 -04:00
|
|
|
|
|
|
|
```BASH
|
2022-07-18 16:55:18 -04:00
|
|
|
curl -X GET http://127.0.0.1:8000/api/channel/1 -H "Authorization: Bearer <TOKEN>"
|
2022-07-05 12:08:00 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
**Response:**
|
2022-06-23 16:39:13 -04:00
|
|
|
|
|
|
|
```JSON
|
2022-07-05 12:08:00 -04:00
|
|
|
{
|
2022-06-23 16:39:13 -04:00
|
|
|
"id": 1,
|
2022-07-19 05:11:23 -04:00
|
|
|
"name": "Channel 1",
|
2022-07-05 12:08:00 -04:00
|
|
|
"preview_url": "http://localhost/live/preview.m3u8",
|
2022-06-23 16:39:13 -04:00
|
|
|
"config_path": "/etc/ffplayout/ffplayout.yml",
|
2022-07-05 12:08:00 -04:00
|
|
|
"extra_extensions": "jpg,jpeg,png",
|
|
|
|
"timezone": "UTC",
|
|
|
|
"service": "ffplayout.service"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2022-07-18 16:55:18 -04:00
|
|
|
**Get settings from all Channels**
|
2022-07-05 12:08:00 -04:00
|
|
|
|
|
|
|
```BASH
|
2022-07-18 16:55:18 -04:00
|
|
|
curl -X GET http://127.0.0.1:8000/api/channels -H "Authorization: Bearer <TOKEN>"
|
2022-07-05 12:08:00 -04:00
|
|
|
```
|
|
|
|
|
2022-07-18 16:55:18 -04:00
|
|
|
**Update Channel**
|
2022-07-05 12:08:00 -04:00
|
|
|
|
|
|
|
```BASH
|
2022-07-18 16:55:18 -04:00
|
|
|
curl -X PATCH http://127.0.0.1:8000/api/channel/1 -H "Content-Type: application/json" \
|
2022-07-19 05:11:23 -04:00
|
|
|
-d '{ "id": 1, "name": "Channel 1", "preview_url": "http://localhost/live/stream.m3u8", \
|
2022-07-18 16:55:18 -04:00
|
|
|
"config_path": "/etc/ffplayout/ffplayout.yml", "extra_extensions": "jpg,jpeg,png", "timezone": "Europe/Berlin"}' \
|
2022-07-05 12:08:00 -04:00
|
|
|
-H "Authorization: Bearer <TOKEN>"
|
|
|
|
```
|
|
|
|
|
2022-07-18 16:55:18 -04:00
|
|
|
**Create new Channel**
|
|
|
|
|
|
|
|
```BASH
|
|
|
|
curl -X POST http://127.0.0.1:8000/api/channel/ -H "Content-Type: application/json" \
|
2022-07-19 05:11:23 -04:00
|
|
|
-d '{ "name": "Channel 2", "preview_url": "http://localhost/live/channel2.m3u8", \
|
2022-07-18 16:55:18 -04:00
|
|
|
"config_path": "/etc/ffplayout/channel2.yml", "extra_extensions": "jpg,jpeg,png",
|
|
|
|
"timezone": "Europe/Berlin", "service": "ffplayout@channel2.service" }' \
|
|
|
|
-H "Authorization: Bearer <TOKEN>"
|
|
|
|
```
|
|
|
|
|
|
|
|
**Delete Channel**
|
|
|
|
|
|
|
|
```BASH
|
|
|
|
curl -X DELETE http://127.0.0.1:8000/api/channel/2 -H "Authorization: Bearer <TOKEN>"
|
|
|
|
```
|
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
#### ffplayout Config
|
|
|
|
|
|
|
|
**Get Config**
|
|
|
|
|
|
|
|
```BASH
|
|
|
|
curl -X GET http://localhost:8000/api/playout/config/1 -H 'Authorization: <TOKEN>'
|
2022-06-23 16:39:13 -04:00
|
|
|
```
|
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
Response is a JSON object from the ffplayout.yml
|
2022-06-23 16:39:13 -04:00
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
**Update Config**
|
2022-06-23 16:39:13 -04:00
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
```BASH
|
|
|
|
curl -X PUT http://localhost:8000/api/playout/config/1 -H "Content-Type: application/json" \
|
|
|
|
-d { <CONFIG DATA> } -H 'Authorization: <TOKEN>'
|
|
|
|
```
|
2022-06-23 16:39:13 -04:00
|
|
|
|
|
|
|
#### Text Presets
|
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
Text presets are made for sending text messages to the ffplayout engine, to overlay them as a lower third.
|
2022-06-23 16:39:13 -04:00
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
**Get all Presets**
|
|
|
|
|
|
|
|
```BASH
|
|
|
|
curl -X GET http://localhost:8000/api/presets/ -H 'Content-Type: application/json' \
|
|
|
|
-H 'Authorization: <TOKEN>'
|
|
|
|
```
|
|
|
|
|
|
|
|
**Update Preset**
|
|
|
|
|
|
|
|
```BASH
|
|
|
|
curl -X PUT http://localhost:8000/api/presets/1 -H 'Content-Type: application/json' \
|
2022-07-06 11:12:15 -04:00
|
|
|
-d '{ "name": "<PRESET NAME>", "text": "<TEXT>", "x": "<X>", "y": "<Y>", "fontsize": 24, \
|
|
|
|
"line_spacing": 4, "fontcolor": "#ffffff", "box": 1, "boxcolor": "#000000", "boxborderw": 4, "alpha": 1.0, "channel_id": 1 }' \
|
2022-07-05 12:08:00 -04:00
|
|
|
-H 'Authorization: <TOKEN>'
|
|
|
|
```
|
|
|
|
|
2022-07-06 11:12:15 -04:00
|
|
|
**Add new Preset**
|
2022-07-05 12:08:00 -04:00
|
|
|
|
|
|
|
```BASH
|
|
|
|
curl -X POST http://localhost:8000/api/presets/ -H 'Content-Type: application/json' \
|
2022-07-06 11:12:15 -04:00
|
|
|
-d '{ "name": "<PRESET NAME>", "text": "TEXT>", "x": "<X>", "y": "<Y>", "fontsize": 24, \
|
|
|
|
"line_spacing": 4, "fontcolor": "#ffffff", "box": 1, "boxcolor": "#000000", "boxborderw": 4, "alpha": 1.0, "channel_id": 1 }' \
|
|
|
|
-H 'Authorization: <TOKEN>'
|
|
|
|
```
|
|
|
|
|
|
|
|
**Delete Preset**
|
|
|
|
|
|
|
|
```BASH
|
|
|
|
curl -X DELETE http://localhost:8000/api/presets/1 -H 'Content-Type: application/json' \
|
2022-07-05 12:08:00 -04:00
|
|
|
-H 'Authorization: <TOKEN>'
|
|
|
|
```
|
|
|
|
|
|
|
|
### ffplayout controlling
|
|
|
|
|
|
|
|
here we communicate with the engine for:
|
|
|
|
- jump to last or next clip
|
|
|
|
- reset playlist state
|
|
|
|
- get infos about current, next, last clip
|
|
|
|
- send text to the engine, for overlaying it (as lower third etc.)
|
|
|
|
|
|
|
|
**Send Text to ffplayout**
|
2022-06-23 16:39:13 -04:00
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
```BASH
|
|
|
|
curl -X POST http://localhost:8000/api/control/1/text/ \
|
|
|
|
-H 'Content-Type: application/json' -H 'Authorization: <TOKEN>' \
|
|
|
|
-d '{"text": "Hello from ffplayout", "x": "(w-text_w)/2", "y": "(h-text_h)/2", \
|
|
|
|
"fontsize": "24", "line_spacing": "4", "fontcolor": "#ffffff", "box": "1", \
|
|
|
|
"boxcolor": "#000000", "boxborderw": "4", "alpha": "1.0"}'
|
|
|
|
```
|
|
|
|
|
2022-07-06 11:12:15 -04:00
|
|
|
**Control Playout**
|
2022-06-23 16:39:13 -04:00
|
|
|
|
2022-07-06 11:12:15 -04:00
|
|
|
- next
|
|
|
|
- back
|
|
|
|
- reset
|
2022-07-05 12:08:00 -04:00
|
|
|
|
|
|
|
```BASH
|
2022-07-06 11:12:15 -04:00
|
|
|
curl -X POST http://localhost:8000/api/control/1/playout/next/ -H 'Content-Type: application/json'
|
|
|
|
-d '{ "command": "reset" }' -H 'Authorization: <TOKEN>'
|
2022-07-05 12:08:00 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
**Get current Clip**
|
|
|
|
|
|
|
|
```BASH
|
2022-07-06 11:12:15 -04:00
|
|
|
curl -X GET http://localhost:8000/api/control/1/media/current
|
2022-07-05 12:08:00 -04:00
|
|
|
-H 'Content-Type: application/json' -H 'Authorization: <TOKEN>'
|
|
|
|
```
|
|
|
|
|
|
|
|
**Response:**
|
2022-06-23 16:39:13 -04:00
|
|
|
|
|
|
|
```JSON
|
|
|
|
{
|
2022-07-05 12:08:00 -04:00
|
|
|
"jsonrpc": "2.0",
|
|
|
|
"result": {
|
|
|
|
"current_media": {
|
|
|
|
"category": "",
|
|
|
|
"duration": 154.2,
|
|
|
|
"out": 154.2,
|
|
|
|
"seek": 0.0,
|
|
|
|
"source": "/opt/tv-media/clip.mp4"
|
|
|
|
},
|
|
|
|
"index": 39,
|
|
|
|
"play_mode": "playlist",
|
|
|
|
"played_sec": 67.80771999300123,
|
|
|
|
"remaining_sec": 86.39228000699876,
|
|
|
|
"start_sec": 24713.631999999998,
|
|
|
|
"start_time": "06:51:53.631"
|
|
|
|
},
|
|
|
|
"id": 1
|
2022-06-23 16:39:13 -04:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
**Get next Clip**
|
|
|
|
|
|
|
|
```BASH
|
|
|
|
curl -X GET http://localhost:8000/api/control/1/media/next/ -H 'Authorization: <TOKEN>'
|
|
|
|
```
|
|
|
|
|
|
|
|
**Get last Clip**
|
|
|
|
|
|
|
|
```BASH
|
|
|
|
curl -X GET http://localhost:8000/api/control/1/media/last/
|
|
|
|
-H 'Content-Type: application/json' -H 'Authorization: <TOKEN>'
|
|
|
|
```
|
|
|
|
|
|
|
|
#### ffplayout Process Control
|
|
|
|
|
|
|
|
Control ffplayout process, like:
|
|
|
|
- start
|
|
|
|
- stop
|
|
|
|
- restart
|
|
|
|
- status
|
|
|
|
|
|
|
|
```BASH
|
|
|
|
curl -X POST http://localhost:8000/api/control/1/process/
|
|
|
|
-H 'Content-Type: application/json' -H 'Authorization: <TOKEN>'
|
|
|
|
-d '{"command": "start"}'
|
|
|
|
```
|
|
|
|
|
|
|
|
#### ffplayout Playlist Operations
|
2022-06-23 16:39:13 -04:00
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
**Get playlist**
|
2022-06-23 16:39:13 -04:00
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
```BASH
|
|
|
|
curl -X GET http://localhost:8000/api/playlist/1?date=2022-06-20
|
|
|
|
-H 'Content-Type: application/json' -H 'Authorization: <TOKEN>'
|
|
|
|
```
|
2022-06-23 16:39:13 -04:00
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
**Save playlist**
|
2022-06-23 16:39:13 -04:00
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
```BASH
|
|
|
|
curl -X POST http://localhost:8000/api/playlist/1/
|
|
|
|
-H 'Content-Type: application/json' -H 'Authorization: <TOKEN>'
|
|
|
|
-- data "{<JSON playlist data>}"
|
|
|
|
```
|
2022-06-23 16:39:13 -04:00
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
**Generate Playlist**
|
2022-06-23 16:39:13 -04:00
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
A new playlist will be generated and response.
|
2022-06-24 11:41:55 -04:00
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
```BASH
|
|
|
|
curl -X GET http://localhost:8000/api/playlist/1/generate/2022-06-20
|
|
|
|
-H 'Content-Type: application/json' -H 'Authorization: <TOKEN>'
|
|
|
|
```
|
2022-06-23 16:39:13 -04:00
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
**Delete Playlist**
|
2022-06-23 16:39:13 -04:00
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
```BASH
|
|
|
|
curl -X DELETE http://localhost:8000/api/playlist/1/2022-06-20
|
|
|
|
-H 'Content-Type: application/json' -H 'Authorization: <TOKEN>'
|
|
|
|
```
|
2022-06-23 16:39:13 -04:00
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
### Log file
|
2022-06-23 16:39:13 -04:00
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
**Read Log Life**
|
2022-06-23 16:39:13 -04:00
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
```BASH
|
|
|
|
curl -X Get http://localhost:8000/api/log/1
|
|
|
|
-H 'Content-Type: application/json' -H 'Authorization: <TOKEN>'
|
|
|
|
```
|
2022-06-23 16:39:13 -04:00
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
### File Operations
|
2022-06-23 16:39:13 -04:00
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
**Get File/Folder List**
|
2022-06-30 12:44:42 -04:00
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
```BASH
|
|
|
|
curl -X POST http://localhost:8000/api/file/1/browse/ -H 'Content-Type: application/json'
|
|
|
|
-d '{ "source": "/" }' -H 'Authorization: <TOKEN>'
|
|
|
|
```
|
|
|
|
|
|
|
|
**Create Folder**
|
2022-06-30 12:44:42 -04:00
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
```BASH
|
|
|
|
curl -X POST http://localhost:8000/api/file/1/create-folder/ -H 'Content-Type: application/json'
|
|
|
|
-d '{"source": "<FOLDER PATH>"}' -H 'Authorization: <TOKEN>'
|
|
|
|
```
|
2022-06-30 12:44:42 -04:00
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
**Rename File**
|
|
|
|
|
|
|
|
```BASH
|
|
|
|
curl -X POST http://localhost:8000/api/file/1/rename/ -H 'Content-Type: application/json'
|
|
|
|
-d '{"source": "<SOURCE>", "target": "<TARGET>"}' -H 'Authorization: <TOKEN>'
|
|
|
|
```
|
2022-06-23 16:39:13 -04:00
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
**Remove File/Folder**
|
2022-06-23 16:39:13 -04:00
|
|
|
|
2022-07-05 12:08:00 -04:00
|
|
|
```BASH
|
|
|
|
curl -X POST http://localhost:8000/api/file/1/remove/ -H 'Content-Type: application/json'
|
|
|
|
-d '{"source": "<SOURCE>"}' -H 'Authorization: <TOKEN>'
|
|
|
|
```
|
|
|
|
|
|
|
|
**Upload File**
|
|
|
|
|
|
|
|
```BASH
|
|
|
|
curl -X POST http://localhost:8000/api/file/1/upload/ -H 'Authorization: <TOKEN>'
|
|
|
|
-F "file=@file.mp4"
|
|
|
|
```
|