-
Notifications
You must be signed in to change notification settings - Fork 4
/
dynamic_watch_general.py
50 lines (44 loc) · 1.4 KB
/
dynamic_watch_general.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
42
43
44
45
46
47
48
49
50
import json
import time
import updynamic
from dynamic_parser import DynamicParser
from notifier import Notifier
uid = int(input('UP主UID: '))
upwh = updynamic.UploaderDynamic(uid)
uploader_name = upwh.uploader_name
notify_methods = ['stdout']
available_notify_methods_d = Notifier.get_available_notify_methods_d()
user_selection_notify_methods_d = {}
print('选择你需要的通知方式:')
i = 0
for key, value in available_notify_methods_d.items():
if key == 'stdout':
continue
user_selection_notify_methods_d[str(i)] = key
print('\t{}: {}'.format(i, value))
i += 1
user_selection_input = input('请输入你的选择 (多个选择用空格隔开): ')
for item in user_selection_input.split(' '):
if item in user_selection_notify_methods_d:
notify_methods.append(user_selection_notify_methods_d[item])
notifier = Notifier(notify_methods)
notifier.notify(
{
'type': 0,
'start': True,
'monitor': None,
'uploader_name': uploader_name
}
)
while True:
try:
new_dynamics = upwh.get_update()
if len(new_dynamics) > 0:
for dynamic in new_dynamics:
dynamic_dict = DynamicParser.dictionary_parser(dynamic, legacy_mode=True)
dynamic_dict['type'] = 0
notifier.notify(dynamic_dict)
except Exception as e:
print(e)
finally:
time.sleep(30)