mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-08-03 17:39:27 +02:00
Merge branch 'deltecent-tunein'
This commit is contained in:
commit
70cf00b268
@ -19084,3 +19084,5 @@
|
|||||||
* Modified the 'pypad' module so as not to throw a
|
* Modified the 'pypad' module so as not to throw a
|
||||||
'UnicodeDecodeError' exception when processing a PAD update
|
'UnicodeDecodeError' exception when processing a PAD update
|
||||||
containing an invalid UTF-8 character.
|
containing an invalid UTF-8 character.
|
||||||
|
2019-09-02 Patrick Linstruth <patrick@deltecent.com>
|
||||||
|
* Refactored 'pypad_tunein.py' ProcessPad while loop.
|
||||||
|
@ -31,31 +31,38 @@ import configparser
|
|||||||
|
|
||||||
def ProcessPad(update):
|
def ProcessPad(update):
|
||||||
if update.hasPadType(pypad.TYPE_NOW):
|
if update.hasPadType(pypad.TYPE_NOW):
|
||||||
section='Station'+str(n)
|
n=1
|
||||||
n=1
|
while(True):
|
||||||
while(update.config().has_section(section)):
|
section='Station'+str(n)
|
||||||
values={}
|
try:
|
||||||
values['id']=update.config().get(section,'StationID')
|
values={}
|
||||||
values['partnerId']=update.config().get(section,'PartnerID')
|
values['id']=update.config().get(section,'StationID')
|
||||||
values['partnerKey']=update.config().get(section,'PartnerKey')
|
values['partnerId']=update.config().get(section,'PartnerID')
|
||||||
values['title']=update.resolvePadFields(update.config().get(section,'TitleString'),pypad.ESCAPE_NONE)
|
values['partnerKey']=update.config().get(section,'PartnerKey')
|
||||||
values['artist']=update.resolvePadFields(update.config().get(section,'ArtistString'),pypad.ESCAPE_NONE)
|
values['title']=update.resolvePadFields(update.config().get(section,'TitleString'),pypad.ESCAPE_NONE)
|
||||||
values['album']=update.resolvePadFields(update.config().get(section,'AlbumString'),pypad.ESCAPE_NONE)
|
values['artist']=update.resolvePadFields(update.config().get(section,'ArtistString'),pypad.ESCAPE_NONE)
|
||||||
update.syslog(syslog.LOG_INFO,'Updating TuneIn: artist='+values['artist']+' title='+values['title']+' album='+values['album'])
|
values['album']=update.resolvePadFields(update.config().get(section,'AlbumString'),pypad.ESCAPE_NONE)
|
||||||
try:
|
except configparser.NoSectionError:
|
||||||
response=requests.get('http://air.radiotime.com/Playing.ashx',params=values)
|
if(n==1):
|
||||||
response.raise_for_status()
|
update.syslog(syslog.LOG_WARNING,'No station config found')
|
||||||
except requests.exceptions.RequestException as e:
|
return
|
||||||
update.syslog(syslog.LOG_WARNING,str(e))
|
|
||||||
else:
|
#
|
||||||
xml=ET.fromstring(response.text)
|
# Now, send the update
|
||||||
status=xml.find('./head/status')
|
#
|
||||||
if(status.text!='200'):
|
if update.shouldBeProcessed(section):
|
||||||
update.syslog(syslog.LOG_WARNING,'Update Failed: '+xml.find('./head/fault').text)
|
update.syslog(syslog.LOG_INFO,'Updating TuneIn: artist='+values['artist']+' title='+values['title']+' album='+values['album'])
|
||||||
n=n+1
|
try:
|
||||||
section='Station'+str(n)
|
response=requests.get('http://air.radiotime.com/Playing.ashx',params=values)
|
||||||
if(n==1):
|
response.raise_for_status()
|
||||||
update.syslog(syslog.LOG_WARNING,'No station config found')
|
except requests.exceptions.RequestException as e:
|
||||||
|
update.syslog(syslog.LOG_WARNING,str(e))
|
||||||
|
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
|
||||||
|
|
||||||
#
|
#
|
||||||
# Program Name
|
# Program Name
|
||||||
|
Loading…
x
Reference in New Issue
Block a user