@@ -144,14 +144,10 @@ def real_discount():
144144 r = requests .get (url )
145145 soup = bs (r .content , "html5lib" )
146146 try :
147- link = soup .select_one (
148- "#panel > div:nth-child(4) > div:nth-child(1) > div.col-lg-7.col-md-12.col-sm-12.col-xs-12 > a"
149- )["href" ]
150- if link .startswith ("https://www.udemy.com" ):
151- rd_links .append (title + "|:|" + link )
147+ link = soup .select_one ("a[href^='https://www.udemy.com']" )["href" ]
148+ rd_links .append (title + "|:|" + link )
152149 except :
153150 pass
154-
155151 main_window ["pReal Discount" ].update (0 , visible = False )
156152 main_window ["iReal Discount" ].update (visible = True )
157153
@@ -162,7 +158,7 @@ def coursevania():
162158 cv_links = []
163159 r = requests .get ("https://coursevania.com/courses/" )
164160 soup = bs (r .content , "html5lib" )
165- nonce = soup .find_all ("script" )[22 ].text [30 :]
161+ nonce = soup .find_all ("script" )[20 ].text [30 :]
166162 nonce = json .loads (nonce [: len (nonce ) - 6 ])["load_content" ]
167163 r = requests .get (
168164 "https://coursevania.com/wp-admin/admin-ajax.php?&template=courses/grid&args={%22posts_per_page%22:%2230%22}&action=stm_lms_load_content&nonce="
@@ -217,7 +213,7 @@ def idcoupons():
217213
218214########################### Constants
219215
220- version = "v1.0 "
216+ version = "v1.1 "
221217
222218
223219def create_scrape_obj ():
@@ -246,12 +242,6 @@ def cookiejar(
246242 return cookies
247243
248244
249- def save_settings (settings ):
250- if True :
251- with open ("duce-gui-settings.json" , "w" ) as f :
252- json .dump (settings , f , indent = 4 )
253-
254-
255245def load_settings ():
256246 try :
257247 os .rename ("duce-settings.json" , "duce-gui-settings.json" )
@@ -261,30 +251,28 @@ def load_settings():
261251 with open ("duce-gui-settings.json" ) as f :
262252 settings = json .load (f )
263253 except FileNotFoundError :
264- settings = requests .get (
265- "https://raw.githubusercontent.com/techtanic/Discounted-Udemy-Course-Enroller/master/duce-gui-settings.json"
266- ).json ()
254+ settings = dict (
255+ requests .get (
256+ "https://raw.githubusercontent.com/techtanic/Discounted-Udemy-Course-Enroller/master/duce-gui-settings.json"
257+ ).json ()
258+ )
267259
268260 title_exclude = "\n " .join (settings ["title_exclude" ])
269261 instructor_exclude = "\n " .join (settings ["instructor_exclude" ])
270262
271- try : # v4.3
272- del settings ["access_token" ]
273- del settings ["client_id" ]
274- settings ["email" ] = ""
275- settings ["password" ] = ""
276- except :
277- pass
278- try : # v4.3
279- settings ["stay_logged_in" ]["cookie" ]
280- del settings ["stay_logged_in" ]["cookie" ]
281- settings ["stay_logged_in" ]["manual" ] = False
282- except :
283- pass
284- save_settings (settings )
263+ try :
264+ settings ["languages" ]["Russian" ]
265+ except KeyError :
266+ settings ["languages" ]["Russian" ] = True
267+
285268 return settings , instructor_exclude , title_exclude
286269
287270
271+ def save_settings ():
272+ with open ("duce-gui-settings.json" , "w" ) as f :
273+ json .dump (settings , f , indent = 4 )
274+
275+
288276def fetch_cookies ():
289277 cookies = browser_cookie3 .load (domain_name = "www.udemy.com" )
290278 return requests .utils .dict_from_cookiejar (cookies ), cookies
@@ -775,7 +763,7 @@ def main1():
775763 my_cookies ["csrftoken" ],
776764 )
777765 settings ["stay_logged_in" ]["auto" ] = values ["sli_a" ]
778- save_settings (settings )
766+ save_settings ()
779767 login_window .close ()
780768 break
781769
@@ -822,7 +810,7 @@ def main1():
822810 client_id , access_token , csrf_token
823811 )
824812 settings ["stay_logged_in" ]["manual" ] = values ["sli_m" ]
825- save_settings (settings )
813+ save_settings ()
826814 login_window .close ()
827815 break
828816 else :
@@ -1138,7 +1126,7 @@ def main1():
11381126 False ,
11391127 False ,
11401128 )
1141- save_settings (settings )
1129+ save_settings ()
11421130 break
11431131
11441132 elif event == "Support" :
@@ -1163,7 +1151,7 @@ def main1():
11631151 filter (None , values ["title_exclude" ].split ("\n " ))
11641152 )
11651153 settings ["min_rating" ] = float (values ["min_rating" ])
1166- save_settings (settings )
1154+ save_settings ()
11671155
11681156 all_functions = create_scrape_obj ()
11691157 funcs = {}
0 commit comments