|
|
@@ -110,8 +110,8 @@
|
|
|
|
|
|
(defun get-import-notify (info)
|
|
|
(labels ((f (fl) (getf info fl)))
|
|
|
- (format nil "[[🎶]] Importing *~a*, ~a tracks in ~a albums. Total size ~a"
|
|
|
- (f :name) (f :wanted-files) (length (f :media-dirs)) (format-size (f :total-wanted)))))
|
|
|
+ (format nil "[[🎶]] Добавляем *~a*, ~a альбомов с ~a треками. Весит ~a"
|
|
|
+ (f :name) (length (f :media-dirs)) (f :wanted-files) (format-size (f :total-wanted)))))
|
|
|
|
|
|
(defun get-root-paths (info)
|
|
|
(let ((roots (delete-duplicates (loop for dir in (getf info :media-dirs)
|
|
|
@@ -132,8 +132,8 @@
|
|
|
(uiop:run-program cmd))))
|
|
|
|
|
|
(defun deluge-get-seeding-torrents ()
|
|
|
- (loop for (torrent state) on (deluge-get-torrents-status '(:|state| "Seeding") '("name" "total_wanted")) by #'cddr
|
|
|
- collect (list (string torrent) (getf state :|name|) (getf state :|total_wanted|)))
|
|
|
+ (loop for (torrent state) on (deluge-get-torrents-status '(:|state| "Seeding") '("name")) by #'cddr
|
|
|
+ collect (cons (string torrent) (getf state :|name|))))
|
|
|
|
|
|
(defun deluge-pause-torrents (&rest torrents)
|
|
|
(deluge-request "core.pause_torrent" (list torrents)))
|
|
|
@@ -168,9 +168,12 @@
|
|
|
|
|
|
(defun process-imports ()
|
|
|
(loop
|
|
|
- (loop for (ih name size) in (deluge-get-seeding-torrents)
|
|
|
- do (handler-case (process-downloaded ih)
|
|
|
- (error (e) (log:error "Error processing torrent" name e))))
|
|
|
+ (handler-bind
|
|
|
+ ((sb-int:broken-pipe #'(lambda (c) (declare (ignorable c))
|
|
|
+ (invoke-restart (find-restart 'dexador:retry-request))))
|
|
|
+ (error #'(lambda (c) (log:error "Error processing torrent" c))))
|
|
|
+ (loop for (ih . name) in (deluge-get-seeding-torrents)
|
|
|
+ do (process-downloaded ih)))
|
|
|
(sleep 1)))
|
|
|
|
|
|
(defvar *watcher* nil "Importer thread ")
|
|
|
@@ -188,9 +191,18 @@
|
|
|
(defun handle-set-watch (enable)
|
|
|
(lists-set-entry :music-watch *chat-id* enable)
|
|
|
(ensure-watcher)
|
|
|
- (bot-send-message (if enable "[[🎶]] Импортим музло" "[[🎶]] Пусть мешки парятся")))
|
|
|
-
|
|
|
-(defun handle-status ())
|
|
|
+ (bot-send-message (if enable "[🎶] Импортим музло" "[🎶] Пусть мешки парятся")))
|
|
|
+
|
|
|
+(defun handle-status ()
|
|
|
+ (let ((stats (loop
|
|
|
+ for (torrent status) on (deluge-get-torrents-status nil '("state" "name" "total_wanted")) by #'cddr
|
|
|
+ for state = (getf status :|state|)
|
|
|
+ when (equal state "Downloading") counting t into down
|
|
|
+ when (equal state "Seeding") counting t into seed
|
|
|
+ summing (getf status :|total_wanted|) into size
|
|
|
+ finally (return (list :down down :seed seed :size size)))))
|
|
|
+ (bot-send-message (format nil "[[🎶]] Осталось скачать ~a, заимпортить ~a торрентов, общий объём ~a" (getf stats :down) (getf stats :seed) (format-size (getf stats :size)))
|
|
|
+ :parse-mode "markdown")))
|
|
|
|
|
|
(def-message-cmd-handler handle-cmd-music (:music)
|
|
|
(cond
|