Пример #1
0
    def __init__(self, PLUGIN_URL, addon, instanceName, user_agent, settings, authenticate=True, gSpreadsheet=None):
        self.PLUGIN_URL = PLUGIN_URL
        self.addon = addon
        self.instanceName = instanceName
        self.integratedPlayer = False
        self.gSpreadsheet = gSpreadsheet
        self.settings = settings
        self.protocol = 2
        self.cache = cache.cache()

        if authenticate == True:
            self.type = int(addon.getSetting(instanceName+'_type'))

        self.crashreport = crashreport.crashreport(self.addon)

        try:
            username = self.addon.getSetting(self.instanceName+'_username')
        except:
            username = ''
        self.authorization = authorization.authorization(username)


        self.cookiejar = cookielib.CookieJar()

        self.user_agent = user_agent


        # load the OAUTH2 tokens or force fetch if not set
        if (authenticate == True and (not self.authorization.loadToken(self.instanceName,addon, 'auth_access_token') or not self.authorization.loadToken(self.instanceName,addon, 'auth_refresh_token'))):
            if self.type ==4 or self.addon.getSetting(self.instanceName+'_code'):
                self.getToken(self.addon.getSetting(self.instanceName+'_code'))
            else:
                xbmcgui.Dialog().ok(self.addon.getLocalizedString(30000), self.addon.getLocalizedString(30017), self.addon.getLocalizedString(30018))
                xbmc.log(self.addon.getAddonInfo('name') + ': ' + str(e), xbmc.LOGERROR)
Пример #2
0
    def __init__(self, PLUGIN_URL, addon, instanceName, user_agent):
        self.PLUGIN_URL = PLUGIN_URL
        self.addon = addon
        self.instanceName = instanceName

        try:
            username = self.addon.getSetting(self.instanceName+'_username')
        except:
            username = ''
        self.authorization = authorization.authorization(username)


        try:
            auth = self.addon.getSetting(self.instanceName+'_auth_token')
            cookie = self.addon.getSetting(self.instanceName+'_auth_cookie')
        except:
            auth = ''
            cookie = ''

        self.authorization.setToken('auth_token',auth)
        self.authorization.setToken('auth_cookie',cookie)
        self.user_agent = user_agent

        #public playback only -- no authentication
        if self.authorization.username == '':
            return

        # if we have an authorization token set, try to use it
        if auth != '':
          xbmc.log(self.addon.getAddonInfo('name') + ': ' + 'using token', xbmc.LOGDEBUG)
          return
        else:
          xbmc.log(self.addon.getAddonInfo('name') + ': ' + 'no token - logging in', xbmc.LOGDEBUG)
          self.login();
          return
Пример #3
0
    def __init__(self, PLUGIN_URL, addon, instanceName, user_agent):
        self.PLUGIN_URL = PLUGIN_URL
        self.addon = addon
        self.instanceName = instanceName

        try:
            username = self.addon.getSetting(self.instanceName+'_username')
        except:
            username = ''
        self.authorization = authorization.authorization(username)

        try:
            self.version = int(self.addon.getSetting(self.instanceName+'_version'))
        except:
            self.version = OWNCLOUD_V6

        try:
            protocol = int(self.addon.getSetting(self.instanceName+'_protocol'))
            if protocol == 1:
                self.protocol = 'https://'
            else:
                self.protocol = 'http://'
        except:
            self.protocol = 'http://'

        try:
            self.domain = self.addon.getSetting(self.instanceName+'_domain')
        except:
            self.domain = 'localhost'


        self.cookiejar = cookielib.CookieJar()

        try:
            auth = self.addon.getSetting(self.instanceName+'_auth_token')
            session = self.addon.getSetting(self.instanceName+'_auth_session')
        except:
            auth = ''
            session = ''

        self.authorization.setToken('auth_token',auth)
        self.authorization.setToken('auth_session',session)


        self.user_agent = user_agent

        #public playback only -- no authentication
        if self.authorization.username == '':
            return

        # if we have an authorization token set, try to use it
        if auth != '':
          xbmc.log(self.addon.getAddonInfo('name') + ': ' + 'using token', xbmc.LOGDEBUG)
          return
        else:
          xbmc.log(self.addon.getAddonInfo('name') + ': ' + 'no token - logging in', xbmc.LOGDEBUG)
          self.login();
          return
Пример #4
0
    def __init__(self,
                 PLUGIN_URL,
                 addon,
                 instanceName,
                 user_agent,
                 settings,
                 authenticate=True,
                 gSpreadsheet=None):
        self.PLUGIN_URL = PLUGIN_URL
        self.addon = addon
        self.instanceName = instanceName
        self.integratedPlayer = False
        self.gSpreadsheet = gSpreadsheet
        self.settings = settings
        self.protocol = 2
        self.cache = cache.cache()

        if authenticate == True:
            self.type = int(addon.getSetting(instanceName + '_type'))

        self.crashreport = crashreport.crashreport(self.addon)

        try:
            username = self.addon.getSetting(self.instanceName + '_username')
        except:
            username = ''
        self.authorization = authorization.authorization(username)

        self.cookiejar = cookielib.CookieJar()

        self.user_agent = user_agent

        # load the OAUTH2 tokens or force fetch if not set
        if (authenticate == True
                and (not self.authorization.loadToken(self.instanceName, addon,
                                                      'auth_access_token')
                     or not self.authorization.loadToken(
                         self.instanceName, addon, 'auth_refresh_token'))):
            if self.type == 4 or self.addon.getSetting(self.instanceName +
                                                       '_code'):
                self.getToken(
                    self.addon.getSetting(self.instanceName + '_code'))
            else:
                xbmcgui.Dialog().ok(self.addon.getLocalizedString(30000),
                                    self.addon.getLocalizedString(30017),
                                    self.addon.getLocalizedString(30018))
                xbmc.log(
                    self.addon.getAddonInfo('name') + ': ' + str(e),
                    xbmc.LOGERROR)
Пример #5
0
    def __init__(self,
                 plugin_handle,
                 PLUGIN_URL,
                 addon,
                 instanceName,
                 user_agent,
                 settings,
                 authenticate=True):
        self.plugin_handle = plugin_handle
        self.PLUGIN_URL = PLUGIN_URL
        self.addon = addon
        self.instanceName = instanceName
        self.settings = settings
        self.failed = False

        try:
            username = self.getInstanceSetting('username')
            #username = self.getInstanceSetting(str(instanceName) + '_username')
        except:
            username = ''

        self.authorization = authorization.authorization(username)
        self.cookiejar = http.cookiejar.CookieJar()
        self.user_agent = user_agent

        # load the OAUTH2 tokens or force fetch if not set
        if (authenticate == True
                and (not self.authorization.loadToken(self.instanceName, addon,
                                                      'auth_access_token')
                     or not self.authorization.loadToken(
                         self.instanceName, addon, 'auth_refresh_token'))):

            if self.getInstanceSetting('code'):
                self.getToken(self.getInstanceSetting('code'))
            else:
                #xbmcgui.Dialog().ok(self.addon.getLocalizedString(30003), self.addon.getLocalizedString(30005) )
                self.failed = True
                return
Пример #6
0
    def __init__(self, PLUGIN_URL, addon, instanceName, user_agent, settings):
        self.PLUGIN_URL = PLUGIN_URL
        self.addon = addon
        self.instanceName = instanceName
        self.integratedPlayer = False
        self.settings = settings
        self.protocol = 1

        try:
            username = self.addon.getSetting(self.instanceName+'_username')
        except:
            username = ''
        self.authorization = authorization.authorization(username)


        self.cookiejar = cookielib.CookieJar()

        self.user_agent = user_agent


        self.login();
        xbmcgui.Dialog().ok(addon.getLocalizedString(30000), addon.getLocalizedString(30153), addon.getLocalizedString(30154))

        self.cache = cache.cache()
Пример #7
0
    def __init__(self, PLUGIN_URL, addon, instanceName, user_agent, settings):
        self.PLUGIN_URL = PLUGIN_URL
        self.addon = addon
        self.instanceName = instanceName
        self.integratedPlayer = False
        self.settings = settings
        self.protocol = 1

        try:
            username = self.addon.getSetting(self.instanceName + '_username')
        except:
            username = ''
        self.authorization = authorization.authorization(username)

        self.cookiejar = cookielib.CookieJar()

        self.user_agent = user_agent

        self.login()
        xbmcgui.Dialog().ok(addon.getLocalizedString(30000),
                            addon.getLocalizedString(30153),
                            addon.getLocalizedString(30154))

        self.cache = cache.cache()
Пример #8
0
    def __init__(self, PLUGIN_URL, addon, instanceName, user_agent):
        self.PLUGIN_URL = PLUGIN_URL
        self.addon = addon
        self.instanceName = instanceName

        try:
            if self.addon.getSetting(self.instanceName + "_ssl") == "true":
                import ssl

                ssl._create_default_https_context = ssl._create_unverified_context
        except:
            pass

        try:
            username = self.addon.getSetting(self.instanceName + "_username")
        except:
            username = ""
        self.authorization = authorization.authorization(username)

        try:
            self.version = int(self.addon.getSetting(self.instanceName + "_version"))
        except:
            self.version = OWNCLOUD_V6

        try:
            protocol = int(self.addon.getSetting(self.instanceName + "_protocol"))
            if protocol == 1:
                self.protocol = "https://"
            else:
                self.protocol = "http://"
        except:
            self.protocol = "http://"

        try:
            self.domain = self.addon.getSetting(self.instanceName + "_domain")
        except:
            self.domain = "localhost"

        self.cookiejar = cookielib.CookieJar()

        try:
            auth = self.addon.getSetting(self.instanceName + "_auth_token")
            session = self.addon.getSetting(self.instanceName + "_auth_session")
        except:
            auth = ""
            session = ""

        self.authorization.setToken("auth_token", auth)
        self.authorization.setToken("auth_session", session)

        self.user_agent = user_agent

        # public playback only -- no authentication
        if self.authorization.username == "":
            return

        # if we have an authorization token set, try to use it
        if auth != "":
            xbmc.log(self.addon.getAddonInfo("name") + ": " + "using token", xbmc.LOGDEBUG)
            return
        else:
            xbmc.log(self.addon.getAddonInfo("name") + ": " + "no token - logging in", xbmc.LOGDEBUG)
            self.login()
            return