summaryrefslogtreecommitdiffhomepage
path: root/attic/elisp/misc.el
diff options
context:
space:
mode:
Diffstat (limited to 'attic/elisp/misc.el')
-rw-r--r--attic/elisp/misc.el20
1 files changed, 20 insertions, 0 deletions
diff --git a/attic/elisp/misc.el b/attic/elisp/misc.el
index 534c38a..dc3a76c 100644
--- a/attic/elisp/misc.el
+++ b/attic/elisp/misc.el
@@ -776,6 +776,26 @@
(enwc-display-mode-line nil)))
+;;; tidal/mpc
+(defconst jao-mpc--search-cmd
+ "-f '%%album%% - %%artist%% :::%%file%%' search %s '%s'|grep :::tidal:album")
+
+(defun jao-mpc--search-albums (query)
+ (let* ((cmd (format jao-mpc--search-cmd "any" query))
+ (str (jao-mpc--cmd cmd))
+ (res (split-string str "\n" t)))
+ (message "%s" str)
+ (mapcar (lambda (s) (split-string s ":::" t " ")) res)))
+
+(defun jao-mpc-select-tidal-album (&optional query port)
+ (interactive "sSearch terms: ")
+ (let* ((jao-mpc-port (or port jao-mpc-port))
+ (resa (jao-mpc--search-albums query)))
+ (if (null resa)
+ (user-error "No results")
+ (when-let* ((a (completing-read "Play album: " resa nil t))
+ (s (car (alist-get a resa nil nil 'string=))))
+ (jao-mpc--add-and-play s port t)))))
;;; snippets
(defun jao-sway-run-or-focus-tidal ()
(interactive)