コード例 #1
0
ファイル: service.py プロジェクト: Santox76/script.sonos
    if ("result" in json_response) and ('addon' in json_response['result']):
        addonItem = json_response['result']['addon']
        if (addonItem['enabled'] is
                True) and (addonItem['broken'] is False) and (
                    addonItem['type']
                    == 'xbmc.addon.repository') and (addonItem['addonid']
                                                     == 'repository.urepo'):
            displayNotice = False

    if displayNotice:
        xbmc.executebuiltin(
            'Notification("URepo Repository Required","www.urepo.org",10000,%s)'
            % ADDON.getAddonInfo('icon'))
    else:
        # Check to see if we need to launch the Sonos Controller as soon as Kodi starts
        if Settings.autoLaunchControllerOnStartup():
            # Launch the Sonos controller, but do not block as we have more to do as a service
            log("SonosService: Launching controller on startup")
            xbmc.executebuiltin(
                'RunScript(%s)' % (os.path.join(CWD, "default.py")), False)

        if (not Settings.isNotificationEnabled()) and (not audioChanges) and (
                not Settings.autoPauseSonos()) and (
                    not Settings.redirectVolumeControls()):
            log("SonosService: Notifications, Volume Link and Auto Pause are disabled, exiting service"
                )
        else:
            sonosDevice = Sonos.createSonosDevice()

            # Make sure a Sonos speaker was found
            if sonosDevice is not None:
コード例 #2
0
ファイル: service.py プロジェクト: robwebset/script.sonos
################################
# Main of the Sonos Service
################################
if __name__ == '__main__':
    log("SonosService: Starting service (version %s)" % ADDON.getAddonInfo('version'))

    # Start by doing any auto-setting of the IP Address
    autoIpAdd = AutoUpdateIPAddress()
    del autoIpAdd

    # Check for the list of things that impact audio
    audioChanges = Settings.linkAudioWithSonos() or Settings.switchSonosToLineIn() or Settings.switchSonosToLineInOnMediaStart()

    # Check to see if we need to launch the Sonos Controller as soon as Kodi starts
    if Settings.autoLaunchControllerOnStartup():
        # Launch the Sonos controller, but do not block as we have more to do as a service
        log("SonosService: Launching controller on startup")
        xbmc.executebuiltin('RunScript(%s)' % (os.path.join(CWD, "default.py")), False)

    if (not Settings.isNotificationEnabled()) and (not audioChanges) and (not Settings.autoPauseSonos()) and (not Settings.redirectVolumeControls()):
        log("SonosService: Notifications, Volume Link and Auto Pause are disabled, exiting service")
    else:
        sonosDevice = Sonos.createSonosDevice()

        # Make sure a Sonos speaker was found
        if sonosDevice is not None:
            timeUntilNextCheck = Settings.getNotificationCheckFrequency() * Settings.getChecksPerSecond()

            log("SonosService: Notification Check Frequency = %d" % timeUntilNextCheck)