mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-07-13 15:17:44 +02:00
2019-08-26 Fred Gleason <fredg@paravelsystems.com>
* Fixed a bug in the 'pypad_tunein.py' PyPAD script that caused an infinite loop.
This commit is contained in:
parent
3b95c723b7
commit
88bebdecc4
@ -19006,3 +19006,6 @@
|
|||||||
2019-08-26 Fred Gleason <fredg@paravelsystems.com>
|
2019-08-26 Fred Gleason <fredg@paravelsystems.com>
|
||||||
* Fixed a bug in the 'pypad_spottrap.py' PyPAD script that caused
|
* Fixed a bug in the 'pypad_spottrap.py' PyPAD script that caused
|
||||||
an infinite loop.
|
an infinite loop.
|
||||||
|
2019-08-26 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
* Fixed a bug in the 'pypad_tunein.py' PyPAD script that caused
|
||||||
|
an infinite loop.
|
||||||
|
@ -31,33 +31,31 @@ import configparser
|
|||||||
|
|
||||||
def ProcessPad(update):
|
def ProcessPad(update):
|
||||||
if update.hasPadType(pypad.TYPE_NOW):
|
if update.hasPadType(pypad.TYPE_NOW):
|
||||||
n=1
|
|
||||||
while(True):
|
|
||||||
section='Station'+str(n)
|
section='Station'+str(n)
|
||||||
|
n=1
|
||||||
|
while(update.config().has_section(section)):
|
||||||
|
values={}
|
||||||
|
values['id']=update.config().get(section,'StationID')
|
||||||
|
values['partnerId']=update.config().get(section,'PartnerID')
|
||||||
|
values['partnerKey']=update.config().get(section,'PartnerKey')
|
||||||
|
values['title']=update.resolvePadFields(update.config().get(section,'TitleString'),pypad.ESCAPE_NONE)
|
||||||
|
values['artist']=update.resolvePadFields(update.config().get(section,'ArtistString'),pypad.ESCAPE_NONE)
|
||||||
|
values['album']=update.resolvePadFields(update.config().get(section,'AlbumString'),pypad.ESCAPE_NONE)
|
||||||
|
update.syslog(syslog.LOG_INFO,'Updating TuneIn: artist='+values['artist']+' title='+values['title']+' album='+values['album'])
|
||||||
try:
|
try:
|
||||||
values={}
|
response=requests.get('http://air.radiotime.com/Playing.ashx',params=values)
|
||||||
values['id']=update.config().get(section,'StationID')
|
response.raise_for_status()
|
||||||
values['partnerId']=update.config().get(section,'PartnerID')
|
except requests.exceptions.RequestException as e:
|
||||||
values['partnerKey']=update.config().get(section,'PartnerKey')
|
update.syslog(syslog.LOG_WARNING,str(e))
|
||||||
values['title']=update.resolvePadFields(update.config().get(section,'TitleString'),pypad.ESCAPE_NONE)
|
else:
|
||||||
values['artist']=update.resolvePadFields(update.config().get(section,'ArtistString'),pypad.ESCAPE_NONE)
|
xml=ET.fromstring(response.text)
|
||||||
values['album']=update.resolvePadFields(update.config().get(section,'AlbumString'),pypad.ESCAPE_NONE)
|
status=xml.find('./head/status')
|
||||||
update.syslog(syslog.LOG_INFO,'Updating TuneIn: artist='+values['artist']+' title='+values['title']+' album='+values['album'])
|
if(status.text!='200'):
|
||||||
try:
|
update.syslog(syslog.LOG_WARNING,'Update Failed: '+xml.find('./head/fault').text)
|
||||||
response=requests.get('http://air.radiotime.com/Playing.ashx',params=values)
|
n=n+1
|
||||||
response.raise_for_status()
|
section='Station'+str(n)
|
||||||
except requests.exceptions.RequestException as e:
|
if(n==1):
|
||||||
update.syslog(syslog.LOG_WARNING,str(e))
|
update.syslog(syslog.LOG_WARNING,'No station config found')
|
||||||
else:
|
|
||||||
xml=ET.fromstring(response.text)
|
|
||||||
status=xml.find('./head/status')
|
|
||||||
if(status.text!='200'):
|
|
||||||
update.syslog(syslog.LOG_WARNING,'Update Failed: '+xml.find('./head/fault').text)
|
|
||||||
n=n+1
|
|
||||||
except configparser.NoSectionError:
|
|
||||||
if(n==1):
|
|
||||||
update.syslog(syslog.LOG_WARNING,'No station config found')
|
|
||||||
return
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Program Name
|
# Program Name
|
||||||
|
Loading…
x
Reference in New Issue
Block a user