RESTful API for remote control of the video player on the albertsongs.github.io
- Spring Boot
- STOMP over WebSockets
- Hibernate
- PostgreSQL
- Maven
- Docker Compose
- JUnit & Mockito
To deploy the project in docker container, follow these steps:
- Copy the file certificate.p12 to project subfolder ./cert
- or create from .pem files:
openssl pkcs12 -export -in certificate.pem -inkey key.pem -out certificate.p12 -CAfile caChain.pem -chain
- or create from .crt files:
openssl pkcs12 -export -in certificate.crt -inkey private.key -out certificate.p12 -CAfile ca_bundle.crt -chain
- or create from .pem files:
- Fill the field SERVER_SSL_KEY_STORE_PASSWORD in docker-compose.yml
- Run init.sh
- add request param "isOnline" to filter receivers in requests:
GET: /api/v1.2/receivers?isOnline=true
GET: /api/v1.2/receivers/{receiverId}?isOnline=false
POST: /api/v1.1/receivers/<receiver_id>/play-pause
POST: /api/v1.1/receivers/<receiver_id>/previous
POST: /api/v1.1/receivers/<receiver_id>/next
POST: /api/v1.1/receivers/<receiver_id>/volume/up
POST: /api/v1.1/receivers/<receiver_id>/volume/down
New requests send commands to the receiver
Response:
202 Accepted
Errors:
404 Not found
GET: /api/v1/videos
Response:
200 OK
{
"list": [
{
"id": 0,
"title": "Одноклассники мои",
"url": "https://albertsongs.github.io/content/videos/Одноклассники мои.webm",
"subtitlesUrl": "https://albertsongs.github.io/content/subtitles/Одноклассники мои.vtt"
},
{
"id": 1,
"title": "Золотая моя рыбка"
"url": "https://albertsongs.github.io/content/videos/Золотая моя рыбка.webm",
"subtitlesUrl": "https://albertsongs.github.io/content/subtitles/Золотая моя рыбка.vtt"
}
]
}
Allowed query params:
- playlistId - for filter by playlist identifier (not required)
GET: /api/v1/playlists
Response:
200 OK
{
"list": [
{
"id": 0,
"name": "Нити времени",
"youtubeId": "PLjv4Gt_enoJvL5QUt1H3bv9F3Omuj9n3g"
},
{
"id": 1,
"name": "Старые каверы",
"youtubeId": "PLjv4Gt_enoJvHxigfI9ETQJn6pbzYEX2Q"
}
]
}
GET: /api/v1/receivers
Returns the list of receivers from the client's local network sorted by novelty
Response:
200 OK
{
"list": [
{
"id": "1052ccc0-b115-422f-a878-95ac2020cf85",
"name": "TV",
"updatedAt": "2022-06-26T08:38:34.609+00:00"
},
{
"id": "8d7404f8-4bd7-47f7-a281-4e3f6e36bcc2",
"name": "PC",
"updatedAt": "2022-06-26T08:38:34.604+00:00"
}
]
}
POST: /api/v1/receivers
Body:
{
"name": "Laptop"
}
Response:
200 OK
{
"id": "0080022c-2c86-48f5-b28e-bcf934f2d6ef",
"name": "Laptop",
"updatedAt": "2022-06-26T08:48:32.893+00:00"
}
Errors:
400 Bad request
404 Not found
GET: /api/v1/receivers/<receiver_id>
Response:
200 OK
{
"id": <receiver_id>,
"name": "Laptop",
"updatedAt": "2022-06-26T08:48:32.893+00:00"
}
Errors:
404 Not found
PATCH: /api/v1/receivers/<receiver_id>
Body:
{
"name": "New laptop"
}
Response:
200 OK
{
"id": <receiver_id>,
"name": "New laptop",
"updatedAt": "2022-06-26T08:52:21.922+00:00"
}
Errors:
400 Bad request
404 Not found
DELETE: /api/v1/receivers/<receiver_id>
Response:
200 OK
Errors:
404 Not found
POST: /api/v1/receivers/<receiver_id>/playVideo
Sends a command to play video to the receiver
Body:
{
"id": <video_id>
}
Response:
202 Accepted
Errors:
404 Not found
Class | Method | Line |
---|---|---|
94% | 80% | 81% |