Improved error handling, and improved uid-loading
Requests would sometimes throw an error while retrieving the c_user cookie (If there were multiple cookies with this name)
This commit is contained in:
@@ -157,7 +157,10 @@ class Client(object):
|
|||||||
self.payloadDefault = {}
|
self.payloadDefault = {}
|
||||||
self.client_id = hex(int(random()*2147483648))[2:]
|
self.client_id = hex(int(random()*2147483648))[2:]
|
||||||
self.start_time = now()
|
self.start_time = now()
|
||||||
self.uid = str(self._session.cookies['c_user'])
|
self.uid = self._session.cookies.get_dict().get('c_user')
|
||||||
|
if self.uid is None:
|
||||||
|
raise Exception('Could not find c_user cookie')
|
||||||
|
self.uid = str(self.uid)
|
||||||
self.user_channel = "p_" + self.uid
|
self.user_channel = "p_" + self.uid
|
||||||
self.ttstamp = ''
|
self.ttstamp = ''
|
||||||
|
|
||||||
|
@@ -143,7 +143,11 @@ def graphql_queries_to_json(*queries):
|
|||||||
return json.dumps(rtn)
|
return json.dumps(rtn)
|
||||||
|
|
||||||
def graphql_response_to_json(content):
|
def graphql_response_to_json(content):
|
||||||
j = json.loads(content, cls=ConcatJSONDecoder)
|
content = strip_to_json(content) # Usually only needed in some error cases
|
||||||
|
try:
|
||||||
|
j = json.loads(content, cls=ConcatJSONDecoder)
|
||||||
|
except Exception as e:
|
||||||
|
raise Exception('Error while parsing JSON: {}'.format(repr(content)), e)
|
||||||
|
|
||||||
rtn = [None]*(len(j))
|
rtn = [None]*(len(j))
|
||||||
for x in j:
|
for x in j:
|
||||||
|
Reference in New Issue
Block a user