-
Notifications
You must be signed in to change notification settings - Fork 6
/
config.py
46 lines (36 loc) · 1.44 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
35
36
37
38
39
40
41
42
43
44
45
46
import os
from cryptography.fernet import Fernet
def get_rd_api():
if os.path.exists("fernet.key"):
with open("fernet.key", "rb") as file:
key = file.read()
else:
key = Fernet.generate_key()
with open("fernet.key", "wb") as file:
file.write(key)
if os.path.exists("api.key"):
with open("api.key", "rb") as file:
encrypted_rd_api = file.read()
else:
print("\nIt seems that your API key is not known by the application, please provide it.\n")
rd_api = input("RD API key: ").encode()
with open("fernet.key", "rb") as file:
key = file.read()
f = Fernet(key)
encrypted_rd_api = f.encrypt(rd_api)
with open("api.key", "wb") as file:
file.write(encrypted_rd_api)
f = Fernet(key)
rd_api = f.decrypt(encrypted_rd_api).decode('utf-8')
return rd_api
def get_media_root():
if os.path.exists("root_path"):
with open("root_path", "r") as file:
root_path = file.read()
root_path = os.path.expanduser(root_path)
else:
root_path = input("It seems that the media library path is not known by the application. Please provide the media library path.\nExample E:\Media\Plex (Windows) or ~/Media/Jellyfin (Linux) : : ")
with open("root_path", "w") as file:
file.write(root_path)
root_path = os.path.expanduser(root_path)
return root_path