forked from wangroot/MFCRecorder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd.py
More file actions
44 lines (34 loc) · 1.2 KB
/
add.py
File metadata and controls
44 lines (34 loc) · 1.2 KB
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
#!/usr/bin/env python3
import sys, configparser
from mfcauto import Client
import asyncio
Config = configparser.ConfigParser()
Config.read(sys.path[0] + "/config.conf")
wishlist = Config.get('paths', 'wishlist')
f = open(wishlist, 'r')
wanted = list(set(f.readlines()))
async def main(loop):
if len(sys.argv) != 2:
print('Must include a models name. ie: add.py AspenRae'.format(sys.argv[0]))
sys.exit(1)
modelName = sys.argv[1]
print("Querying MFC for {}".format(modelName))
client = Client(loop)
await client.connect(False)
msg = await client.query_user(modelName)
client.disconnect()
print()
if msg == None:
print("User not found. Please check your spelling and try again")
else:
if str(msg['uid'])+'\n' in wanted:
print('{} is already in the wanted list. Models UID is {}'.format(modelName, str(msg['uid'])))
else:
f = open(wishlist, 'a')
f.write(str(msg['uid'])+'\n')
print("{} with UID {} has been added to the list".format(modelName, msg['uid']))
print()
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(main(loop))
loop.close()