def execute(self, data=''):
# evaluate input argument and depends on run add-on event/action
if data.startswith('Location'):
keyboard = xbmc.Keyboard('', xbmc.getLocalizedString(14024), False)
keyboard.doModal()
if keyboard.isConfirmed() and keyboard.getText() != '':
text = keyboard.getText()
locationNames, locationIds = self.provider.location(text)
dialog = xbmcgui.Dialog()
if locationNames != []:
selected = dialog.select(xbmc.getLocalizedString(396), locationNames)
if selected != -1:
commons.setSetting('Enabled', 'true')
commons.setSetting(data, locationNames[selected])
commons.debug('Selected location: %s' % locationNames[selected])
commons.setSetting(data + 'id', locationIds[selected])
commons.debug('Selected location id: %s' % locationIds[selected])
else:
dialog.ok(commons.AddonName(), commons.translate(284))
elif commons.setting('Enabled'):
location = commons.setting('Location%s' % data)
locationid = commons.setting('Location%sid' % data)
if (locationid == '') and (data != '1'):
location = commons.setting('Location1')
locationid = commons.setting('Location1id')
commons.debug('Trying first location instead: %s (%s)' % (location, locationid))
if locationid == '':
commons.debug('Fallback to GeoIP')
location, locationid = self.provider.geoip()
if not locationid == '':
commons.debug('Call forecast for location %s (%s)' % (location, locationid))
self.provider.forecast(location, locationid)
else:
commons.debug('No location found')
self.provider.clear()
self.provider.refresh()
else:
commons.debug('You need to enable weather retrieval in the weather underground add-on settings')
self.provider.clear()
评论列表
文章目录