Пример #1
0
def accountActions(addon, PLUGIN_NAME, mode, instanceName, numberOfAccounts):

    if mode == 'dummy':
        xbmc.executebuiltin("XBMC.Container.Refresh")

    # delete the configuration for the specified account
    elif mode == 'delete':

        #*** old - needs to be re-written
        if instanceName != '':

            try:
                # gdrive specific ***
                addon.setSetting(instanceName + '_username', '')
                addon.setSetting(instanceName + '_code', '')
                addon.setSetting(instanceName + '_client_id', '')
                addon.setSetting(instanceName + '_client_secret', '')
                addon.setSetting(instanceName + '_url', '')
                addon.setSetting(instanceName + '_password', '')
                addon.setSetting(instanceName + '_passcode', '')
                addon.setSetting(instanceName + '_auth_access_token', '')
                addon.setSetting(instanceName + '_auth_refresh_token', '')
                # ***
                xbmcgui.Dialog().ok(addon.getLocalizedString(30000),
                                    addon.getLocalizedString(30158))
            except:
                #error: instance doesn't exist
                pass
        xbmc.executebuiltin("XBMC.Container.Refresh")

    # enroll a new account
    elif mode == 'enroll':

        invokedUsername = settings.getParameter('username')
        code = settings.getParameter('code', '')

        if code == '':
            options = []
            options.append('Google Apps')
            ret = xbmcgui.Dialog().select('select type', options)

            invokedUsername = ''
            password = ''
            if ret == 0:
                try:
                    dialog = xbmcgui.Dialog()
                    invokedUsername = dialog.input('username',
                                                   type=xbmcgui.INPUT_ALPHANUM)
                    passcode = dialog.input('passcode',
                                            type=xbmcgui.INPUT_ALPHANUM)
                except:
                    pass

            count = 1
            loop = True
            while loop:
                instanceName = PLUGIN_NAME + str(count)
                try:
                    username = settings.getSetting(instanceName + '_username')
                    if username == invokedUsername:
                        addon.setSetting(instanceName + '_type', str(4))
                        addon.setSetting(instanceName + '_username',
                                         str(invokedUsername))
                        addon.setSetting(instanceName + '_passcode',
                                         str(passcode))
                        xbmcgui.Dialog().ok(addon.getLocalizedString(30000),
                                            addon.getLocalizedString(30118),
                                            invokedUsername)
                        loop = False
                    elif username == '':
                        addon.setSetting(instanceName + '_type', str(4))
                        addon.setSetting(instanceName + '_username',
                                         str(invokedUsername))
                        addon.setSetting(instanceName + '_passcode',
                                         str(passcode))
                        xbmcgui.Dialog().ok(addon.getLocalizedString(30000),
                                            addon.getLocalizedString(30118),
                                            invokedUsername)
                        loop = False

                except:
                    pass

                if count == numberOfAccounts:
                    #fallback on first defined account
                    addon.setSetting(instanceName + '_type', str(4))
                    addon.setSetting(instanceName + '_username',
                                     invokedUsername)
                    addon.setSetting(instanceName + '_passcode', str(passcode))
                    xbmcgui.Dialog().ok(addon.getLocalizedString(30000),
                                        addon.getLocalizedString(30118),
                                        invokedUsername)
                    loop = False
                count = count + 1

        else:
            count = 1
            loop = True
            while loop:
                instanceName = PLUGIN_NAME + str(count)
                try:
                    username = settings.getSetting(instanceName + '_username')
                    if username == invokedUsername:
                        addon.setSetting(instanceName + '_type', str(1))
                        addon.setSetting(instanceName + '_code', str(code))
                        addon.setSetting(instanceName + '_username',
                                         str(invokedUsername))
                        xbmcgui.Dialog().ok(addon.getLocalizedString(30000),
                                            addon.getLocalizedString(30118),
                                            invokedUsername)
                        loop = False
                    elif username == '':
                        addon.setSetting(instanceName + '_type', str(1))
                        addon.setSetting(instanceName + '_code', str(code))
                        addon.setSetting(instanceName + '_username',
                                         str(invokedUsername))
                        xbmcgui.Dialog().ok(addon.getLocalizedString(30000),
                                            addon.getLocalizedString(30118),
                                            invokedUsername)
                        loop = False

                except:
                    pass

                if count == numberOfAccounts:
                    #fallback on first defined account
                    addon.setSetting(instanceName + '_type', str(1))
                    addon.setSetting(instanceName + '_code', code)
                    addon.setSetting(instanceName + '_username',
                                     invokedUsername)
                    xbmcgui.Dialog().ok(addon.getLocalizedString(30000),
                                        addon.getLocalizedString(30118),
                                        invokedUsername)
                    loop = False
                count = count + 1
Пример #2
0
def accountActions(addon, PLUGIN_NAME, mode, instanceName, numberOfAccounts):

    if mode == 'dummy':
        xbmc.executebuiltin("XBMC.Container.Refresh")

    # delete the configuration for the specified account
    elif mode == 'delete':

        #*** old - needs to be re-written
        if instanceName != '':

            try:
                # gdrive specific ***
                addon.setSetting(instanceName + '_username', '')
                addon.setSetting(instanceName + '_code', '')
                addon.setSetting(instanceName + '_client_id', '')
                addon.setSetting(instanceName + '_client_secret', '')
                addon.setSetting(instanceName + '_url', '')
                addon.setSetting(instanceName + '_password', '')
                addon.setSetting(instanceName + '_passcode', '')
                addon.setSetting(instanceName + '_auth_access_token', '')
                addon.setSetting(instanceName + '_auth_refresh_token', '')
                # ***
                xbmcgui.Dialog().ok(addon.getLocalizedString(30000), addon.getLocalizedString(30158))
            except:
                #error: instance doesn't exist
                pass
        xbmc.executebuiltin("XBMC.Container.Refresh")


    # enroll a new account
    elif mode == 'enroll':


            invokedUsername = settings.getParameter('username')
            code = settings.getParameter('code', '')


            if code == '':
                options = []
                options.append('Google Apps')
                ret = xbmcgui.Dialog().select('select type', options)

                invokedUsername = ''
                password = ''
                if ret == 0:
                    try:
                        dialog = xbmcgui.Dialog()
                        invokedUsername = dialog.input('username', type=xbmcgui.INPUT_ALPHANUM)
                        passcode = dialog.input('passcode', type=xbmcgui.INPUT_ALPHANUM)
                    except:
                        pass

                count = 1
                loop = True
                while loop:
                    instanceName = PLUGIN_NAME+str(count)
                    try:
                        username = settings.getSetting(instanceName+'_username')
                        if username == invokedUsername:
                            addon.setSetting(instanceName + '_type', str(4))
                            addon.setSetting(instanceName + '_username', str(invokedUsername))
                            addon.setSetting(instanceName + '_passcode', str(passcode))
                            xbmcgui.Dialog().ok(addon.getLocalizedString(30000), addon.getLocalizedString(30118), invokedUsername)
                            loop = False
                        elif username == '':
                            addon.setSetting(instanceName + '_type', str(4))
                            addon.setSetting(instanceName + '_username', str(invokedUsername))
                            addon.setSetting(instanceName + '_passcode', str(passcode))
                            xbmcgui.Dialog().ok(addon.getLocalizedString(30000), addon.getLocalizedString(30118), invokedUsername)
                            loop = False

                    except:
                        pass

                    if count == numberOfAccounts:
                        #fallback on first defined account
                        addon.setSetting(instanceName + '_type', str(4))
                        addon.setSetting(instanceName + '_username', invokedUsername)
                        addon.setSetting(instanceName + '_passcode', str(passcode))
                        xbmcgui.Dialog().ok(addon.getLocalizedString(30000), addon.getLocalizedString(30118), invokedUsername)
                        loop = False
                    count = count + 1

            else:
                count = 1
                loop = True
                while loop:
                    instanceName = PLUGIN_NAME+str(count)
                    try:
                        username = settings.getSetting(instanceName+'_username')
                        if username == invokedUsername:
                            addon.setSetting(instanceName + '_type', str(1))
                            addon.setSetting(instanceName + '_code', str(code))
                            addon.setSetting(instanceName + '_username', str(invokedUsername))
                            xbmcgui.Dialog().ok(addon.getLocalizedString(30000), addon.getLocalizedString(30118), invokedUsername)
                            loop = False
                        elif username == '':
                            addon.setSetting(instanceName + '_type', str(1))
                            addon.setSetting(instanceName + '_code', str(code))
                            addon.setSetting(instanceName + '_username', str(invokedUsername))
                            xbmcgui.Dialog().ok(addon.getLocalizedString(30000), addon.getLocalizedString(30118), invokedUsername)
                            loop = False

                    except:
                        pass

                    if count == numberOfAccounts:
                        #fallback on first defined account
                        addon.setSetting(instanceName + '_type', str(1))
                        addon.setSetting(instanceName + '_code', code)
                        addon.setSetting(instanceName + '_username', invokedUsername)
                        xbmcgui.Dialog().ok(addon.getLocalizedString(30000), addon.getLocalizedString(30118), invokedUsername)
                        loop = False
                    count = count + 1
kodi_common.debugger()


# cloudservice - create settings module
settings = settings.settings(addon)

# retrieve settings
user_agent = settings.getSetting('user_agent')
#obsolete, replace, revents audio from streaming
#if user_agent == 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)':
#    addon.setSetting('user_agent', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.195.38 Safari/532.0')



mode = settings.getParameter('mode','main')

# make mode case-insensitive
mode = mode.lower()


#*** old - acd
# allow for playback of public videos without authentication
#if (mode == 'shared'):
#  authenticate = False
#else:
authenticate = True
##**


instanceName = ''