Merge branch 'deltecent-pypad-fixes' into pypad-fixes

This commit is contained in:
Fred Gleason 2019-08-28 17:22:51 -04:00
commit b4916e96ac
4 changed files with 163 additions and 0 deletions

View File

@ -19024,3 +19024,5 @@
2019-08-26 Fred Gleason <fredg@paravelsystems.com>
* Fixed a bug in the 'pypad_xmpad.py' PyPAD script that caused
an infinite loop.
2019-08-26 Patrick Linstruth <patrick@deltecent.com>
* Added 'pypad_httpget.py' script.

View File

@ -26,6 +26,8 @@ install-exec-am:
cp pypad_ando.exemplar $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/pypad/pypad_ando.exemplar
../../../helpers/install_python.sh pypad_filewrite.py $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/pypad/pypad_filewrite.py
cp pypad_filewrite.exemplar $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/pypad/pypad_filewrite.exemplar
../../../helpers/install_python.sh pypad_httpget.py $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/pypad/pypad_httpget.py
cp pypad_httpget.exemplar $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/pypad/pypad_httpget.exemplar
../../../helpers/install_python.sh pypad_icecast2.py $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/pypad/pypad_icecast2.py
cp pypad_icecast2.exemplar $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/pypad/pypad_icecast2.exemplar
../../../helpers/install_python.sh pypad_inno713.py $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/pypad/pypad_inno713.py
@ -62,6 +64,8 @@ uninstall-local:
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/pypad/pypad_ando.py
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/pypad/pypad_filewrite.exemplar
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/pypad/pypad_filewrite.py
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/pypad/pypad_httpget.exemplar
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/pypad/pypad_httpget.py
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/pypad/pypad_icecast2.exemplar
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/pypad/pypad_icecast2.py
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/pypad/pypad_inno713.exemplar
@ -97,6 +101,8 @@ EXTRA_DIST = pypad_ando.exemplar\
pypad_ando.py\
pypad_filewrite.exemplar\
pypad_filewrite.py\
pypad_httpget.exemplar\
pypad_httpget.py\
pypad_icecast2.exemplar\
pypad_icecast2.py\
pypad_inno713.exemplar\

View File

@ -0,0 +1,77 @@
; This is the configuration for the 'pypad_httpget.py' script for
; Rivendell, which can be used to send an HTTP GET transaction.
; Section Header
;
; One section per HTTP GET URL station is configured, starting with
; 'Url1' and working up consecutively
[Url1]
; URL String. The URL to be sent each time RDAirPlay changes
; play state, including any wildcards as placeholders for metadata values.
;
; The list of available wildcards can be found in the 'metadata_wildcards.txt'
; file in the Rivendell documentation directory.
;
URL=https://someplace.com/metadata.php?key=somekey&artist=%a&title=%t
; 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 station. 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 HTTPS GET URLs can be configured by adding new
; sections...
;
;[Url2]
;URL=https://some.otherplace.com/metadata.php?key=somekey&artist=%a&title=%t
;MasterLog=No
;Aux1Log=Yes
;Aux2Log=No
;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

View File

@ -0,0 +1,78 @@
#!%PYTHON_BANGPATH%
# pypad_httpget.py
#
# Write PAD updates to HTTP GET URL
#
# (C) Copyright 2019 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 configparser
import pycurl
import pypad
import syslog
from io import BytesIO
def eprint(*args,**kwargs):
print(*args,file=sys.stderr,**kwargs)
def ProcessPad(update):
if update.hasPadType(pypad.TYPE_NOW):
n=1
while(True):
section='Url'+str(n)
try:
url=update.resolvePadFields(update.config().get(section,'URL'),pypad.ESCAPE_URL)
buf=BytesIO()
curl=pycurl.Curl()
curl.setopt(curl.URL,url)
curl.setopt(curl.WRITEDATA,buf)
curl.setopt(curl.FOLLOWLOCATION,True)
except configparser.NoSectionError:
if(n==1):
update.syslog(syslog.LOG_WARNING,'No httpget config found')
return
if update.shouldBeProcessed(section):
try:
curl.perform()
code=curl.getinfo(pycurl.RESPONSE_CODE)
if (code<200) or (code>=300):
update.syslog(syslog.LOG_WARNING,'['+section+'] returned response code '+str(code))
else:
update.syslog(syslog.LOG_NOTICE,'['+section+'] successful')
except pycurl.error:
update.syslog(syslog.LOG_WARNING,'['+section+'] failed: '+curl.errstr())
update.syslog(syslog.LOG_WARNING,'['+section+'] URL: '+url)
curl.close()
n=n+1
#
# 'Main' function
#
rcvr=pypad.Receiver()
try:
rcvr.setConfigFile(sys.argv[3])
except IndexError:
eprint('pypad_httpget.py: USAGE: cmd <hostname> <port> <config>')
sys.exit(1)
rcvr.setPadCallback(ProcessPad)
rcvr.start(sys.argv[1],int(sys.argv[2]))