forked from yanjisheng/blivechat
-
Notifications
You must be signed in to change notification settings - Fork 49
/
update.py
40 lines (34 loc) · 1.47 KB
/
update.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# -*- coding: utf-8 -*-
import asyncio
import aiohttp
import utils.request
VERSION = 'v1.8.2'
DOODLEBEAR_VERSION = 'v1.8.2-230924'
def check_update():
asyncio.get_running_loop().create_task(_do_check_update())
async def _do_check_update():
try:
async with utils.request.http_session.get(
'https://api.github.com/repos/xfgryujk/blivechat/releases/latest'
) as r:
data = await r.json()
if data['name'] != VERSION:
print('---------------------------------------------')
print('New version available:', data['name'])
print(data['body'])
print('Download:', data['html_url'])
print('---------------------------------------------')
async with utils.request.http_session.get(
'https://api.github.com/repos/DoodleBears/blivechat/releases/latest'
) as r:
data = await r.json()
if data['name'] != DOODLEBEAR_VERSION:
print('---------------------------------------------')
print('只熊KUMA版 blivechat has a new version available:', data['name'])
print(data['body'])
print('Download:', data['html_url'])
print('---------------------------------------------')
except aiohttp.ClientConnectionError:
print('Failed to check update: connection failed')
except asyncio.TimeoutError:
print('Failed to check update: timeout')