thomas-louvigne / playerctl.el

Play music from emacs with playerctl
Other
15 stars 7 forks source link

Add function to probe metadata #7

Closed robertodr closed 2 years ago

robertodr commented 2 years ago

I've tested this version locally:

(defun playerctl-metadata ()
  "Get metadata from playerctl player."
  (interactive)
  (let ((proc (start-process "playerctl.el" "*playerctl*" "playerctl" "metadata" "--format" "{{ playerName }} {{ lc(status) }}: {{ artist }} - {{ album }} - {{ title }}")))
    (set-process-filter proc (lambda
                               (proc line)
                               (message line))))
  )

Some players (e.g. web radios playing in the browser) return all info in the title field, so the output is a bit weird, e.g. playerName playing: - - artist - album - title. I don't know elisp enough to prettify the output in that case: one would remove the {{ artist }} - {{ album }} - bit in case they're empty. I just don't know how to do that properly 😸

thomas-louvigne commented 2 years ago

Cool feature ! Can you also update the readme ?