mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2026-01-13 08:05:55 +01:00
2018-12-20 Fred Gleason <fredg@paravelsystems.com>
* Added a 'PyPAD.Update::startDateTimeString()' method. * Added a 'pypad_spinitron.py' PyPAD script. * Removed the 'rlm_spinitron_plus' RLM.
This commit is contained in:
@@ -18241,3 +18241,7 @@
|
|||||||
and 'PyPAD.Update::padField()'.
|
and 'PyPAD.Update::padField()'.
|
||||||
2018-12-18 Fred Gleason <fredg@paravelsystems.com>
|
2018-12-18 Fred Gleason <fredg@paravelsystems.com>
|
||||||
* Removed the 'rlm_padpoint' RLM.
|
* Removed the 'rlm_padpoint' RLM.
|
||||||
|
2018-12-20 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
* Added a 'PyPAD.Update::startDateTimeString()' method.
|
||||||
|
* Added a 'pypad_spinitron.py' PyPAD script.
|
||||||
|
* Removed the 'rlm_spinitron_plus' RLM.
|
||||||
|
|||||||
@@ -418,6 +418,19 @@ class Update(object):
|
|||||||
except TypeError:
|
except TypeError:
|
||||||
return False;
|
return False;
|
||||||
|
|
||||||
|
def startDateTimeString(self,pad_type):
|
||||||
|
"""
|
||||||
|
Returns the start date-time of the specified PAD type in ISO 8601
|
||||||
|
format (string).
|
||||||
|
|
||||||
|
Takes one argument:
|
||||||
|
|
||||||
|
pad_type - The type of PAD value. Valid values are:
|
||||||
|
PyPAD.TYPE_NOW - Now playing data
|
||||||
|
PyPAD.TYPE_NEXT - Next to play data
|
||||||
|
"""
|
||||||
|
return self.__fields['padUpdate'][pad_type]['startDateTime']
|
||||||
|
|
||||||
def startDateTime(self,pad_type):
|
def startDateTime(self,pad_type):
|
||||||
"""
|
"""
|
||||||
Returns the start datetime of the specified PAD type
|
Returns the start datetime of the specified PAD type
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ install-exec-am:
|
|||||||
cp pypad_filewrite.exemplar $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_filewrite.exemplar
|
cp pypad_filewrite.exemplar $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_filewrite.exemplar
|
||||||
../../../helpers/install_python.sh pypad_live365.py $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_live365.py
|
../../../helpers/install_python.sh pypad_live365.py $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_live365.py
|
||||||
cp pypad_live365.exemplar $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_live365.exemplar
|
cp pypad_live365.exemplar $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_live365.exemplar
|
||||||
|
|
||||||
|
../../../helpers/install_python.sh pypad_spinitron.py $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_spinitron.py
|
||||||
|
cp pypad_spinitron.exemplar $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_spinitron.exemplar
|
||||||
|
|
||||||
../../../helpers/install_python.sh pypad_udp.py $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_udp.py
|
../../../helpers/install_python.sh pypad_udp.py $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_udp.py
|
||||||
cp pypad_udp.exemplar $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_udp.exemplar
|
cp pypad_udp.exemplar $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_udp.exemplar
|
||||||
../../../helpers/install_python.sh pypad_urlwrite.py $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_urlwrite.py
|
../../../helpers/install_python.sh pypad_urlwrite.py $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_urlwrite.py
|
||||||
@@ -38,6 +42,8 @@ uninstall-local:
|
|||||||
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_filewrite.py
|
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_filewrite.py
|
||||||
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_live365.exemplar
|
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_live365.exemplar
|
||||||
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_live365.py
|
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_live365.py
|
||||||
|
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_spinitron.exemplar
|
||||||
|
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_spinitron.py
|
||||||
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_udp.exemplar
|
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_udp.exemplar
|
||||||
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_udp.py
|
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_udp.py
|
||||||
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_urlwrite.exemplar
|
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_urlwrite.exemplar
|
||||||
@@ -49,6 +55,8 @@ EXTRA_DIST = pypad_filewrite.exemplar\
|
|||||||
pypad_filewrite.py\
|
pypad_filewrite.py\
|
||||||
pypad_live365.exemplar\
|
pypad_live365.exemplar\
|
||||||
pypad_live365.py\
|
pypad_live365.py\
|
||||||
|
pypad_spinitron.exemplar\
|
||||||
|
pypad_spinitron.py\
|
||||||
pypad_udp.exemplar\
|
pypad_udp.exemplar\
|
||||||
pypad_udp.py\
|
pypad_udp.py\
|
||||||
pypad_urlwrite.exemplar\
|
pypad_urlwrite.exemplar\
|
||||||
|
|||||||
132
apis/PyPAD/scripts/pypad_spinitron.exemplar
Normal file
132
apis/PyPAD/scripts/pypad_spinitron.exemplar
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
; This is the configuration for the 'pypad_spinitron' script
|
||||||
|
; for Rivendell, which can be used log Now & Next data to the Spinitron
|
||||||
|
; online playlist service [http://www.spinitron.com].
|
||||||
|
|
||||||
|
; Section Header
|
||||||
|
;
|
||||||
|
; One section per Spinitron account is configured, starting with
|
||||||
|
; 'Spinitron1' and working up consecutively
|
||||||
|
[Spinitron1]
|
||||||
|
|
||||||
|
; 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.
|
||||||
|
;
|
||||||
|
; (For a discussion of the implications of this setting on your
|
||||||
|
; Spinitron playlists, see Section 3.2 of the 'Spinitron Automation
|
||||||
|
; Integration' document, available from Spinitron).
|
||||||
|
;
|
||||||
|
; The following options are recognized:
|
||||||
|
;
|
||||||
|
; Full - Always use the Spinitron 'Full Automation' mode.
|
||||||
|
; Assist - Always use the Spinitron 'Live Assist' mode.
|
||||||
|
; Follow - Use the Spinitron 'Full Automation' mode when RDAirPlay
|
||||||
|
; is in Automatic, otherwise use the Spinitron 'Live Assist' mode.
|
||||||
|
PlaylistMode=Follow
|
||||||
|
|
||||||
|
; Title. The string to be sent as the 'Title' field for each update,
|
||||||
|
; including any wildcards as placeholders for metadata values. For the
|
||||||
|
; list of supported wildcards. see the 'Metadata Wildcards' section of the
|
||||||
|
; Rivendell Operations Guide.
|
||||||
|
Title=%t
|
||||||
|
|
||||||
|
; Artist. The string to be sent as the 'Artist' field for each update,
|
||||||
|
; including any wildcards as placeholders for metadata values.
|
||||||
|
Artist=%a
|
||||||
|
|
||||||
|
; Album. The string to be sent as the 'Album' field for each update,
|
||||||
|
; including any wildcards as placeholders for metadata values.
|
||||||
|
Album=%l
|
||||||
|
|
||||||
|
; Label. The string to be sent as the 'Label' field for each update,
|
||||||
|
; including any wildcards as placeholders for metadata values.
|
||||||
|
Label=%b
|
||||||
|
|
||||||
|
; Composer. The string to be sent as the 'Composer' field for each update,
|
||||||
|
; including any wildcards as placeholders for metadata values.
|
||||||
|
Composer=%m
|
||||||
|
|
||||||
|
; Conductor. The string to be sent as the 'Conductor' field for each update,
|
||||||
|
; including any wildcards as placeholders for metadata values.
|
||||||
|
Conductor=%r
|
||||||
|
|
||||||
|
; Notes. The string to be sent as the 'Notes' field for each update,
|
||||||
|
; including any wildcards as placeholders for metadata values.
|
||||||
|
Notes=%u
|
||||||
|
|
||||||
|
; Log Selection
|
||||||
|
;
|
||||||
|
; Set the status for each log to 'Yes', 'No' or 'Onair' to indicate whether
|
||||||
|
; state changes on that log should be output to this account. If set
|
||||||
|
; to 'Onair', then output will be generated only if RDAirPlays OnAir flag
|
||||||
|
; is active.
|
||||||
|
MasterLog=Yes
|
||||||
|
Aux1Log=Yes
|
||||||
|
Aux2Log=Yes
|
||||||
|
VLog101=No
|
||||||
|
VLog102=No
|
||||||
|
VLog103=No
|
||||||
|
VLog104=No
|
||||||
|
VLog105=No
|
||||||
|
VLog106=No
|
||||||
|
VLog107=No
|
||||||
|
VLog108=No
|
||||||
|
VLog109=No
|
||||||
|
VLog110=No
|
||||||
|
VLog111=No
|
||||||
|
VLog112=No
|
||||||
|
VLog113=No
|
||||||
|
VLog114=No
|
||||||
|
VLog115=No
|
||||||
|
VLog116=No
|
||||||
|
VLog117=No
|
||||||
|
VLog118=No
|
||||||
|
VLog119=No
|
||||||
|
VLog120=No
|
||||||
|
|
||||||
|
|
||||||
|
; Additional Spinitron instances can be configured by adding new
|
||||||
|
; sections...
|
||||||
|
;
|
||||||
|
;[Spinitron2]
|
||||||
|
;MajorVersion=2
|
||||||
|
;Station=abcd
|
||||||
|
;Username=metoo
|
||||||
|
;Password=letmein
|
||||||
|
;APIKey=some_different_key
|
||||||
|
;Title=%t
|
||||||
|
;Artist=%a
|
||||||
|
;Album=%l
|
||||||
|
;Label=%b
|
||||||
|
;Composer=%m
|
||||||
|
;Conductor=%r
|
||||||
|
;Notes=%u
|
||||||
|
;MasterLog=Yes
|
||||||
|
;Aux1Log=No
|
||||||
|
;Aux2Log=Onair
|
||||||
|
;VLog101=No
|
||||||
|
;VLog102=No
|
||||||
|
;VLog103=No
|
||||||
|
;VLog104=No
|
||||||
|
;VLog105=No
|
||||||
|
;VLog106=No
|
||||||
|
;VLog107=No
|
||||||
|
;VLog108=No
|
||||||
|
;VLog109=No
|
||||||
|
;VLog110=No
|
||||||
|
;VLog111=No
|
||||||
|
;VLog112=No
|
||||||
|
;VLog113=No
|
||||||
|
;VLog114=No
|
||||||
|
;VLog115=No
|
||||||
|
;VLog116=No
|
||||||
|
;VLog117=No
|
||||||
|
;VLog118=No
|
||||||
|
;VLog119=No
|
||||||
|
;VLog120=No
|
||||||
128
apis/PyPAD/scripts/pypad_spinitron.py
Executable file
128
apis/PyPAD/scripts/pypad_spinitron.py
Executable file
@@ -0,0 +1,128 @@
|
|||||||
|
#!%PYTHON_BANGPATH%
|
||||||
|
|
||||||
|
# pypad_spinitron.py
|
||||||
|
#
|
||||||
|
# Write PAD updates to the Spinitron Playlist Service
|
||||||
|
#
|
||||||
|
# (C) Copyright 2018 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License version 2 as
|
||||||
|
# published by the Free Software Foundation.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public
|
||||||
|
# License along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
#
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import syslog
|
||||||
|
import configparser
|
||||||
|
import pycurl
|
||||||
|
import PyPAD
|
||||||
|
from io import BytesIO
|
||||||
|
|
||||||
|
last_updates={}
|
||||||
|
|
||||||
|
def eprint(*args,**kwargs):
|
||||||
|
print(*args,file=sys.stderr,**kwargs)
|
||||||
|
|
||||||
|
def JsonField(update,tag,value,is_last=False):
|
||||||
|
if (value==None) or (value==''):
|
||||||
|
ret=' "'+tag+'": null'
|
||||||
|
else:
|
||||||
|
ret=' "'+tag+'": "'+update.escape(value,PyPAD.ESCAPE_JSON)+'"'
|
||||||
|
if not is_last:
|
||||||
|
ret+=','
|
||||||
|
return ret+'\r\n'
|
||||||
|
|
||||||
|
def ProcessPad(update):
|
||||||
|
try:
|
||||||
|
last_updates[update.machine()]
|
||||||
|
except KeyError:
|
||||||
|
last_updates[update.machine()]=None
|
||||||
|
|
||||||
|
n=1
|
||||||
|
try:
|
||||||
|
while(True):
|
||||||
|
section='Spinitron'+str(n)
|
||||||
|
if update.shouldBeProcessed(section) and update.hasPadType(PyPAD.TYPE_NOW) and (last_updates[update.machine()] != update.startDateTimeString(PyPAD.TYPE_NOW)):
|
||||||
|
last_updates[update.machine()]=update.startDateTimeString(PyPAD.TYPE_NOW)
|
||||||
|
title=update.resolvePadFields(update.config().get(section,'Title'),PyPAD.ESCAPE_JSON)
|
||||||
|
artist=update.resolvePadFields(update.config().get(section,'Artist'),PyPAD.ESCAPE_JSON)
|
||||||
|
album=update.resolvePadFields(update.config().get(section,'Album'),PyPAD.ESCAPE_JSON)
|
||||||
|
label=update.resolvePadFields(update.config().get(section,'Label'),PyPAD.ESCAPE_JSON)
|
||||||
|
composer=update.resolvePadFields(update.config().get(section,'Composer'),PyPAD.ESCAPE_JSON)
|
||||||
|
conductor=update.resolvePadFields(update.config().get(section,'Conductor'),PyPAD.ESCAPE_JSON)
|
||||||
|
notes=update.resolvePadFields(update.config().get(section,'Notes'),PyPAD.ESCAPE_JSON)
|
||||||
|
|
||||||
|
json='{\r\n'
|
||||||
|
pmode=update.config().get(section,'PlaylistMode')
|
||||||
|
if pmode=='Full':
|
||||||
|
json+=' "live": false\r\n'
|
||||||
|
if pmode=='Assist':
|
||||||
|
json+=' "live:" true\r\n'
|
||||||
|
if pmode=='Follow':
|
||||||
|
if update.mode()=='Automatic':
|
||||||
|
json+=' "live": false,\r\n'
|
||||||
|
else:
|
||||||
|
json+=' "live": true,\r\n'
|
||||||
|
duration=str(update.padField(PyPAD.TYPE_NOW,PyPAD.FIELD_LENGTH)//1000)
|
||||||
|
year=update.padField(PyPAD.TYPE_NOW,PyPAD.FIELD_YEAR)
|
||||||
|
if year==None:
|
||||||
|
json+=' "released": null,\r\n'
|
||||||
|
else:
|
||||||
|
json+=' "released": '+str(year)+',\r\n'
|
||||||
|
json+=' "duration": '+duration+',\r\n'
|
||||||
|
json+=JsonField(update,'artist',artist)
|
||||||
|
json+=JsonField(update,'release',album)
|
||||||
|
json+=JsonField(update,'label',label)
|
||||||
|
json+=JsonField(update,'song',title)
|
||||||
|
json+=JsonField(update,'composer',composer)
|
||||||
|
json+=JsonField(update,'conductor',conductor)
|
||||||
|
json+=JsonField(update,'note',notes)
|
||||||
|
json+=JsonField(update,'isrc',update.padField(PyPAD.TYPE_NOW,PyPAD.FIELD_ISRC),True)
|
||||||
|
json+='}\r\n'
|
||||||
|
send_buf=BytesIO(json.encode('utf-8'))
|
||||||
|
recv_buf=BytesIO()
|
||||||
|
curl=pycurl.Curl()
|
||||||
|
curl.setopt(curl.URL,'https://spinitron.com/api/spins')
|
||||||
|
headers=[]
|
||||||
|
headers.append('Authorization: Bearer '+update.config().get(section,'APIKey'))
|
||||||
|
headers.append('Content-Type: application/json')
|
||||||
|
headers.append('Content-Length: '+str(len(json.encode('utf-8'))))
|
||||||
|
curl.setopt(curl.HTTPHEADER,headers);
|
||||||
|
curl.setopt(curl.POST,True)
|
||||||
|
curl.setopt(curl.READDATA,send_buf)
|
||||||
|
curl.setopt(curl.WRITEDATA,recv_buf)
|
||||||
|
try:
|
||||||
|
curl.perform()
|
||||||
|
code=curl.getinfo(pycurl.RESPONSE_CODE)
|
||||||
|
if (code<200) or (code>=300):
|
||||||
|
syslog.syslog(syslog.LOG_WARNING,'['+section+'] returned response code '+str(code))
|
||||||
|
except pycurl.error:
|
||||||
|
syslog.syslog(syslog.LOG_WARNING,'['+section+'] failed: '+curl.errstr())
|
||||||
|
curl.close()
|
||||||
|
n=n+1
|
||||||
|
|
||||||
|
except configparser.NoSectionError:
|
||||||
|
return
|
||||||
|
|
||||||
|
#
|
||||||
|
# 'Main' function
|
||||||
|
#
|
||||||
|
syslog.openlog(sys.argv[0].split('/')[-1])
|
||||||
|
|
||||||
|
rcvr=PyPAD.Receiver()
|
||||||
|
try:
|
||||||
|
rcvr.setConfigFile(sys.argv[3])
|
||||||
|
except IndexError:
|
||||||
|
eprint('pypad_spinitron.py: you must specify a configuration file')
|
||||||
|
sys.exit(1)
|
||||||
|
rcvr.setCallback(ProcessPad)
|
||||||
|
rcvr.start(sys.argv[1],int(sys.argv[2]))
|
||||||
@@ -27,7 +27,6 @@ RLM_MODULES=rlm_ando.rlm\
|
|||||||
rlm_liqcomp.rlm\
|
rlm_liqcomp.rlm\
|
||||||
rlm_serial.rlm\
|
rlm_serial.rlm\
|
||||||
rlm_shoutcast1.rlm\
|
rlm_shoutcast1.rlm\
|
||||||
rlm_spinitron_plus.rlm\
|
|
||||||
rlm_spottrap.rlm\
|
rlm_spottrap.rlm\
|
||||||
rlm_test.rlm\
|
rlm_test.rlm\
|
||||||
rlm_tunein.rlm\
|
rlm_tunein.rlm\
|
||||||
@@ -59,7 +58,6 @@ EXTRA_DIST = Makefile-example\
|
|||||||
rlm_liqcomp.c\
|
rlm_liqcomp.c\
|
||||||
rlm_serial.c\
|
rlm_serial.c\
|
||||||
rlm_shoutcast1.c\
|
rlm_shoutcast1.c\
|
||||||
rlm_spinitron_plus.c\
|
|
||||||
rlm_spottrap.c\
|
rlm_spottrap.c\
|
||||||
rlm_test.c\
|
rlm_test.c\
|
||||||
rlm_tunein.c\
|
rlm_tunein.c\
|
||||||
|
|||||||
@@ -1,657 +0,0 @@
|
|||||||
/* rlm_spinitron_plus.c
|
|
||||||
*
|
|
||||||
* (C) Copyright 2013-2018 Fred Gleason <fredg@paravelsystems.com>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License version 2
|
|
||||||
* as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public
|
|
||||||
* License along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*
|
|
||||||
* This is a Rivendell Loadable Module. It sends Now&Next PAD data
|
|
||||||
* to the Spinitron account(s) specified in the configuration file pointed
|
|
||||||
* to by the plugin argument. For information about Spinitron, see
|
|
||||||
* http://www.spinitron.com/.
|
|
||||||
*
|
|
||||||
* Inspired by the original spinitron RLM by Eric Berg, Benjamin Yu
|
|
||||||
* and Max Goldstein.
|
|
||||||
*
|
|
||||||
* This module requires the curl(1) network transfer tool, included with
|
|
||||||
* most Linux distros. It is also available at http://curl.haxx.se/.
|
|
||||||
*
|
|
||||||
* To compile this module, just do:
|
|
||||||
*
|
|
||||||
* gcc -shared -o rlm_spinitron_plus.rlm rlm_spinitron_plus.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <strings.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include <rlm/rlm.h>
|
|
||||||
|
|
||||||
#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;
|
|
||||||
char *rlm_spinitron_plus_albums;
|
|
||||||
char *rlm_spinitron_plus_labels;
|
|
||||||
char *rlm_spinitron_plus_composers;
|
|
||||||
char *rlm_spinitron_plus_notes;
|
|
||||||
int *rlm_spinitron_plus_masters;
|
|
||||||
int *rlm_spinitron_plus_aux1s;
|
|
||||||
int *rlm_spinitron_plus_aux2s;
|
|
||||||
int *rlm_spinitron_plus_vlog101s;
|
|
||||||
int *rlm_spinitron_plus_vlog102s;
|
|
||||||
int *rlm_spinitron_plus_vlog103s;
|
|
||||||
int *rlm_spinitron_plus_vlog104s;
|
|
||||||
int *rlm_spinitron_plus_vlog105s;
|
|
||||||
int *rlm_spinitron_plus_vlog106s;
|
|
||||||
int *rlm_spinitron_plus_vlog107s;
|
|
||||||
int *rlm_spinitron_plus_vlog108s;
|
|
||||||
int *rlm_spinitron_plus_vlog109s;
|
|
||||||
int *rlm_spinitron_plus_vlog110s;
|
|
||||||
int *rlm_spinitron_plus_vlog111s;
|
|
||||||
int *rlm_spinitron_plus_vlog112s;
|
|
||||||
int *rlm_spinitron_plus_vlog113s;
|
|
||||||
int *rlm_spinitron_plus_vlog114s;
|
|
||||||
int *rlm_spinitron_plus_vlog115s;
|
|
||||||
int *rlm_spinitron_plus_vlog116s;
|
|
||||||
int *rlm_spinitron_plus_vlog117s;
|
|
||||||
int *rlm_spinitron_plus_vlog118s;
|
|
||||||
int *rlm_spinitron_plus_vlog119s;
|
|
||||||
int *rlm_spinitron_plus_vlog120s;
|
|
||||||
|
|
||||||
int rlm_spinitron_plus_BufferDiff(char *sString,int dOrigin,int dDiff,int dMaxSize)
|
|
||||||
{
|
|
||||||
int dOldSize,dNewSize;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Will it fit?
|
|
||||||
*/
|
|
||||||
dOldSize=strlen(sString);
|
|
||||||
if((dOldSize+dDiff)>=dMaxSize) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
dNewSize=dOldSize+dDiff;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Adding characters
|
|
||||||
*/
|
|
||||||
if(dDiff>0) {
|
|
||||||
for(i=dOldSize;i>dOrigin;i--) {
|
|
||||||
sString[i+dDiff]=sString[i];
|
|
||||||
}
|
|
||||||
return dNewSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* No Change
|
|
||||||
*/
|
|
||||||
if(dDiff==0) {
|
|
||||||
return dNewSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Deleting Characters
|
|
||||||
*/
|
|
||||||
if(dDiff<0) {
|
|
||||||
for(i=dOrigin;i<dOldSize;i++) {
|
|
||||||
sString[i]=sString[i-dDiff];
|
|
||||||
}
|
|
||||||
return dNewSize;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int rlm_spinitron_plus_EncodeString(char *sString,int dMaxSize)
|
|
||||||
{
|
|
||||||
int i; /* General Purpose Counter */
|
|
||||||
char sAccum[4]; /* General String Buffer */
|
|
||||||
|
|
||||||
i=0;
|
|
||||||
while(sString[i]!=0) {
|
|
||||||
if(((sString[i]!=' ') && (sString[i]!='*') && (sString[i]!='-') &&
|
|
||||||
(sString[i]!='_') && (sString[i]!='.')) &&
|
|
||||||
((sString[i]<'0') ||
|
|
||||||
((sString[i]>'9') && (sString[i]<'A')) ||
|
|
||||||
((sString[i]>'Z') && (sString[i]<'a')) ||
|
|
||||||
(sString[i]>'z'))) {
|
|
||||||
if(rlm_spinitron_plus_BufferDiff(sString,i,2,dMaxSize)<0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
sprintf(sAccum,"%%%2x",sString[i]);
|
|
||||||
sString[i++]=sAccum[0];
|
|
||||||
sString[i++]=sAccum[1];
|
|
||||||
sString[i]=sAccum[2];
|
|
||||||
}
|
|
||||||
if(sString[i]==' ') {
|
|
||||||
sString[i]='+';
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
return strlen(sString);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int rlm_spinitron_plus_GetLogStatus(void *ptr,const char *arg,
|
|
||||||
const char *section,const char *logname)
|
|
||||||
{
|
|
||||||
const char *tag=RLMGetStringValue(ptr,arg,section,logname,"");
|
|
||||||
if(strcasecmp(tag,"yes")==0) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if(strcasecmp(tag,"on")==0) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if(strcasecmp(tag,"true")==0) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if(strcasecmp(tag,"no")==0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if(strcasecmp(tag,"off")==0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if(strcasecmp(tag,"false")==0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if(strcasecmp(tag,"onair")==0) {
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void rlm_spinitron_plus_RLMStart(void *ptr,const char *arg)
|
|
||||||
{
|
|
||||||
char station[256];
|
|
||||||
char section[256];
|
|
||||||
char errtext[256];
|
|
||||||
char mode[256];
|
|
||||||
int pmode;
|
|
||||||
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;
|
|
||||||
rlm_spinitron_plus_albums=NULL;
|
|
||||||
rlm_spinitron_plus_labels=NULL;
|
|
||||||
rlm_spinitron_plus_composers=NULL;
|
|
||||||
rlm_spinitron_plus_notes=NULL;
|
|
||||||
rlm_spinitron_plus_masters=NULL;
|
|
||||||
rlm_spinitron_plus_aux1s=NULL;
|
|
||||||
rlm_spinitron_plus_aux2s=NULL;
|
|
||||||
rlm_spinitron_plus_vlog101s=NULL;
|
|
||||||
rlm_spinitron_plus_vlog102s=NULL;
|
|
||||||
rlm_spinitron_plus_vlog103s=NULL;
|
|
||||||
rlm_spinitron_plus_vlog104s=NULL;
|
|
||||||
rlm_spinitron_plus_vlog105s=NULL;
|
|
||||||
rlm_spinitron_plus_vlog106s=NULL;
|
|
||||||
rlm_spinitron_plus_vlog107s=NULL;
|
|
||||||
rlm_spinitron_plus_vlog108s=NULL;
|
|
||||||
rlm_spinitron_plus_vlog109s=NULL;
|
|
||||||
rlm_spinitron_plus_vlog110s=NULL;
|
|
||||||
rlm_spinitron_plus_vlog111s=NULL;
|
|
||||||
rlm_spinitron_plus_vlog112s=NULL;
|
|
||||||
rlm_spinitron_plus_vlog113s=NULL;
|
|
||||||
rlm_spinitron_plus_vlog114s=NULL;
|
|
||||||
rlm_spinitron_plus_vlog115s=NULL;
|
|
||||||
rlm_spinitron_plus_vlog116s=NULL;
|
|
||||||
rlm_spinitron_plus_vlog117s=NULL;
|
|
||||||
rlm_spinitron_plus_vlog118s=NULL;
|
|
||||||
rlm_spinitron_plus_vlog119s=NULL;
|
|
||||||
rlm_spinitron_plus_vlog120s=NULL;
|
|
||||||
|
|
||||||
sprintf(section,"Spinitron%d",i++);
|
|
||||||
strncpy(station,RLMGetStringValue(ptr,arg,section,"Station",""),255);
|
|
||||||
station[255]=0;
|
|
||||||
if(strlen(station)==0) {
|
|
||||||
RLMLog(ptr,LOG_WARNING,"rlm_spinitron_plus: no spinitron accounts specified");
|
|
||||||
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));
|
|
||||||
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);
|
|
||||||
rlm_spinitron_plus_EncodeString(rlm_spinitron_plus_stations+256*rlm_spinitron_plus_devs,255);
|
|
||||||
|
|
||||||
rlm_spinitron_plus_usernames=realloc(rlm_spinitron_plus_usernames,
|
|
||||||
(rlm_spinitron_plus_devs+1)*(rlm_spinitron_plus_devs+1)*256);
|
|
||||||
strcpy(rlm_spinitron_plus_usernames+256*rlm_spinitron_plus_devs,
|
|
||||||
RLMGetStringValue(ptr,arg,section,"Username",""));
|
|
||||||
rlm_spinitron_plus_EncodeString(rlm_spinitron_plus_usernames+256*rlm_spinitron_plus_devs,255);
|
|
||||||
|
|
||||||
rlm_spinitron_plus_passwords=realloc(rlm_spinitron_plus_passwords,
|
|
||||||
(rlm_spinitron_plus_devs+1)*(rlm_spinitron_plus_devs+1)*256);
|
|
||||||
strcpy(rlm_spinitron_plus_passwords+256*rlm_spinitron_plus_devs,
|
|
||||||
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) {
|
|
||||||
pmode=0;
|
|
||||||
}
|
|
||||||
if(strcasecmp(mode,"assist")==0) {
|
|
||||||
pmode=2;
|
|
||||||
}
|
|
||||||
rlm_spinitron_plus_playlist_modes=
|
|
||||||
realloc(rlm_spinitron_plus_playlist_modes,
|
|
||||||
(rlm_spinitron_plus_devs+1)*sizeof(int));
|
|
||||||
rlm_spinitron_plus_playlist_modes[rlm_spinitron_plus_devs]=pmode;
|
|
||||||
|
|
||||||
rlm_spinitron_plus_titles=realloc(rlm_spinitron_plus_titles,(rlm_spinitron_plus_devs+1)*256);
|
|
||||||
strncpy(rlm_spinitron_plus_titles+256*rlm_spinitron_plus_devs,
|
|
||||||
RLMGetStringValue(ptr,arg,section,"Title",""),256);
|
|
||||||
|
|
||||||
rlm_spinitron_plus_artists=realloc(rlm_spinitron_plus_artists,(rlm_spinitron_plus_devs+1)*256);
|
|
||||||
strncpy(rlm_spinitron_plus_artists+256*rlm_spinitron_plus_devs,
|
|
||||||
RLMGetStringValue(ptr,arg,section,"Artist",""),256);
|
|
||||||
|
|
||||||
rlm_spinitron_plus_albums=realloc(rlm_spinitron_plus_albums,(rlm_spinitron_plus_devs+1)*256);
|
|
||||||
strncpy(rlm_spinitron_plus_albums+256*rlm_spinitron_plus_devs,
|
|
||||||
RLMGetStringValue(ptr,arg,section,"Album",""),256);
|
|
||||||
|
|
||||||
rlm_spinitron_plus_labels=realloc(rlm_spinitron_plus_labels,(rlm_spinitron_plus_devs+1)*256);
|
|
||||||
strncpy(rlm_spinitron_plus_labels+256*rlm_spinitron_plus_devs,
|
|
||||||
RLMGetStringValue(ptr,arg,section,"Label",""),256);
|
|
||||||
|
|
||||||
rlm_spinitron_plus_composers=realloc(rlm_spinitron_plus_composers,(rlm_spinitron_plus_devs+1)*256);
|
|
||||||
strncpy(rlm_spinitron_plus_composers+256*rlm_spinitron_plus_devs,
|
|
||||||
RLMGetStringValue(ptr,arg,section,"Composer",""),256);
|
|
||||||
|
|
||||||
rlm_spinitron_plus_notes=realloc(rlm_spinitron_plus_notes,(rlm_spinitron_plus_devs+1)*256);
|
|
||||||
strncpy(rlm_spinitron_plus_notes+256*rlm_spinitron_plus_devs,
|
|
||||||
RLMGetStringValue(ptr,arg,section,"Notes",""),256);
|
|
||||||
|
|
||||||
|
|
||||||
rlm_spinitron_plus_masters=realloc(rlm_spinitron_plus_masters,
|
|
||||||
(rlm_spinitron_plus_devs+1)*sizeof(int));
|
|
||||||
rlm_spinitron_plus_masters[rlm_spinitron_plus_devs]=
|
|
||||||
rlm_spinitron_plus_GetLogStatus(ptr,arg,section,"MasterLog");
|
|
||||||
rlm_spinitron_plus_aux1s=realloc(rlm_spinitron_plus_aux1s,
|
|
||||||
(rlm_spinitron_plus_devs+1)*sizeof(int));
|
|
||||||
rlm_spinitron_plus_aux1s[rlm_spinitron_plus_devs]=
|
|
||||||
rlm_spinitron_plus_GetLogStatus(ptr,arg,section,"Aux1Log");
|
|
||||||
rlm_spinitron_plus_aux2s=realloc(rlm_spinitron_plus_aux2s,
|
|
||||||
(rlm_spinitron_plus_devs+1)*sizeof(int));
|
|
||||||
rlm_spinitron_plus_aux2s[rlm_spinitron_plus_devs]=
|
|
||||||
rlm_spinitron_plus_GetLogStatus(ptr,arg,section,"Aux2Log");
|
|
||||||
|
|
||||||
rlm_spinitron_plus_vlog101s=realloc(rlm_spinitron_plus_vlog101s,
|
|
||||||
(rlm_spinitron_plus_devs+1)*sizeof(int));
|
|
||||||
rlm_spinitron_plus_vlog101s[rlm_spinitron_plus_devs]=
|
|
||||||
rlm_spinitron_plus_GetLogStatus(ptr,arg,section,"VLog101");
|
|
||||||
|
|
||||||
rlm_spinitron_plus_vlog102s=realloc(rlm_spinitron_plus_vlog102s,
|
|
||||||
(rlm_spinitron_plus_devs+1)*sizeof(int));
|
|
||||||
rlm_spinitron_plus_vlog102s[rlm_spinitron_plus_devs]=
|
|
||||||
rlm_spinitron_plus_GetLogStatus(ptr,arg,section,"VLog102");
|
|
||||||
|
|
||||||
rlm_spinitron_plus_vlog103s=realloc(rlm_spinitron_plus_vlog103s,
|
|
||||||
(rlm_spinitron_plus_devs+1)*sizeof(int));
|
|
||||||
rlm_spinitron_plus_vlog103s[rlm_spinitron_plus_devs]=
|
|
||||||
rlm_spinitron_plus_GetLogStatus(ptr,arg,section,"VLog103");
|
|
||||||
|
|
||||||
rlm_spinitron_plus_vlog104s=realloc(rlm_spinitron_plus_vlog104s,
|
|
||||||
(rlm_spinitron_plus_devs+1)*sizeof(int));
|
|
||||||
rlm_spinitron_plus_vlog104s[rlm_spinitron_plus_devs]=
|
|
||||||
rlm_spinitron_plus_GetLogStatus(ptr,arg,section,"VLog104");
|
|
||||||
|
|
||||||
rlm_spinitron_plus_vlog105s=realloc(rlm_spinitron_plus_vlog105s,
|
|
||||||
(rlm_spinitron_plus_devs+1)*sizeof(int));
|
|
||||||
rlm_spinitron_plus_vlog105s[rlm_spinitron_plus_devs]=
|
|
||||||
rlm_spinitron_plus_GetLogStatus(ptr,arg,section,"VLog105");
|
|
||||||
|
|
||||||
rlm_spinitron_plus_vlog106s=realloc(rlm_spinitron_plus_vlog106s,
|
|
||||||
(rlm_spinitron_plus_devs+1)*sizeof(int));
|
|
||||||
rlm_spinitron_plus_vlog106s[rlm_spinitron_plus_devs]=
|
|
||||||
rlm_spinitron_plus_GetLogStatus(ptr,arg,section,"VLog106");
|
|
||||||
|
|
||||||
rlm_spinitron_plus_vlog107s=realloc(rlm_spinitron_plus_vlog107s,
|
|
||||||
(rlm_spinitron_plus_devs+1)*sizeof(int));
|
|
||||||
rlm_spinitron_plus_vlog107s[rlm_spinitron_plus_devs]=
|
|
||||||
rlm_spinitron_plus_GetLogStatus(ptr,arg,section,"VLog107");
|
|
||||||
|
|
||||||
rlm_spinitron_plus_vlog108s=realloc(rlm_spinitron_plus_vlog108s,
|
|
||||||
(rlm_spinitron_plus_devs+1)*sizeof(int));
|
|
||||||
rlm_spinitron_plus_vlog108s[rlm_spinitron_plus_devs]=
|
|
||||||
rlm_spinitron_plus_GetLogStatus(ptr,arg,section,"VLog108");
|
|
||||||
|
|
||||||
rlm_spinitron_plus_vlog109s=realloc(rlm_spinitron_plus_vlog109s,
|
|
||||||
(rlm_spinitron_plus_devs+1)*sizeof(int));
|
|
||||||
rlm_spinitron_plus_vlog109s[rlm_spinitron_plus_devs]=
|
|
||||||
rlm_spinitron_plus_GetLogStatus(ptr,arg,section,"VLog109");
|
|
||||||
|
|
||||||
rlm_spinitron_plus_vlog110s=realloc(rlm_spinitron_plus_vlog110s,
|
|
||||||
(rlm_spinitron_plus_devs+1)*sizeof(int));
|
|
||||||
rlm_spinitron_plus_vlog110s[rlm_spinitron_plus_devs]=
|
|
||||||
rlm_spinitron_plus_GetLogStatus(ptr,arg,section,"VLog110");
|
|
||||||
|
|
||||||
rlm_spinitron_plus_vlog111s=realloc(rlm_spinitron_plus_vlog111s,
|
|
||||||
(rlm_spinitron_plus_devs+1)*sizeof(int));
|
|
||||||
rlm_spinitron_plus_vlog111s[rlm_spinitron_plus_devs]=
|
|
||||||
rlm_spinitron_plus_GetLogStatus(ptr,arg,section,"VLog111");
|
|
||||||
|
|
||||||
rlm_spinitron_plus_vlog112s=realloc(rlm_spinitron_plus_vlog112s,
|
|
||||||
(rlm_spinitron_plus_devs+1)*sizeof(int));
|
|
||||||
rlm_spinitron_plus_vlog112s[rlm_spinitron_plus_devs]=
|
|
||||||
rlm_spinitron_plus_GetLogStatus(ptr,arg,section,"VLog112");
|
|
||||||
|
|
||||||
rlm_spinitron_plus_vlog113s=realloc(rlm_spinitron_plus_vlog113s,
|
|
||||||
(rlm_spinitron_plus_devs+1)*sizeof(int));
|
|
||||||
rlm_spinitron_plus_vlog113s[rlm_spinitron_plus_devs]=
|
|
||||||
rlm_spinitron_plus_GetLogStatus(ptr,arg,section,"VLog113");
|
|
||||||
|
|
||||||
rlm_spinitron_plus_vlog114s=realloc(rlm_spinitron_plus_vlog114s,
|
|
||||||
(rlm_spinitron_plus_devs+1)*sizeof(int));
|
|
||||||
rlm_spinitron_plus_vlog114s[rlm_spinitron_plus_devs]=
|
|
||||||
rlm_spinitron_plus_GetLogStatus(ptr,arg,section,"VLog114");
|
|
||||||
|
|
||||||
rlm_spinitron_plus_vlog115s=realloc(rlm_spinitron_plus_vlog115s,
|
|
||||||
(rlm_spinitron_plus_devs+1)*sizeof(int));
|
|
||||||
rlm_spinitron_plus_vlog115s[rlm_spinitron_plus_devs]=
|
|
||||||
rlm_spinitron_plus_GetLogStatus(ptr,arg,section,"VLog115");
|
|
||||||
|
|
||||||
rlm_spinitron_plus_vlog116s=realloc(rlm_spinitron_plus_vlog116s,
|
|
||||||
(rlm_spinitron_plus_devs+1)*sizeof(int));
|
|
||||||
rlm_spinitron_plus_vlog116s[rlm_spinitron_plus_devs]=
|
|
||||||
rlm_spinitron_plus_GetLogStatus(ptr,arg,section,"VLog116");
|
|
||||||
|
|
||||||
rlm_spinitron_plus_vlog117s=realloc(rlm_spinitron_plus_vlog117s,
|
|
||||||
(rlm_spinitron_plus_devs+1)*sizeof(int));
|
|
||||||
rlm_spinitron_plus_vlog117s[rlm_spinitron_plus_devs]=
|
|
||||||
rlm_spinitron_plus_GetLogStatus(ptr,arg,section,"VLog117");
|
|
||||||
|
|
||||||
rlm_spinitron_plus_vlog118s=realloc(rlm_spinitron_plus_vlog118s,
|
|
||||||
(rlm_spinitron_plus_devs+1)*sizeof(int));
|
|
||||||
rlm_spinitron_plus_vlog118s[rlm_spinitron_plus_devs]=
|
|
||||||
rlm_spinitron_plus_GetLogStatus(ptr,arg,section,"VLog118");
|
|
||||||
|
|
||||||
rlm_spinitron_plus_vlog119s=realloc(rlm_spinitron_plus_vlog119s,
|
|
||||||
(rlm_spinitron_plus_devs+1)*sizeof(int));
|
|
||||||
rlm_spinitron_plus_vlog119s[rlm_spinitron_plus_devs]=
|
|
||||||
rlm_spinitron_plus_GetLogStatus(ptr,arg,section,"VLog119");
|
|
||||||
|
|
||||||
rlm_spinitron_plus_vlog120s=realloc(rlm_spinitron_plus_vlog120s,
|
|
||||||
(rlm_spinitron_plus_devs+1)*sizeof(int));
|
|
||||||
rlm_spinitron_plus_vlog120s[rlm_spinitron_plus_devs]=
|
|
||||||
rlm_spinitron_plus_GetLogStatus(ptr,arg,section,"VLog120");
|
|
||||||
|
|
||||||
sprintf(errtext,"rlm_spinitron_plus: configured account for station \"%s\"",
|
|
||||||
station);
|
|
||||||
|
|
||||||
rlm_spinitron_plus_devs++;
|
|
||||||
RLMLog(ptr,LOG_INFO,errtext);
|
|
||||||
sprintf(section,"Spinitron%d",i++);
|
|
||||||
strncpy(station,RLMGetStringValue(ptr,arg,section,"Station",""),255);
|
|
||||||
station[255]=0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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);
|
|
||||||
free(rlm_spinitron_plus_albums);
|
|
||||||
free(rlm_spinitron_plus_labels);
|
|
||||||
free(rlm_spinitron_plus_composers);
|
|
||||||
free(rlm_spinitron_plus_notes);
|
|
||||||
free(rlm_spinitron_plus_masters);
|
|
||||||
free(rlm_spinitron_plus_aux1s);
|
|
||||||
free(rlm_spinitron_plus_aux2s);
|
|
||||||
free(rlm_spinitron_plus_vlog101s);
|
|
||||||
free(rlm_spinitron_plus_vlog102s);
|
|
||||||
free(rlm_spinitron_plus_vlog103s);
|
|
||||||
free(rlm_spinitron_plus_vlog104s);
|
|
||||||
free(rlm_spinitron_plus_vlog105s);
|
|
||||||
free(rlm_spinitron_plus_vlog106s);
|
|
||||||
free(rlm_spinitron_plus_vlog107s);
|
|
||||||
free(rlm_spinitron_plus_vlog108s);
|
|
||||||
free(rlm_spinitron_plus_vlog109s);
|
|
||||||
free(rlm_spinitron_plus_vlog110s);
|
|
||||||
free(rlm_spinitron_plus_vlog111s);
|
|
||||||
free(rlm_spinitron_plus_vlog112s);
|
|
||||||
free(rlm_spinitron_plus_vlog113s);
|
|
||||||
free(rlm_spinitron_plus_vlog114s);
|
|
||||||
free(rlm_spinitron_plus_vlog115s);
|
|
||||||
free(rlm_spinitron_plus_vlog116s);
|
|
||||||
free(rlm_spinitron_plus_vlog117s);
|
|
||||||
free(rlm_spinitron_plus_vlog118s);
|
|
||||||
free(rlm_spinitron_plus_vlog119s);
|
|
||||||
free(rlm_spinitron_plus_vlog120s);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void rlm_spinitron_plus_RLMPadDataSent(void *ptr,const struct rlm_svc *svc,
|
|
||||||
const struct rlm_log *log,
|
|
||||||
const struct rlm_pad *now,
|
|
||||||
const struct rlm_pad *next)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
int flag=0;
|
|
||||||
char title[1024];
|
|
||||||
char artist[1024];
|
|
||||||
char album[1024];
|
|
||||||
char label[1024];
|
|
||||||
char composer[1024];
|
|
||||||
char notes[1024];
|
|
||||||
char msg[8192];
|
|
||||||
char sysmsg[8192];
|
|
||||||
int pm;
|
|
||||||
|
|
||||||
for(i=0;i<rlm_spinitron_plus_devs;i++) {
|
|
||||||
switch(log->log_mach) {
|
|
||||||
case 0:
|
|
||||||
flag=rlm_spinitron_plus_masters[i];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
flag=rlm_spinitron_plus_aux1s[i];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
flag=rlm_spinitron_plus_aux2s[i];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 100:
|
|
||||||
flag=rlm_spinitron_plus_vlog101s[i];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 101:
|
|
||||||
flag=rlm_spinitron_plus_vlog102s[i];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 102:
|
|
||||||
flag=rlm_spinitron_plus_vlog103s[i];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 103:
|
|
||||||
flag=rlm_spinitron_plus_vlog104s[i];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 104:
|
|
||||||
flag=rlm_spinitron_plus_vlog105s[i];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 105:
|
|
||||||
flag=rlm_spinitron_plus_vlog106s[i];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 106:
|
|
||||||
flag=rlm_spinitron_plus_vlog107s[i];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 107:
|
|
||||||
flag=rlm_spinitron_plus_vlog108s[i];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 108:
|
|
||||||
flag=rlm_spinitron_plus_vlog109s[i];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 109:
|
|
||||||
flag=rlm_spinitron_plus_vlog110s[i];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 110:
|
|
||||||
flag=rlm_spinitron_plus_vlog111s[i];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 111:
|
|
||||||
flag=rlm_spinitron_plus_vlog112s[i];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 112:
|
|
||||||
flag=rlm_spinitron_plus_vlog113s[i];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 113:
|
|
||||||
flag=rlm_spinitron_plus_vlog114s[i];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 114:
|
|
||||||
flag=rlm_spinitron_plus_vlog115s[i];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 115:
|
|
||||||
flag=rlm_spinitron_plus_vlog116s[i];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 116:
|
|
||||||
flag=rlm_spinitron_plus_vlog117s[i];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 117:
|
|
||||||
flag=rlm_spinitron_plus_vlog118s[i];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 118:
|
|
||||||
flag=rlm_spinitron_plus_vlog119s[i];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 119:
|
|
||||||
flag=rlm_spinitron_plus_vlog120s[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if((flag==1)||((flag==2)&&(log->log_onair!=0))) {
|
|
||||||
strncpy(title,RLMResolveNowNext(ptr,now,next,
|
|
||||||
rlm_spinitron_plus_titles+256*i),256);
|
|
||||||
rlm_spinitron_plus_EncodeString(title,1023);
|
|
||||||
strncpy(artist,RLMResolveNowNext(ptr,now,next,
|
|
||||||
rlm_spinitron_plus_artists+256*i),256);
|
|
||||||
rlm_spinitron_plus_EncodeString(artist,1023);
|
|
||||||
strncpy(album,RLMResolveNowNext(ptr,now,next,
|
|
||||||
rlm_spinitron_plus_albums+256*i),256);
|
|
||||||
rlm_spinitron_plus_EncodeString(album,1023);
|
|
||||||
strncpy(label,RLMResolveNowNext(ptr,now,next,
|
|
||||||
rlm_spinitron_plus_labels+256*i),256);
|
|
||||||
rlm_spinitron_plus_EncodeString(label,1023);
|
|
||||||
strncpy(composer,RLMResolveNowNext(ptr,now,next,
|
|
||||||
rlm_spinitron_plus_composers+256*i),256);
|
|
||||||
rlm_spinitron_plus_EncodeString(composer,1023);
|
|
||||||
strncpy(notes,RLMResolveNowNext(ptr,now,next,
|
|
||||||
rlm_spinitron_plus_notes+256*i),256);
|
|
||||||
rlm_spinitron_plus_EncodeString(notes,1023);
|
|
||||||
if(rlm_spinitron_plus_playlist_modes[i]==3) {
|
|
||||||
switch(log->log_mode) {
|
|
||||||
case RLM_LOGMODE_AUTOMATIC:
|
|
||||||
pm=0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RLM_LOGMODE_LIVEASSIST:
|
|
||||||
case RLM_LOGMODE_MANUAL:
|
|
||||||
default:
|
|
||||||
pm=2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
pm=rlm_spinitron_plus_playlist_modes[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
if(strlen(now->rlm_title)!=0) {
|
|
||||||
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)");
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
snprintf(sysmsg,8192,"rlm_spinitron_plus: sending pad update: \"%s\"",
|
|
||||||
(const char *)msg);
|
|
||||||
RLMLog(ptr,LOG_DEBUG,sysmsg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user