-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.py
executable file
·108 lines (91 loc) · 5.17 KB
/
install.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env python3
import os
import colorama
import platform
import getpass
import json
from time import sleep
#A context manager class which changes the working directory
class cd:
def __init__(self, newPath):
self.newPath = os.path.expanduser(newPath)
def __enter__(self):
self.savedPath = os.getcwd()
os.chdir(self.newPath)
def __exit__(self, etype, value, traceback):
os.chdir(self.savedPath)
#Clear screen
if platform.system() == "Windows":
os.system('cls')
if platform.system() == "Linux":
os.system('clear')
version = "BETA"
colorama.init()
print("\033[95mWelcome to \033[0m \n")
print("\033[93m██╗ ██╗███╗ ███╗ █████╗ ██████╗ ██╗ ██╗ ██████╗██╗ ██╗ █████╗ ███╗ ██╗\033[0m")
print("\033[93m██║ ██║████╗ ████║██╔══██╗██╔══██╗██║ ██║ ██╔════╝██║ ██║██╔══██╗████╗ ██║\033[0m")
print("\033[93m██║ ██║██╔████╔██║███████║██████╔╝██║ ██║█████╗██║ ███████║███████║██╔██╗ ██║\033[0m")
print("\033[93m██║ ██║██║╚██╔╝██║██╔══██║██╔══██╗██║ ██║╚════╝██║ ██╔══██║██╔══██║██║╚██╗██║\033[0m")
print("\033[93m╚██████╔╝██║ ╚═╝ ██║██║ ██║██║ ██║╚██████╔╝ ╚██████╗██║ ██║██║ ██║██║ ╚████║\033[0m")
print("\033[93m ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═══╝\033[0m \033[95m v{}\033[0m".format(version))
print("\033[95mA program to automate anime watching and downloading on Linux.\033[0m")
print("")
print("This script will guide you through setting up Umaru-chan for the first time")
print("")
sleep(2)
with cd("source"):
print("\033[92m[+] Moved to source directory.\033[0m")
print("Checking if data folder exists...")
sleep(1)
if not os.path.isdir("data"):
print("\033[91m[-] Does not exist! Creating one...")
sleep(1)
os.mkdir("data")
with cd("data"):
print("\033[92m[+] Moved to data directory\033[0m")
path = input("Where is the root folder of your anime library? (Enter absolute path):\n")
torrent = input("Where do you want your downloaded .torrent files to be stored? (Enter absolute path):\n")
#Check for a trailing slash based on platform
if platform.system() == "Linux":
if torrent[-1] != "/":
torrent = torrent + "/"
if platform.system() == "Windows":
if torrent[-1] != "\\":
torrent = torrent + "\\"
print("\033[95mIMPORTANT: Turn on 'Download .torrent files automatically from this folder' in the settings of your Torrent Client and set the folder to the one specified above.\033[0m")
q = input("What do you want the default quality of downloads to be? (480p/720p/1080p):\n")
if q == "480p" or q == "720p" or q == "1080p":
quality = q
else:
print("\033[91mInvalid input! Setting to default quality (720p)\033[0m")
quality = "720p"
_id = input("Do you own a MAL(MyAnimeList) account? (y/n): ")
if _id == 'y':
print("Enter your credentials \033[91m(WARNING: Your credentials will be stored locally in plaintext form)\033[0m")
username = input("Username: ")
password = getpass.getpass("Password: ")
autoDetect = input("Umaru-chan supports automatic updating of your watchlist on MAL. Enable it? (y/n): ")
if autoDetect == 'y':
print("Creating necessary files for media_detect and autofind scripts.")
with open("loginData.json", "w+") as f:
emptyDict = {}
json.dump(emptyDict, f, indent=4)
with open("media_players.json", "w+") as f:
emptyList = []
json.dump(emptyList, f, indent=4)
sleep(1)
print("\033[91mRun media_detect.py for automatic list updation.\033[0m")
else:
username = ""
password = ""
print("Creating config...")
config = {"main":{"path":path,"torrent":torrent,"quality":quality,"username":username,"password":password},"watchlist":{}}
with open("config.json", "w+") as f:
json.dump(config, f, indent=4)
sleep(1)
print("\033[92m[+] Config created!\033[0m")
print("")
print("\033[92mAll set!\033[0m")
print("\033[96m[*] Add anime to your watchlist by running client.py with -a/--add option.\033[0m \033[91m(Example: python client.py -a \"boku no hero academia\":87 where the no. following the ':' refers to the last watched episode number)\033[0m")
print("\033[96m[*] All values set above can be changed by running client.py followed by the appropriate argument. Type -h/--help for more info.\033[0m")
print("\033[96m[*] When done, run server.py and leave it running in the background (Don't forget to keep your Torrent Client open and ready to download .torrent files!)\033[0m")