Fix foreign url bug [BR#88: wenzhoou]

This commit is contained in:
LittleCoder
2016-10-10 08:47:00 +08:00
parent 18dfab5116
commit 2d91c4e06f
2 changed files with 13 additions and 3 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ import time
from .client import client
from . import content # this is for creating pyc
__version__ = '1.1.11'
__version__ = '1.1.12'
__client = client()
def auto_login(hotReload=False, statusStorageDir='itchat.pkl', enableCmdQR=False):
+12 -2
View File
@@ -336,7 +336,12 @@ class client(object):
if m['AppMsgType'] == 6:
def download_atta(attaDir=None):
cookiesList = {name:data for name,data in self.s.cookies.items()}
url = 'https://file%s.wx.qq.com/cgi-bin/mmwebwx-bin/webwxgetmedia'%('2' if '2' in self.loginInfo['url'] else '')
url = '/cgi-bin/mmwebwx-bin/webwxgetmedia'
if 'web.wechat.com' in self.loginInfo['url']:
url = 'https://file.web%s.wechat.com' + url
else:
url = 'https://file%s.wx.qq.com' + url
url = url % ('2' if '2' in self.loginInfo['url'] else '')
payloads = {
'sender': m['FromUserName'],
'mediaid': m['MediaId'],
@@ -446,7 +451,12 @@ class client(object):
return r.json()['BaseResponse']['Ret'] == 0
def __upload_file(self, fileDir, isPicture = False, isVideo = False):
if not tools.check_file(fileDir): return
url = 'https://file%s.wx.qq.com/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json'%('2' if '2' in self.loginInfo['url'] else '')
url = '/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json'
if 'web.wechat.com' in self.loginInfo['url']:
url = 'https://file.web%s.wechat.com' + url
else:
url = 'https://file%s.wx.qq.com' + url
url = url % ('2' if '2' in self.loginInfo['url'] else '')
# save it on server
fileSize = str(os.path.getsize(fileDir))
cookiesList = {name:data for name,data in self.s.cookies.items()}