forked from kakuyuuki/6v_auto_seed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
34 lines (34 loc) · 1.33 KB
/
config.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
import configparser
import os
import json
confile = 'configure.ini'
def check_file():
config = configparser.ConfigParser()
if not os.path.exists(confile):
print('Lack of configure file : configure.ini')
config['6v'] = {'cookies': ''}
config['utorrent'] = {'account': '', 'password': '', 'cookies': '', 'token': ''}
with open(confile, 'w') as configfile:
config.write(configfile)
print('new configure file created')
else:
print('configure file exists')
def check_data():
print('did nothing')
def save_cookies(UTorrentAPI,neu6):
check_file()
config = configparser.ConfigParser()
config.read(confile)
config.set('6v', 'cookies', json.dumps(neu6.cookies.get_dict()).replace('%','%%'))
config.set('utorrent', 'account', UTorrentAPI.account)
config.set('utorrent', 'password', UTorrentAPI.password)
config.set('utorrent', 'cookies', json.dumps(UTorrentAPI.cookies).replace('%','%%'))
config.set('utorrent', 'token', str(UTorrentAPI.token))
config.write(open(confile, "w"))
print('cookies account password saved')
def neu6_getconfig() -> dict:
check_file()
config = configparser.ConfigParser()
config.read(confile)
cookies = config.get('6v', 'cookies')
return json.loads(cookies.replace('%%','%'))