Removed json from main client.py

This commit is contained in:
Mads Marquart
2017-10-21 11:58:57 +02:00
2 changed files with 4 additions and 2 deletions

View File

@@ -12,7 +12,6 @@ from .utils import *
from .models import * from .models import *
from .graphql import * from .graphql import *
import time import time
import json
@@ -1425,7 +1424,7 @@ class Client(object):
mentions = [] mentions = []
if delta.get('data') and delta['data'].get('prng'): if delta.get('data') and delta['data'].get('prng'):
try: try:
mentions = [Mention(str(mention.get('i')), offset=mention.get('o'), length=mention.get('l')) for mention in json.loads(delta['data']['prng'])] mentions = [Mention(str(mention.get('i')), offset=mention.get('o'), length=mention.get('l')) for mention in parse_json(delta['data']['prng'])]
except Exception: except Exception:
log.exception('An exception occured while reading attachments') log.exception('An exception occured while reading attachments')

View File

@@ -142,6 +142,9 @@ def get_decoded_r(r):
def get_decoded(content): def get_decoded(content):
return content.decode(facebookEncoding) return content.decode(facebookEncoding)
def parse_json(content):
return json.loads(content)
def get_json(r): def get_json(r):
return json.loads(strip_to_json(get_decoded_r(r))) return json.loads(strip_to_json(get_decoded_r(r)))