77from sys import exit
88import inquirer
99
10- version = "1.4.1 "
10+ version = "1.4.2 "
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.db" ]
15+ database_list = ["e621" , "furbooru" , "rule34" ]
16+ unsafe_chars = ["/" , "\\ " , ":" , "*" , "?" , "\" " , "<" , ">" , "|" , "\0 " , "$" , "#" , "@" , "&" , "%" , "!" , "`" , "^" , "(" , ")" , "{" , "}" , "[" , "]" , "=" , "+" , "~" , "," , ";" ]
1617
1718if os .path .exists ("outdated" ):
1819 version_for_logo = colored (f"v{ version } " , "cyan" , attrs = ["blink" ])
@@ -70,13 +71,13 @@ def main_startup():
7071
7172 if oneTimeDownload == True :
7273 for database in database_list :
73- with open (f"db/{ database } " , "a" ) as db_creator :
74+ with open (f"db/{ database } .db " , "a" ) as db_creator :
7475 db_creator .close ()
7576
7677 print (colored ("What site do you want to download from?" , "green" ))
7778 questions = [
7879 inquirer .List ('selection' ,
79- choices = ['E621' , 'E926' , 'Furbooru' , 'Multporn' , 'Rule34' , 'Yiffer' ]), #choices=['E621', 'E926', 'Furbooru', ' Luscious', 'Multporn', 'Rule34', 'Yiffer']),
80+ choices = ['E621' , 'E926' , 'Furbooru' , 'Luscious' , 'Multporn' , 'Rule34' , 'Yiffer' ]),
8081 ]
8182 answers = inquirer .prompt (questions )
8283 print ("" )
@@ -108,7 +109,8 @@ def main_startup():
108109 print (colored ("Please add your Api Key into the config.json" , "red" ))
109110 sleep (5 )
110111 else :
111- 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 )
112+ 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 )
113+
112114 elif site == "e926" :
113115 apiUser = config ["user_credentials" ]["e926" ]["apiUser" ]
114116 apiKey = config ["user_credentials" ]["e926" ]["apiKey" ]
@@ -119,44 +121,76 @@ def main_startup():
119121 print (colored ("Please add your Api Key into the config.json" , "red" ))
120122 sleep (5 )
121123 else :
122- E926 .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 )
124+ output = E926 .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 )
125+
123126 elif site == "rule34" :
124- RULE34 .Fetcher (user_tags = user_tags , user_blacklist = config ["blacklisted_tags" ], proxy_list = proxy_list , max_sites = max_sites , user_proxies = config ["proxies" ], header = header )
127+ if oneTimeDownload == True :
128+ with open ("db/rule34.db" , "r" ) as db_reader :
129+ database = db_reader .read ().splitlines ()
130+ output = RULE34 .Fetcher (user_tags = user_tags , user_blacklist = config ["blacklisted_tags" ], proxy_list = proxy_list , max_sites = max_sites , user_proxies = config ["proxies" ], header = header , db = database )
131+
125132 elif site == "furbooru" :
126133 apiKey = config ["user_credentials" ]["furbooru" ]["apiKey" ]
134+ if oneTimeDownload == True :
135+ with open ("db/furbooru.db" , "r" ) as db_reader :
136+ database = db_reader .read ().splitlines ()
127137 if apiKey == "" :
128138 print (colored ("Please add your Api Key into the config.json" , "red" ))
129139 sleep (5 )
130140 else :
131- FURBOORU .Fetcher (user_tags = user_tags , user_blacklist = config ["blacklisted_tags" ], proxy_list = proxy_list , max_sites = max_sites , user_proxies = config ["proxies" ], apiKey = apiKey , header = header )
141+ output = FURBOORU .Fetcher (user_tags = user_tags , user_blacklist = config ["blacklisted_tags" ], proxy_list = proxy_list , max_sites = max_sites , user_proxies = config ["proxies" ], apiKey = apiKey , header = header , db = database )
142+
132143 elif site == "multporn" :
133144 print (colored ("Please enter the link. (e.g. https://multporn.net/comics/double_trouble_18)" , "green" ))
134145 URL = input (">> " )
135146 while URL == "" :
136147 print (colored ("Please enter a valid link." , "red" ))
137148 sleep (1.5 )
138149 URL = input (">> " )
139- Multporn .Fetcher (proxy_list = proxy_list , user_proxies = config ["proxies" ], header = header , URL = URL )
150+ output = Multporn .Fetcher (proxy_list = proxy_list , user_proxies = config ["proxies" ], header = header , URL = URL )
151+
140152 elif site == "yiffer" :
141153 print (colored ("Please enter the link. (e.g. https://yiffer.xyz/Howl & Jasper)" , "green" ))
142154 URL = input (">> " )
143155 while URL == "" :
144156 print (colored ("Please enter a valid link." , "red" ))
145157 sleep (1.5 )
146158 URL = input (">> " )
147- Yiffer .Fetcher (proxy_list = proxy_list , user_proxies = config ["proxies" ], header = header , URL = URL )
159+ output = Yiffer .Fetcher (proxy_list = proxy_list , user_proxies = config ["proxies" ], header = header , URL = URL )
160+
148161 elif site == "luscious" :
149162 print (colored ("Please enter the link. (e.g. https://www.luscious.net/albums/bifurcation-ongoing_437722)" , "green" ))
150163 URL = input (">> " )
151164 while URL == "" :
152165 print (colored ("Please enter a valid link." , "red" ))
153166 sleep (1.5 )
154167 URL = input (">> " )
155- Luscious .Fetcher (proxy_list = proxy_list , user_proxies = config ["proxies" ], header = header , URL = URL )
168+ output = Luscious .Fetcher (proxy_list = proxy_list , user_proxies = config ["proxies" ], header = header , URL = URL )
169+
170+ else :
171+ print (colored ("Site not supported. Open a ticket to request support for that site!" , "red" ))
172+ raise Exception (f"This shouldn't be possible! User tried to download from { site } ." )
173+ Main .main_startup ()
174+
175+ status = output .get ("status" , "why no status man?" )
176+ uinput = output .get ("uinput" , "URL overdosed :(" )
177+ exception_str = output .get ("exception" , "Fuck me there was no exception." )
178+ extra = output .get ("extra" , "" )
179+
180+ if status == "ok" :
181+ pass
156182
183+ elif status == "error" :
184+ print (f"{ error } An error occured while downloading from { colored (site , 'yellow' )} ! Please report this. Exception: { colored (exception_str , 'red' )} " )
185+ error_str = f"An error occured while downloading from { site } ! Please report this. Exception: { exception_str } "
186+ Logger .log_event (error_str , extra , uinput )
187+ sleep (7 )
157188
158189 else :
159- print (colored ("Site not supported. Open a ticket to request support for that site!" , "red" ))
190+ print (f"{ major_error } An unknown error occured while downloading from { colored (site , 'yellow' )} ! Please report this. Exception: { colored (exception_str , 'red' )} " )
191+ error_str = f"An unknown error occured while downloading from { site } ! Please report this. Exception: { exception_str } "
192+ Logger .log_event (error_str , extra , uinput )
193+ sleep (7 )
160194
161195 # Jump back to start
162196 Main .main_startup ()
@@ -168,9 +202,3 @@ def main_startup():
168202 print ("User Cancelled" )
169203 sleep (3 )
170204 exit (0 )
171-
172-
173- """
174- TODO: fix luscious being broken
175-
176- """
0 commit comments