From dd0342685d6c10149298e91f4569c8458717db81 Mon Sep 17 00:00:00 2001 From: stardiviner Date: Sun, 4 Jun 2023 19:18:21 +0800 Subject: [PATCH] Fix process downloaded 100% finished logic --- youtube-dl.el | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/youtube-dl.el b/youtube-dl.el index 0c2e156..9a04acf 100644 --- a/youtube-dl.el +++ b/youtube-dl.el @@ -402,25 +402,27 @@ $ youtube-dl --get-filename " ((stringp item-log-end) item-log-end) ((listp item-log-end) (car (last item-log-end))))) (error-hander (lambda () (setf (youtube-dl-item-running item) nil) - (message "[youtube-dl] ERROR: , destination: %s" + (message "[youtube-dl] ✖ , destination: %s" (youtube-dl-item-process item) (youtube-dl-item-destination item)))) (running-handler (lambda () (setf (youtube-dl-item-running item) t))) - (finished-handler (lambda () (setf (youtube-dl-item-running item) nil)))) + (finished-handler (lambda () (setf (youtube-dl-item-running item) nil) + (message "[youtube-dl] ✔ %s downloaded." (youtube-dl-item-destination item))))) (when (stringp log-end-str) (cond + ;; progress finished when percentage is 100%. + ((or (string-equal (youtube-dl-item-percentage item) "100%") + (string-match "\\[download\\]\\ *100%.*" log-end-str)) ; ".*100%.*" + (funcall finished-handler)) ;; process exited abnormally with code 1 ((string-match "exited abnormally with code 1" log-end-str) (funcall error-hander)) ;; file already downloaded ((string-match "ERROR: Fixed output name but more than one file to download:.*" log-end-str) - (funcall error-hander) + ;; (funcall error-hander) (message "[youtube-dl] ERROR: Already has existing downloading process or output file! (%s)" (youtube-dl-item-destination item))) ;; any other errors ((string-match "ERROR:.*" log-end-str) (funcall error-hander)) - ;; progress finished when percentage is 100%. - ((string-equal (youtube-dl-item-percentage item) "100%") - (funcall finished-handler)) (t (funcall running-handler))))) ;; DEBUG: ;; (message "[DEBUG] [youtube-dl] destination/title: %s" destination) -- 2.11.4.GIT