2018-12-18 Fred Gleason <fredg@paravelsystems.com>

* Added a 'pypad_live365.py' PyPAD script.
	* Removed the 'rlm_live365' RLM.
	* Fixed typos in the docstrings for 'PyPAD.Update::startDateTime()'
	and 'PyPAD.Update::padField()'.
This commit is contained in:
Fred Gleason
2018-12-18 18:08:49 -05:00
parent 324e35cd8e
commit 8dc4e72af6
7 changed files with 190 additions and 552 deletions

View File

@@ -410,8 +410,8 @@ class Update(object):
Takes one argument:
pad_type - The type of PAD value. Valid values are:
PyPAD.NOW - Now playing data
PyPAD.NEXT - Next to play data
PyPAD.TYPE_NOW - Now playing data
PyPAD.TYPE_NEXT - Next to play data
"""
try:
return self.__fields['padUpdate'][pad_type]!=None
@@ -425,8 +425,8 @@ class Update(object):
Takes one argument:
pad_type - The type of PAD value. Valid values are:
PyPAD.NOW - Now playing data
PyPAD.NEXT - Next to play data
PyPAD.TYPE_NOW - Now playing data
PyPAD.TYPE_NEXT - Next to play data
"""
try:
return self.__fromIso8601(self.__fields['padUpdate'][pad_type]['startDateTime'])
@@ -440,8 +440,8 @@ class Update(object):
Takes two arguments:
pad_type - The type of PAD value. Valid values are:
PyPAD.NOW - Now playing data
PyPAD.NEXT - Next to play data
PyPAD.TYPE_NOW - Now playing data
PyPAD.TYPE_NEXT - Next to play data
pad_field - The specific field. Valid values are:
PyPAD.FIELD_AGENCY - The 'Agency' field (string)

View File

@@ -24,6 +24,8 @@ install-exec-am:
mkdir -p $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD
../../../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_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
../../../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
../../../helpers/install_python.sh pypad_urlwrite.py $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_urlwrite.py
@@ -34,6 +36,8 @@ install-exec-am:
uninstall-local:
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_live365.exemplar
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_live365.py
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_urlwrite.exemplar
@@ -43,6 +47,8 @@ uninstall-local:
EXTRA_DIST = pypad_filewrite.exemplar\
pypad_filewrite.py\
pypad_live365.exemplar\
pypad_live365.py\
pypad_udp.exemplar\
pypad_udp.py\
pypad_urlwrite.exemplar\

View File

@@ -0,0 +1,97 @@
; This is the configuration for the 'pypad_live365.py' script for
; Rivendell, which can be used to update the metadata on a Live 365 channel
; using Now & Next data.
; Section Header
;
; One section per Live365 station is configured, starting with
; 'Station1' and working up consecutively
[Station1]
; MemberName
;
; The member name of the Live365 station to which to send updates.
MemberName=my_station
; Password
;
; The password of the Live365 station to which to send updates.
Password=changeme
; Metadata String. The metadata fields 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.
;
TitleString=%t
ArtistString=%a
AlbumString=%l
; 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 Live365 stations can be configured by adding new
; sections...
;
;[Station2]
;MemberName=your_station
;Password=changeme
;TitleString=%t
;ArtistString=%a
;AlbumString=%l
;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,76 @@
#!%PYTHON_BANGPATH%
# pypad_live365.py
#
# Write PAD updates to Live365 stations
#
# (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
def eprint(*args,**kwargs):
print(*args,file=sys.stderr,**kwargs)
def ProcessPad(update):
n=1
try:
while(True):
section='Station'+str(n)
if update.shouldBeProcessed(section) and update.hasPadType(PyPAD.TYPE_NOW):
member=update.escape(update.config().get(section,'MemberName'),PyPAD.ESCAPE_URL)
password=update.escape(update.config().get(section,'Password'),PyPAD.ESCAPE_URL)
title=update.resolvePadFields(update.config().get(section,'TitleString'),PyPAD.ESCAPE_URL)
artist=update.resolvePadFields(update.config().get(section,'ArtistString'),PyPAD.ESCAPE_URL)
album=update.resolvePadFields(update.config().get(section,'AlbumString'),PyPAD.ESCAPE_URL)
seconds=str(update.padField(PyPAD.TYPE_NOW,PyPAD.FIELD_LENGTH)//1000)
buf=BytesIO()
curl=pycurl.Curl()
url='http://www.live365.com/cgi-bin/add_song.cgi?member_name='+member+'&password='+password+'&version=2&filename=Rivendell&seconds='+seconds+'&title='+title+'&artist='+artist+'&album='+album
curl.setopt(curl.URL,url)
curl.setopt(curl.WRITEDATA,buf)
curl.setopt(curl.FOLLOWLOCATION,True)
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_live365.py: you must specify a configuration file')
sys.exit(1)
rcvr.setCallback(ProcessPad)
rcvr.start(sys.argv[1],int(sys.argv[2]))