44from termcolor import colored
55from ctypes import windll
66from time import sleep
7- from sys import exit
7+ import sys
88import inquirer
99
10- version = "1.4.3 "
10+ version = "1.5.0 "
1111windll .kernel32 .SetConsoleTitleW (f"NN-Downloader | v{ version } " )
1212proxy_list = []
1313header = {"User-Agent" :f"nn-downloader/{ version } (by Official Husko on GitHub)" }
1414needed_folders = ["db" , "media" ]
15- database_list = ["e621" , "furbooru" , "rule34" ]
15+ database_list = ["e621" , "furbooru" , "rule34" , "e6ai" ]
1616unsafe_chars = ["/" , "\\ " , ":" , "*" , "?" , "\" " , "<" , ">" , "|" , "\0 " , "$" , "#" , "@" , "&" , "%" , "!" , "`" , "^" , "(" , ")" , "{" , "}" , "[" , "]" , "=" , "+" , "~" , "," , ";" ]
1717
18- DEBUG = True
18+ if sys .gettrace () is not None :
19+ DEBUG = True
20+ else :
21+ DEBUG = False
1922
2023if os .path .exists ("outdated" ):
2124 version_for_logo = colored (f"v{ version } " , "cyan" , attrs = ["blink" ])
3437
3538class Main ():
3639 def main_startup ():
40+
41+ print (colored ("Checking for read and write permissions." , "green" ))
42+
43+ # Check if the process has read and write permissions
44+ if os .access (os .getcwd (), os .R_OK | os .W_OK ):
45+ pass
46+ else :
47+ print (colored ("The program is missing read & write permissions! Change the directory or try run as administrator." , "red" ))
48+ sleep (300 )
49+ sys .exit (0 )
50+
3751 os .system ("cls" )
3852 print (logo )
3953 print ("" )
@@ -53,7 +67,7 @@ def main_startup():
5367 config = Config_Manager .creator ()
5468 print (colored ("New Config file generated. Please configure it for your use case and add API keys for needed services." , "green" ))
5569 sleep (7 )
56- exit (0 )
70+ sys . exit (0 )
5771
5872 if checkForUpdates == True :
5973 os .system ("cls" )
@@ -79,7 +93,7 @@ def main_startup():
7993 print (colored ("What site do you want to download from?" , "green" ))
8094 questions = [
8195 inquirer .List ('selection' ,
82- choices = ['E621' , 'E926' , 'Furbooru' , 'Luscious' , 'Multporn' , 'Rule34' , 'Yiffer' ]),
96+ choices = ['E621' , 'E6AI' , ' E926' , 'Furbooru' , 'Luscious' , 'Multporn' , 'Rule34' , 'Yiffer' ]),
8397 ]
8498 answers = inquirer .prompt (questions )
8599 print ("" )
@@ -113,6 +127,18 @@ def main_startup():
113127 else :
114128 output = E621 .Fetcher (user_tags = user_tags , user_blacklist = config ["blacklisted_tags" ], proxy_list = proxy_list , max_sites = max_sites , user_proxies = config ["proxies" ], apiUser = apiUser , apiKey = apiKey , header = header , db = database )
115129
130+ if site == "e6ai" :
131+ apiUser = config ["user_credentials" ]["e6ai" ]["apiUser" ]
132+ apiKey = config ["user_credentials" ]["e6ai" ]["apiKey" ]
133+ if oneTimeDownload == True :
134+ with open ("db/e6ai.db" , "r" ) as db_reader :
135+ database = db_reader .read ().splitlines ()
136+ if apiKey == "" or apiUser == "" :
137+ print (colored ("Please add your Api Key into the config.json" , "red" ))
138+ sleep (5 )
139+ else :
140+ output = E6AI .Fetcher (user_tags = user_tags , user_blacklist = config ["blacklisted_tags" ], proxy_list = proxy_list , max_sites = max_sites , user_proxies = config ["proxies" ], apiUser = apiUser , apiKey = apiKey , header = header , db = database )
141+
116142 elif site == "e926" :
117143 apiUser = config ["user_credentials" ]["e926" ]["apiUser" ]
118144 apiKey = config ["user_credentials" ]["e926" ]["apiKey" ]
@@ -203,4 +229,4 @@ def main_startup():
203229 except KeyboardInterrupt :
204230 print ("User Cancelled" )
205231 sleep (3 )
206- exit (0 )
232+ sys . exit (0 )
0 commit comments