2018-08-28 Fred Gleason <fredg@paravelsystems.com>

* Added support for the Spinitron v2 API in the 'spinitron_plus'
	RLM [Pull Request #000211].
This commit is contained in:
Fred Gleason 2018-08-28 13:54:32 -04:00
parent 65e7559009
commit 83fa79a84d
3 changed files with 63 additions and 14 deletions

View File

@ -16672,3 +16672,6 @@
2018-08-28 Fred Gleason <fredg@paravelsystems.com>
* Added an optional third argument to the 'Add Next' ['PX'] RML
to allow specication of the transition type.
2018-08-28 Fred Gleason <fredg@paravelsystems.com>
* Added support for the Spinitron v2 API in the 'spinitron_plus'
RLM [Pull Request #000211].

View File

@ -18,6 +18,12 @@
; 'Spinitron1' and working up consecutively
[Spinitron1]
; MajorVersion
;
; The major version of the Spinitron API to be used. Choices are '1'
; or '2'.
MajorVersion=1
; Station;
;
; The station to be used for the Spinitron account to which to log the
@ -27,13 +33,21 @@ Station=wxyz
; Username
;
; Username for the Spinitron account to which to log the play-out.
; (This setting is only needed for Spinitron major version 1).
Username=user@example.com
; Password
;
; The password of the Spinitron account to which to log the play-out.
; (This setting is only needed for Spinitron major version 1).
Password=changeme
; APIKey
;
; API key for the Spinitron v2 account to which to log the play-out.
; (This setting is only needed for Spinitron major version 2).
APIKey=change_me_please
; PlaylistMode
;
; Set the Spinitron playlist mode to use when sending updates.

View File

@ -43,9 +43,11 @@
#define RLM_SPINITRON_PLUS_LOGGER_NAME "Rivendell"
int rlm_spinitron_plus_devs;
int *rlm_spinitron_plus_major_versions;
char *rlm_spinitron_plus_stations;
char *rlm_spinitron_plus_usernames;
char *rlm_spinitron_plus_passwords;
char *rlm_spinitron_plus_api_keys;
int *rlm_spinitron_plus_playlist_modes;
char *rlm_spinitron_plus_titles;
char *rlm_spinitron_plus_artists;
@ -171,9 +173,11 @@ void rlm_spinitron_plus_RLMStart(void *ptr,const char *arg)
int i=1;
rlm_spinitron_plus_devs=0;
rlm_spinitron_plus_major_versions=NULL;
rlm_spinitron_plus_stations=NULL;
rlm_spinitron_plus_usernames=NULL;
rlm_spinitron_plus_passwords=NULL;
rlm_spinitron_plus_api_keys=NULL;
rlm_spinitron_plus_playlist_modes=NULL;
rlm_spinitron_plus_titles=NULL;
rlm_spinitron_plus_artists=NULL;
@ -193,6 +197,12 @@ void rlm_spinitron_plus_RLMStart(void *ptr,const char *arg)
return;
}
while(strlen(station)>0) {
rlm_spinitron_plus_major_versions=realloc(rlm_spinitron_plus_major_versions,
(rlm_spinitron_plus_devs+1)*(rlm_spinitron_plus_devs+1)*sizeof(int));
strcpy(rlm_spinitron_plus_stations+256*rlm_spinitron_plus_devs,station);
rlm_spinitron_plus_major_versions[rlm_spinitron_plus_devs]=
RLMGetIntegerValue(ptr,arg,section,"MajorVersion",1);
rlm_spinitron_plus_stations=realloc(rlm_spinitron_plus_stations,
(rlm_spinitron_plus_devs+1)*(rlm_spinitron_plus_devs+1)*256);
strcpy(rlm_spinitron_plus_stations+256*rlm_spinitron_plus_devs,station);
@ -210,6 +220,12 @@ void rlm_spinitron_plus_RLMStart(void *ptr,const char *arg)
RLMGetStringValue(ptr,arg,section,"Password",""));
rlm_spinitron_plus_EncodeString(rlm_spinitron_plus_passwords+256*rlm_spinitron_plus_devs,255);
rlm_spinitron_plus_api_keys=realloc(rlm_spinitron_plus_api_keys,
(rlm_spinitron_plus_devs+1)*(rlm_spinitron_plus_devs+1)*256);
strcpy(rlm_spinitron_plus_api_keys+256*rlm_spinitron_plus_devs,
RLMGetStringValue(ptr,arg,section,"APIKey",""));
rlm_spinitron_plus_EncodeString(rlm_spinitron_plus_api_keys+256*rlm_spinitron_plus_devs,255);
pmode=3;
strcpy(mode,RLMGetStringValue(ptr,arg,section,"PlaylistMode",""));
if(strcasecmp(mode,"full")==0) {
@ -275,8 +291,10 @@ void rlm_spinitron_plus_RLMStart(void *ptr,const char *arg)
void rlm_spinitron_plus_RLMFree(void *ptr)
{
free(rlm_spinitron_plus_stations);
free(rlm_spinitron_plus_major_versions);
free(rlm_spinitron_plus_usernames);
free(rlm_spinitron_plus_passwords);
free(rlm_spinitron_plus_api_keys);
free(rlm_spinitron_plus_playlist_modes);
free(rlm_spinitron_plus_titles);
free(rlm_spinitron_plus_artists);
@ -358,20 +376,34 @@ void rlm_spinitron_plus_RLMPadDataSent(void *ptr,const struct rlm_svc *svc,
}
if(strlen(now->rlm_title)!=0) {
snprintf(msg,8192,
"https://spinitron.com/member/logthis.php?un=%s&pw=%s&sn=%s&aw=%s&dn=%s&ln=%s&sc=%s&se=%s&df=%s&st=%s&sd=%d&pm=%d",
rlm_spinitron_plus_usernames+256*i,
rlm_spinitron_plus_passwords+256*i,
title,
artist,
album,
label,
composer,
notes,
RLM_SPINITRON_PLUS_LOGGER_NAME,
rlm_spinitron_plus_stations+256*i,
now->rlm_len/1000,
pm);
if(rlm_spinitron_plus_major_versions[i]==2) { /* Use v2 API */
snprintf(msg,8192,
"https://spinitron.com/api/spin/create-v1?access-token=%s&sn=%s&aw=%s&dn=%s&ln=%s&sc=%s&se=%s&sd=%d",
rlm_spinitron_plus_api_keys+256*i,
title,
artist,
album,
label,
composer,
notes,
now->rlm_len/1000);
}
else { /* Default to v1 API */
snprintf(msg,8192,
"https://spinitron.com/member/logthis.php?un=%s&pw=%s&sn=%s&aw=%s&dn=%s&ln=%s&sc=%s&se=%s&df=%s&st=%s&sd=%d&pm=%d",
rlm_spinitron_plus_usernames+256*i,
rlm_spinitron_plus_passwords+256*i,
title,
artist,
album,
label,
composer,
notes,
RLM_SPINITRON_PLUS_LOGGER_NAME,
rlm_spinitron_plus_stations+256*i,
now->rlm_len/1000,
pm);
}
if(fork()==0) {
execlp("curl","curl",msg,(char *)NULL);
RLMLog(ptr,LOG_WARNING,"rlm_spinitron_plus: unable to execute curl(1)");