Commit d230bc48 authored by Dainis Abols's avatar Dainis Abols
Browse files

Moved LR connections to configuration

4.0.9
parent b88076dd
......@@ -94,7 +94,6 @@ class Play extends AbstractEntity
*/
public $first;
/**
* Cron script
*
......@@ -170,6 +169,7 @@ class Play extends AbstractEntity
$dataHelper->saveInCache(DataHelper::CACHED_SONG_ENTRY, $currentSong, DataHelper::CACHED_SONG_TIME);
}
// If new song success, send new data to LR
$this->sendLRData();
......@@ -178,32 +178,23 @@ class Play extends AbstractEntity
}
/**
* @TODO: Make normal
* @TODO: Create date model for JAVA type
*
* Get access token
* curl -X POST -d "grant_type=password&username=radionaba&password=GrupaStrikis1" -u"slcQEpQrIDJzUOpf5j7C1P58ErUaXEi7jMxtqpAb:eHZt44PixFizcL2B7SA73m4OngB2doR9vm37aKaWU719DXAgSCTIn0hzk5LJlLO81s4hjhotvhkwc8AmfQubPGBSgLJb1ewcpsoz7Xdk5JwH5gItAjU29wccCDcRaLN6" https://lr-api.dev.pieci.lv/oauth/token/ | jq '.'
*
* Refresh access token
* curl -X POST -d "grant_type=refresh_token&client_id=slcQEpQrIDJzUOpf5j7C1P58ErUaXEi7jMxtqpAb&client_secret=eHZt44PixFizcL2B7SA73m4OngB2doR9vm37aKaWU719DXAgSCTIn0hzk5LJlLO81s4hjhotvhkwc8AmfQubPGBSgLJb1ewcpsoz7Xdk5JwH5gItAjU29wccCDcRaLN6&refresh_token=fsVjYIgVbcfIAqFPqsU1qyenTLT2qi" https://lr-api.dev.pieci.lv/oauth/token/ | jq '.'
*
* Send song data
* curl -X POST -H "Authorization: Bearer hXsaOByg7lOJNRGHvmaqj1pTlBzYK2" -H 'Content-Type: application/json' -d '[{"station":6,"id":990990992,"status":"playing","type":"song","airtime_utc":"2022-03-23T13:00:00.0006237Z","endtime_utc":"2022-03-23T13:02:40.0006237Z","artist":[{"name":"ŠŅK"}],"title":"Nevajadzīgs","length":"160.0"}]' https://lr-api.dev.pieci.lv/now/
* Send data to Latvijas Radio
*
* @return void
*/
public function sendLRData()
{
$this->getConfig();
$currentSong = $this->getLastEntry();
$currentProgramme = $this->getCurrentProgramme();
// Basic data
$clientId = "";
$clientSecret = "";
$url_token = "";
$url_submit = "";
$user = "";
$pass = "";
$clientId = $this->conf['clientId'];
$clientSecret = $this->conf['clientSecret'];
$url_token = $this->conf['url_token'];
$url_submit = $this->conf['url_submit'];
$user = $this->conf['user'];
$pass = $this->conf['pass'];
// Data array
$data = [
......@@ -242,7 +233,7 @@ class Play extends AbstractEntity
// Send data
$client = new Guzzle();
$raw_response = $client->post($url_submit, [
$client->post($url_submit, [
'headers' => [
'Authorization' => 'Bearer '.$bearer,
'Content-Type' => 'application/json',
......@@ -250,11 +241,6 @@ class Play extends AbstractEntity
'json' => [$data],
]);
// print_r($raw_response->getBody()->getContents());
// // @TODO: Log full JSON respopnse
// die;
return true;
}
......
......@@ -4,7 +4,7 @@
## Version
4.0.8
4.0.9
## Dependencies
......@@ -32,11 +32,17 @@ Lauris Karklis <lauris.karklis@lu.lv>
## Configuration
Var name | Meaning |
| --------------- | ------------------------------------------ |
| ipIncreaseCount | Admin song increase count (+) |
| ipDecreaseCount | Admin song decrease count (+) |
| eventPageId | Calendarize event PID for programm display |
| streamServer | Streaming server endpoint |
| top10StorageId | Top 10 storage page id |
| top25StorageId | Top 25 storage page id |
| Var name | Category | Meaning |
|-----------------|----------------|--------------------------------------------|
| ipIncreaseCount | General | Admin song increase count (+) |
| ipDecreaseCount | General | Admin song decrease count (+) |
| eventPageId | General | Calendarize event PID for programm display |
| streamServer | General | Streaming server endpoint |
| top10StorageId | TOP | Top 10 storage page id |
| top25StorageId | TOP | Top 25 storage page id |
| user | Latvijas Radio | Auth Username |
| pass | Latvijas Radio | Auth Password |
| clientId | Latvijas Radio | Client ID |
| clientSecret | Latvijas Radio | Client Secret |
| url_token | Latvijas Radio | Token URL |
| url_submit | Latvijas Radio | Data submit URL |
{
"name": "luitd/lu-nabamusic",
"version": "4.0.8",
"version": "4.0.9",
"description": "Radio NABA plugin used for live stream, song tops and much more",
"type": "typo3-cms-extension",
"keywords": [
......
......@@ -13,10 +13,13 @@ eventPageId =
# cat=General/set; type=string; label=stream_server:Live stream server address
streamServer = http://5.179.12.179/
# cat=Tops/set; type=string; label=Top 10 storage page id
# TOP's settings
###########################
# cat=TOP/set; type=int; label=Top 10 storage page id
top10StorageId =
# cat=Tops/set; type=string; label=Top 25 storage page id
# cat=TOP/set; type=int; label=Top 25 storage page id
top25StorageId =
# Latvijas Radio settings
......
......@@ -13,7 +13,7 @@ $EM_CONF[$_EXTKEY] = [
'modify_tables' => '',
'clearCacheOnLoad' => 1,
'lockType' => '',
'version' => '4.0.8',
'version' => '4.0.9',
'constraints' => [
'depends' => [
'typo3' => '10.0.0-10.9.99',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment