summaryrefslogtreecommitdiffhomepage
path: root/media
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-01-12 21:16:54 +0000
committerjao <jao@gnu.org>2021-01-12 21:16:54 +0000
commit0ff0270717b428de630b5dd6819ea2e3dbab3d95 (patch)
treebdb6a2942bba82f9c56555128cfa4e4af426d940 /media
parent60e74a345c7ff8ca2ecfdf2c706b4e643c3ee499 (diff)
downloadelibs-0ff0270717b428de630b5dd6819ea2e3dbab3d95.tar.gz
elibs-0ff0270717b428de630b5dd6819ea2e3dbab3d95.tar.bz2
espotify: richer marginalia
Diffstat (limited to 'media')
-rw-r--r--media/espotify.org14
1 files changed, 12 insertions, 2 deletions
diff --git a/media/espotify.org b/media/espotify.org
index 7b22cc0..6f001fd 100644
--- a/media/espotify.org
+++ b/media/espotify.org
@@ -311,7 +311,11 @@ Let's start with an umbrella customization group:
#+begin_src emacs-lisp
(defun espotify--format-item (x)
- (propertize (format "%s" (alist-get 'name x)) 'espotify-item x))
+ (propertize (format "%s%s"
+ (alist-get 'name x)
+ (if-let ((a (alist-get 'album x)))
+ (format " (%s)" (alist-get 'name a))))
+ 'espotify-item x))
(defun espotify--item (cand)
(get-text-property 0 'espotify-item cand))
@@ -379,11 +383,17 @@ Let's start with an umbrella customization group:
(when-let (x (espotify--item cand))
(marginalia--fields
((alist-get 'type x "") :face 'marginalia-mode :width 10)
+ ((if-let (d (alist-get 'duration_ms x))
+ (let ((secs (/ d 1000)))
+ (format "%02d:%02d" (/ secs 60) (mod secs 60)))
+ ""))
((or (alist-get 'name (car (alist-get 'artists x))) "")
:face 'marginalia-file-name :width 50)
((if-let (d (alist-get 'total_tracks x)) (format "%s tracks" d) "")
:face 'marginalia-size :width 12)
- ((if-let (d (alist-get 'release_date x)) (format "%s" d) "")
+ ((if-let (d (alist-get 'release_date (alist-get 'album x x)))
+ (format "%s" d)
+ "")
:face 'marginalia-modified :width 10))))
(add-to-list 'marginalia-annotators-heavy