~amk/subsonic.el

b017f0b7ca7de08dfcfb98f10844075cb382fe14 — Alex McGrath 4 months ago 9764405
Require user set subsonic-host to find the correct authinfo more accuratly
2 files changed, 17 insertions(+), 9 deletions(-)

M README.md
M subsonic.el
M README.md => README.md +7 -4
@@ 8,10 8,10 @@ This is a subsonic client for emacs using mpv for music playing.

Add a `~/.authinfo.gpg` or `~/.authinfo` file with the following contents

    machine SUBSONIC_URL login USERNAME password PASSWORD port subsonic
    machine SUBSONIC_URL login USERNAME password PASSWORD

The `port` section here is used to identify the line as a subsonic
server must be `subsonic`
The `subsonic-host` must be set to the same value as SUBSONIC_URL in
your init file, example below.

## Usage



@@ 24,12 24,15 @@ Example use-package config:
  :commands subsonic
  :bind (("C-c m" . subsonic))
  :custom
  (subsonic-url "coolsubsonic.example.com")
  (subsonic-enable-art t))
```

Use the `subsonic` command to open a transient with commonly used
commands available
commands available.

- `subsonic-host` to the domain of the subsonic server, used to find
  the correct authinfo entry
- `subsonic-enable-art` to `t` to enable album art
- `subsonic-mpv-default-volume` to set default mpv volume


M subsonic.el => subsonic.el +10 -5
@@ 25,9 25,7 @@
;; uses mpv for playing the actual music.  Use a ~/.authinfo.gpg file with
;; contents like the following to setup auth
;;
;; machine SUBSONIC_URL login USERNAME password PASSWORD port subsonic
;;
;; port is required to be 'subsonic' for this to work
;; machine SUBSONIC_HOST login USERNAME password PASSWORD

;;; Code:
(require 'json)


@@ 45,6 43,12 @@
  :prefix "subsonic-"
  :group 'external)

(defcustom subsonic-host ""
  "Hostname for the subsonic service.
Used to find the correct authinfo entry."
  :type 'string
  :group 'subsonic)

(defcustom subsonic-mpv (executable-find "mpv")
  "Path to the mpv executable."
  :type 'string


@@ 123,7 127,7 @@ this case usually track lists"
     (lambda (_proc _string)))
    t))

(defvar subsonic-auth (let ((auth (auth-source-search :port "subsonic")))
(defvar subsonic-auth (let ((auth (auth-source-search :host subsonic-host)))
                        (when auth
                          (car auth))))



@@ 196,7 200,8 @@ EXTRA-QUERY is used for any extra query parameters"
                                               ("v" . "1.16.0")
                                               ("f" . "json"))
                                             extra-query)))
    (error "Failed to load .authinfo, please provide auth configuration for subsonic")))
    (error "Failed to load .authinfo, please provide auth configuration for
subsonic, and ensure subsonic-host is set correctly")))

(defun subsonic-mpv-command (&rest args)
  "Generate a mpv ipc command using ARGS."