1616class Consts :
1717 CYELLOW , CGREEN , CBLUE , SBOLD , ENDL = "\033 [93m" , "\033 [92m" , "\033 [94m" , "\033 [1m" , "\033 [0m"
1818 DERROR_EXC = '{"output_code":"exception","exc_trace":"vars.downloadError"}'
19- SET_COOKIE = "echo 'document.cookie = \" installed=1; expires=Thu, 1 Jan 2026 12:00:00 UTC; sameSite=Lax\" ;' | jsi"
2019
2120
2221class SW_DLT :
@@ -61,21 +60,23 @@ def __init__(self, file_id, *args):
6160
6261 @staticmethod
6362 def update_check ():
63+ current_time = datetime .datetime .today ()
6464 show_progress ("util" , 0 , 2 )
6565 if not os .path .exists (f"{ os .environ ['HOME' ]} /Library/Cookies/Cookies.binarycookies" ):
66- subprocess .run (Consts .SET_COOKIE )
66+ cookie_expiration = current_time .replace (year = current_time .year + 1 )
67+ set_cookie = f"echo 'document.cookie = \" installed=1; expires={ cookie_expiration .strftime ('%a, %#d %b %Y %H:%M:%S UTC' )} ; sameSite=Lax\" ;' | jsi"
68+ subprocess .run (set_cookie )
6769
6870 #We need to wait for delay in jsi command
6971 while not os .path .exists (f"{ os .environ ['HOME' ]} /Library/Cookies/Cookies.binarycookies" ):
7072 subprocess .run ("sleep 1" )
7173
7274 show_progress ("util" , 1 , 2 )
73- current_time = int (datetime .datetime .today ().timestamp ())
7475
7576 with open (f"{ os .environ ['HOME' ]} /Documents/SW-DLT/shortcut_update_ts.txt" , 'r' ) as ts_file :
7677 last_check = int (ts_file .read ())
7778
78- if current_time - last_check < 600 :
79+ if int ( current_time . timestamp ()) - last_check < 600 :
7980 subprocess .run ("pip install chardet requests certifi mutagen -q --disable-pip-version-check --upgrade" )
8081 subprocess .run ("pip install yt-dlp yt-dlp-ejs yt-dlp-apple-webkit-jsi gallery-dl -q --disable-pip-version-check --upgrade" )
8182 #yt-dlp is reloaded here to avoid issues after updates
@@ -153,12 +154,11 @@ def gallery_download(self):
153154 show_progress ("manual" , 1 , 1 )
154155
155156 files = os .listdir (self .file_id )
156- # No files returned, removes temp folder and raises Exception
157+ # No files returned, raises Exception
157158 if len (files ) == 0 :
158- shutil .rmtree (self .file_id , True )
159159 raise OSError ()
160160
161- # Single item, removes temp folder and directly outputs the item
161+ # Single item, directly outputs the item
162162 elif len (files ) < 2 :
163163 file = "{0}/{1}" .format (self .file_id , files [0 ])
164164 output = {
@@ -167,10 +167,9 @@ def gallery_download(self):
167167 "file_title" : self .date_id
168168 }
169169
170- # Mutiple items, zips temp folder and returns it, removes temp folder
170+ # Mutiple items, zips temp folder and returns it
171171 else :
172172 shutil .make_archive (self .file_id , "zip" , self .file_id )
173- shutil .rmtree (self .file_id , True )
174173 output = {
175174 "output_code" : "success" ,
176175 "file_name" : os .path .abspath (self .file_id + ".zip" ),
0 commit comments