-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
41 lines (31 loc) · 1.02 KB
/
utils.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
41
import time
import requests
import config
def get_current_time(time_format):
current_struct_time = time.localtime(time.time())
current_time = time.strftime(time_format, current_struct_time)
return current_time
def generate_filename(room_id):
data = dict()
data['c_time'] = get_current_time('%Y%m%d_%H%M')
data['room_id'] = room_id
return '_'.join(data.values())
def inform(text, desp):
if config.enable_inform:
param = {
'text': text,
'desp': desp,
}
resp = requests.get(url=config.inform_url, params=param)
if resp.status_code == 200:
print_log(content='通知完成!')
else:
pass
def print_log(room_id='None', content='None'):
brackets = '[{}]'
time_part = brackets.format(get_current_time('%Y-%m-%d %H:%M:%S'))
room_part = brackets.format('直播间: ' + room_id)
print(time_part, room_part, content)
if __name__ == '__main__':
print(generate_filename('1075'))
print_log(content='开始录制')