bugfix
This commit is contained in:
parent
ba211de526
commit
0cdf3c5fc8
@ -116,12 +116,12 @@ class WeChatMediaManager:
|
|||||||
|
|
||||||
async with aiohttp.ClientSession(timeout=timeout) as session:
|
async with aiohttp.ClientSession(timeout=timeout) as session:
|
||||||
async with session.post(url, data=form) as resp:
|
async with session.post(url, data=form) as resp:
|
||||||
result = await resp.json()
|
text = await resp.text()
|
||||||
|
if resp.status == 200:
|
||||||
if resp.status == 200 and ('media_id' in result or 'url' in result):
|
result = json.loads(text)
|
||||||
return result['media_id']
|
return result['media_id']
|
||||||
else:
|
else:
|
||||||
raise Exception(f"WeChat Upload Error: {result}")
|
raise Exception(f"WeChat Upload Error: {text}")
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
f.close() # 手动关闭
|
f.close() # 手动关闭
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user