@@ -97,37 +97,9 @@ def worker(self):
9797 job .status = Job .FAILED
9898 job .log = "Error during download task:\n {}:\n \t {}" .format (type (e ).__name__ , str (e ))
9999 print ("Error during download task:\n {}:\n \t {}" .format (type (e ).__name__ , str (e )))
100- elif job .type == JobType .YDL_UPDATE :
101- rc , log = self .update ()
102- job .log = Job .clean_logs (log )
103- job .status = Job .COMPLETED if rc == 0 else Job .FAILED
104100 self .jobshandler .put ((Actions .UPDATE , job ))
105101 self .queue .task_done ()
106102
107- def update (self ):
108- if self .app_config ["ydl_server" ].get ("no_updates" , False ):
109- return 0 , ""
110- print (f"Updating: Current { self .ydl_module_name } version: { self .ydl_version } " )
111- if os .environ .get ("YDL_PYTHONPATH" ):
112- command = [
113- "pip" ,
114- "install" ,
115- "--no-cache-dir" ,
116- "-t" ,
117- os .environ .get ("YDL_PYTHONPATH" ),
118- "--upgrade" ,
119- self .ydl_module_name ,
120- ]
121- else :
122- command = ["pip" , "install" , "--no-cache-dir" , "--upgrade" , self .ydl_module_name ]
123- proc = subprocess .Popen (command , stdout = subprocess .PIPE , stderr = subprocess .STDOUT )
124- out , err = proc .communicate ()
125- if proc .wait () == 0 :
126- self .app_config ["ydl_last_update" ] = datetime .now ()
127- self .import_ydl_module ()
128- print (f"Updating: New { self .ydl_module_name } version: { self .ydl_version } " )
129- return proc .returncode , str (out .decode ("utf-8" ))
130-
131103 def get_ydl_options (self , ydl_config , request_options ):
132104 ydl_config = ydl_config .copy ()
133105 req_format = request_options .get ("format" )
@@ -212,19 +184,16 @@ def resume_pending(self):
212184 jobs = db .get_all (self .app_config ["ydl_server" ].get ("max_log_entries" , 100 ))
213185 not_endeds = [job for job in jobs if job ["status" ] == "Pending" or job ["status" ] == "Running" ]
214186 for pending in not_endeds :
215- if int (pending ["type" ]) == JobType .YDL_UPDATE :
216- self .jobshandler .put ((Actions .SET_STATUS , (pending ["id" ], Job .FAILED )))
217- else :
218- job = Job (
219- pending ["name" ],
220- Job .PENDING ,
221- "Queue stopped" ,
222- int (pending ["type" ]),
223- pending ["format" ],
224- pending ["url" ],
225- )
226- job .id = pending ["id" ]
227- self .jobshandler .put ((Actions .RESUME , job ))
187+ job = Job (
188+ pending ["name" ],
189+ Job .PENDING ,
190+ "Queue stopped" ,
191+ int (pending ["type" ]),
192+ pending ["format" ],
193+ pending ["url" ],
194+ )
195+ job .id = pending ["id" ]
196+ self .jobshandler .put ((Actions .RESUME , job ))
228197
229198 def join (self ):
230199 if self .thread is not None :
0 commit comments