Skip to content

Commit

Permalink
Merge pull request Urinx#200 from zhoubofsy/rpi_linux
Browse files Browse the repository at this point in the history
修改demoo中接受语音消息出错问题
  • Loading branch information
Urinx authored May 22, 2017
2 parents 8a2ca3f + 314c56e commit 97f347b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions wxbot_demo_py3/weixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ def webwxgetvideo(self, msgid):
def webwxgetvoice(self, msgid):
url = self.base_uri + \
'/webwxgetvoice?msgid=%s&skey=%s' % (msgid, self.skey)
data = self._get(url)
data = self._get(url, api='webwxgetvoice')
if data == '':
return ''
fn = 'voice_' + msgid + '.mp3'
Expand Down Expand Up @@ -1104,7 +1104,10 @@ def _get(self, url: object, api: object = None, timeout: object = None) -> objec
request.add_header('Range', 'bytes=0-')
try:
response = urllib.request.urlopen(request, timeout=timeout) if timeout else urllib.request.urlopen(request)
data = response.read().decode('utf-8')
if api == 'webwxgetvoice' or api == 'webwxgetvideo':
data = response.read()
else:
data = response.read().decode('utf-8')
logging.debug(url)
return data
except urllib.error.HTTPError as e:
Expand Down

0 comments on commit 97f347b

Please sign in to comment.