Beispiel #1
0
    def authenticate(self, user, pwd):
        try:
            # partner login
            partner = self.do_request(
                "auth.partnerLogin",
                True,
                False,
                deviceModel=self.DEVICE_MODEL,
                username=self.PARTNER_USERNAME,
                password=self.PARTNER_PASSWORD,
                version=self.PROTOCOL_VERSION,
            )
            self.partner_id = partner["partnerId"]
            self.partner_auth_token = partner["partnerAuthToken"]

            # sync
            pandora_time = int(crypt.pandora_decrypt(partner["syncTime"])[4:14])
            self.time_offset = pandora_time - time.time()

            # user login
            user = self.do_request(
                "auth.userLogin", True, True, username=user, password=pwd, loginType="user", returnStationList=True
            )
            self.user_id = user["userId"]
            self.user_auth_token = user["userAuthToken"]
            self.stations = user["stationListResult"]["stations"]
            return True
        except:
            self.partner_id = None
            self.partner_auth_token = None
            self.user_id = None
            self.user_auth_token = None
            self.time_offset = None

            return False
Beispiel #2
0
	def authenticate(self, user, pwd):
		try:
			# partner login
			partner = self.do_request('auth.partnerLogin', True, False, deviceModel=self.DEVICE_MODEL, username=self.PARTNER_USERNAME, password=self.PARTNER_PASSWORD, version=self.PROTOCOL_VERSION)
			self.partner_id = partner['partnerId']
			self.partner_auth_token = partner['partnerAuthToken']
			
			# sync
			pandora_time = int(crypt.pandora_decrypt(partner['syncTime'])[4:14])
			self.time_offset = pandora_time - time.time()
			
			# user login
			user = self.do_request('auth.userLogin', True, True, username=user, password=pwd, loginType="user")
			self.user_id = user['userId']
			self.user_auth_token = user['userAuthToken']
			
			return True
		except:
			self.partner_id = None
			self.partner_auth_token = None
			self.user_id = None
			self.user_auth_token = None
			self.time_offset = None
			
			return False
Beispiel #3
0
    def authenticate_connection(self):
        try:
            # partner login
            partner = self.do_request(
                "auth.partnerLogin",
                True,
                False,
                None,
                deviceModel=self.DEVICE_MODEL,
                username=self.PARTNER_USERNAME,
                password=self.PARTNER_PASSWORD,
                version=self.PROTOCOL_VERSION,
            )
            self.partner_id = partner["partnerId"]
            self.partner_auth_token = partner["partnerAuthToken"]

            # sync
            pandora_time = int(crypt.pandora_decrypt(partner["syncTime"])[4:14])
            self.time_offset = pandora_time - time.time()
            #
            ## user login
            # user = self.do_request('auth.userLogin', True, True, username=user, password=pwd, loginType="user")
            # self.user_id = user['userId']
            # self.user_auth_token = user['userAuthToken']

            return True
        except Exception as e:
            self.partner_id = None
            self.partner_auth_token = None
            # self.user_id = None
            # self.user_auth_token = None
            # self.time_offset = None
            print repr(e)

            return False
Beispiel #4
0
    def __init__(self):
        self.rid = "%07i" % (time.time() % 1e7)
        self.timedelta = 0

        try:
            # partner login
            partner = self.do_request('auth.partnerLogin', True, False, {}, deviceModel=self.DEVICE_MODEL, username=self.PARTNER_USERNAME, password=self.PARTNER_PASSWORD, version=self.PROTOCOL_VERSION)
            self.partner_id = partner['partnerId']
            self.partner_auth_token = partner['partnerAuthToken']

            # sync
            pandora_time = int(crypt.pandora_decrypt(partner['syncTime'])[4:14])
            self.time_offset = pandora_time - time.time()
        except:
            self.partner_id = None
            self.partner_auth_token = None
            self.time_offset = None

            raise Exception("Establishing connection to Pandora failed")
Beispiel #5
0
    def authenticate(self, user, pwd):
        try:
            # partner login
            partner = self.do_request('auth.partnerLogin',
                                      True,
                                      False,
                                      deviceModel=self.DEVICE_MODEL,
                                      username=self.PARTNER_USERNAME,
                                      password=self.PARTNER_PASSWORD,
                                      version=self.PROTOCOL_VERSION)
            self.partner_id = partner['partnerId']
            self.partner_auth_token = partner['partnerAuthToken']

            # sync
            pandora_time = int(
                crypt.pandora_decrypt(partner['syncTime'])[4:14])
            self.time_offset = pandora_time - time.time()

            # user login
            user = self.do_request('auth.userLogin',
                                   True,
                                   True,
                                   username=user,
                                   password=pwd,
                                   loginType="user")
            self.user_id = user['userId']
            self.user_auth_token = user['userAuthToken']

            return True
        except:
            self.partner_id = None
            self.partner_auth_token = None
            self.user_id = None
            self.user_auth_token = None
            self.time_offset = None

            return False