From d42f0f461c775a634cb4253552adb3b3b00ddaf2 Mon Sep 17 00:00:00 2001 From: LittleCoder Date: Sat, 18 Feb 2017 00:07:03 +0800 Subject: [PATCH] Avoid failure in login of accounts with big contact & make qrcode bigger --- itchat/components/contact.py | 9 +++++++-- itchat/components/login.py | 2 +- itchat/config.py | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/itchat/components/contact.py b/itchat/components/contact.py index b4ad5d0..a207205 100644 --- a/itchat/components/contact.py +++ b/itchat/components/contact.py @@ -254,7 +254,11 @@ def get_contact(self, update=False): headers = { 'ContentType': 'application/json; charset=UTF-8', 'User-Agent' : config.USER_AGENT, } - r = self.s.get(url, headers=headers) + try: + r = self.s.get(url, headers=headers) + except: + logger.info('Failed to fetch contact, that may because of the amount of your chatrooms') + return [] tempList = json.loads(r.content.decode('utf-8', 'replace'))['MemberList'] chatroomList, otherList = [], [] for m in tempList: @@ -350,7 +354,8 @@ def get_head_img(self, userName=None, chatroomUserName=None, picDir=None): ''' params = { 'userName': userName or chatroomUserName or self.storageClass.userName, - 'skey': self.loginInfo['skey'], } + 'skey': self.loginInfo['skey'], + 'type': 'big', } url = '%s/webwxgeticon' % self.loginInfo['url'] if chatroomUserName is None: infoDict = self.storageClass.search_friends(userName=userName) diff --git a/itchat/components/login.py b/itchat/components/login.py index becdc7e..759028d 100644 --- a/itchat/components/login.py +++ b/itchat/components/login.py @@ -84,7 +84,7 @@ def get_QR(self, uuid=None, enableCmdQR=False, picDir=None, qrCallback=None): picDir = picDir or config.DEFAULT_QR qrStorage = io.BytesIO() qrCode = QRCode('https://login.weixin.qq.com/l/' + uuid) - qrCode.png(qrStorage) + qrCode.png(qrStorage, scale=10) if hasattr(qrCallback, '__call__'): qrCallback(uuid=uuid, status='0', qrcode=qrStorage.getvalue()) else: diff --git a/itchat/config.py b/itchat/config.py index d6f1657..1e6735f 100644 --- a/itchat/config.py +++ b/itchat/config.py @@ -1,6 +1,6 @@ import os, platform -VERSION = '1.2.24' +VERSION = '1.2.25' BASE_URL = 'https://login.weixin.qq.com' OS = platform.system() #Windows, Linux, Darwin DIR = os.getcwd() -- GitLab