added AGENTS.md
This commit is contained in:
@@ -31,9 +31,6 @@
|
||||
|
||||
|
||||
;;; projectile find file - quick switcher
|
||||
(after! evil
|
||||
(map! :gnv "C-e" #'projectile-find-file)
|
||||
)
|
||||
(after! 'better-jumper
|
||||
(map! :gnv "C-i" #'projectile-find-file)
|
||||
)
|
||||
@@ -158,7 +155,7 @@
|
||||
:config
|
||||
(emms-all) ;; Loads stable EMMS features
|
||||
(setq emms-source-file-default-directory "~/work/music/"
|
||||
emms-player-list '(emms-player-vlc))
|
||||
emms-player-list '(emms-player-mpv))
|
||||
)
|
||||
|
||||
;;; infrasonic
|
||||
@@ -166,72 +163,145 @@
|
||||
(defvar my-subsonic-client
|
||||
(infrasonic-make-client :url "tunes.c2vi.dev")
|
||||
)
|
||||
(defun my-play-playlist (playlist-id)
|
||||
"Fetch a Subsonic playlist by PLAYLIST-ID using infrasonic.el and load it into EMMS."
|
||||
(interactive "sEnter Subsonic Playlist ID: ")
|
||||
(message "Fetching Subsonic playlist %s..." playlist-id)
|
||||
(defun my-pick-song ()
|
||||
(interactive)
|
||||
(let* (
|
||||
(playlist (infrasonic-get-playlist my-subsonic-client "6ad5avelak6Lnu2yEbWwjj"))
|
||||
(entries (cdr (assoc 'entry playlist)))
|
||||
(candidates (list))
|
||||
(urls '())
|
||||
(void (dolist (song entries)
|
||||
(let* (
|
||||
(artist (cdr (assoc 'artist song)))
|
||||
(cropped-artist (truncate-string-to-width artist 50))
|
||||
(title (cdr (assoc 'title song)))
|
||||
(id (cdr (assoc 'id song)))
|
||||
(line (format "%-50s - %s" cropped-artist title))
|
||||
(stream-url (infrasonic-get-stream-url my-subsonic-client id))
|
||||
)
|
||||
(add-to-list 'candidates line)
|
||||
(push (cons line stream-url) urls)
|
||||
)
|
||||
))
|
||||
(completion-result (completing-read "Select track: " candidates))
|
||||
(url (cdr (assoc completion-result urls)))
|
||||
)
|
||||
(emms-play-url url)
|
||||
)
|
||||
)
|
||||
|
||||
(defun my-load-playlist ()
|
||||
(interactive)
|
||||
(emms-playlist-mode-go)
|
||||
(emms-playlist-clear)
|
||||
|
||||
(let* (
|
||||
(playlist-id "6I9sKLo2NfnyzdtShKwreO")
|
||||
(playlist-id "6ad5avelak6Lnu2yEbWwjj")
|
||||
(playlist (infrasonic-get-playlist
|
||||
my-subsonic-client
|
||||
playlist-id
|
||||
))
|
||||
(entries (cdr (assoc 'entry playlist)))
|
||||
(track-count 0)
|
||||
(void (dolist (track entries)
|
||||
(let* (
|
||||
(track-id (cdr (assoc 'id track)))
|
||||
(title (cdr (assoc 'title track)))
|
||||
(artist (cdr (assoc 'artist track)))
|
||||
(stream-url (infrasonic-get-stream-url my-subsonic-client track-id))
|
||||
(emmstrack (emms-track 'url stream-url))
|
||||
)
|
||||
;(message title)
|
||||
(emms-track-set emmstrack 'info-title title)
|
||||
(emms-track-set emmstrack 'info-artist artist)
|
||||
(funcall emms-playlist-insert-track-function emmstrack)
|
||||
)
|
||||
))
|
||||
)
|
||||
|
||||
(dolist (track entries)
|
||||
(let* (
|
||||
(track-id (cdr (assoc 'id track)))
|
||||
(stream-url (infrasonic-get-stream-url my-subsonic-client track-id))
|
||||
)
|
||||
;(emms-add-url stream-url)
|
||||
;(emms-add-track
|
||||
;(emms-track 'url stream-url))
|
||||
;(setq track-count (1+ track-count))
|
||||
;(emms-playlist-select-first)
|
||||
;(emms-start)
|
||||
)
|
||||
)
|
||||
entries
|
||||
(infrasonic-get-stream-url my-subsonic-client "7id7XzpofiHmnJPqfORA0O")
|
||||
)
|
||||
|
||||
(lambda (playlist-data)
|
||||
;; This callback executes on a successful API response
|
||||
(let*
|
||||
(
|
||||
|
||||
;; Ensure EMMS is ready and clear old queue if desired
|
||||
(emms-playlist-ensure-playlist-buffer)
|
||||
|
||||
;; 3. Loop through every track returned by the API
|
||||
(dolist (track entries)
|
||||
(let* ((track-id (plist-get track :id))
|
||||
;; Generate the authenticated streaming URL using infrasonic
|
||||
(stream-url (infrasonic-stream-url client track-id)))
|
||||
|
||||
;; 4. Insert the URL track directly into the EMMS track ecosystem
|
||||
(emms-add-track
|
||||
(emms-track 'url stream-url))
|
||||
(setq track-count (1+ track-count))))
|
||||
|
||||
(message "Successfully loaded %d tracks into EMMS from playlist!" track-count)
|
||||
|
||||
;; 5. Start playback immediately if nothing is playing
|
||||
(unless emms-player-playing-p
|
||||
(emms-playlist-select-first)
|
||||
(emms-start))))
|
||||
|
||||
;; Error callback handling
|
||||
(lambda (error-data)
|
||||
(error "Infrasonic playlist fetch failed: %S" error-data)))
|
||||
)
|
||||
(defun my-play-work () (interactive)(my-play-playlist "6I9sKLo2NfnyzdtShKwreO"))
|
||||
|
||||
|
||||
|
||||
;;; my finder
|
||||
(defun my/obsidian--extra-files ()
|
||||
"Return Markdown files from additional directories."
|
||||
(let ((directory "~/notes/reference"))
|
||||
(when (file-directory-p directory)
|
||||
(directory-files-recursively
|
||||
(expand-file-name directory)
|
||||
"\\.md\\'"))))
|
||||
|
||||
(defun my/obsidian--candidate-data ()
|
||||
"Return `(DISPLAY . FILE)' candidates for the Obsidian finder."
|
||||
(let (result)
|
||||
|
||||
;; Files known to obsidian.el.
|
||||
(maphash
|
||||
(lambda (file metadata)
|
||||
(let* ((tags (gethash 'tags metadata))
|
||||
(aliases (gethash 'aliases metadata))
|
||||
(title (file-name-base file))
|
||||
(display
|
||||
(concat
|
||||
title
|
||||
(when aliases
|
||||
(format " [%s]" (string-join aliases ", ")))
|
||||
(when tags
|
||||
(format " #%s"
|
||||
(string-join tags " #"))))))
|
||||
(push (cons display file) result)))
|
||||
obsidian-vault-cache)
|
||||
|
||||
;; Files in the additional directory.
|
||||
(dolist (file (my/obsidian--extra-files))
|
||||
(unless (assoc (file-name-base file) result)
|
||||
(push (cons (file-name-base file) file) result)))
|
||||
|
||||
result))
|
||||
|
||||
(defun my-switcher ()
|
||||
"Fuzzy-find all my stuff"
|
||||
(interactive)
|
||||
|
||||
;; Make sure obsidian.el's cache is current.
|
||||
;;(obsidian-update)
|
||||
|
||||
(let* ((data (my/obsidian--candidate-data))
|
||||
(candidates (mapcar #'car data))
|
||||
(choice
|
||||
(completing-read
|
||||
"things: "
|
||||
candidates
|
||||
nil
|
||||
nil ; allow a new/non-existing note
|
||||
nil
|
||||
nil
|
||||
nil)))
|
||||
|
||||
(if-let ((file (cdr (assoc choice data))))
|
||||
;; Existing note.
|
||||
(find-file file)
|
||||
|
||||
;; New note.
|
||||
(let ((file
|
||||
(expand-file-name
|
||||
(if (string-suffix-p ".md" choice)
|
||||
choice
|
||||
(concat choice ".md"))
|
||||
(expand-file-name obsidian-inbox-directory
|
||||
obsidian-directory))))
|
||||
(make-directory (file-name-directory file) t)
|
||||
(find-file file)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(after! evil
|
||||
(map! :gnv "C-e" #'my-switcher)
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
;;; scratch
|
||||
@@ -240,17 +310,8 @@
|
||||
(lookup-key corfu-map (kbd "C-i"))
|
||||
(define-key corfu-map (kbd "C-i") 'my/corfu-insert-first)
|
||||
|
||||
(plz 'get "https://tunes.c2vi.dev")
|
||||
(infrasonic-get-playlist
|
||||
my-subsonic-client
|
||||
"6I9sKLo2NfnyzdtShKwreO"
|
||||
)
|
||||
(infrasonic-ping my-subsonic-client)
|
||||
(infrasonic-api-call my-subsonic-client "ping" nil (lambda () (message "hi")) (lambda (e) (message e)))
|
||||
(shell-command-to-string "curl https://tunes.c2vi.dev")
|
||||
|
||||
(emms-play-url "https://tunes.c2vi.dev/rest/stream.view?u=c2vi&t=618e0d04594b0e72c865d7989b6dad38&s=5b08708ee057af16caab55db98c3dd03&v=1.16.1&c=infrasonic&f=json&id=7id7XzpofiHmnJPqfORA0O")
|
||||
|
||||
|
||||
(emms-insert-url "https://tunes.c2vi.dev/rest/stream.view?u=c2vi&t=59248d02914f93abee797adcf0f14d6a&s=8a3988f950895ee7bd87e17651e65eb1&v=1.16.1&c=infrasonic&f=json&id=0FnN5Sb3mCItKdIiJZcG7x")
|
||||
(message emms-playlist-buffer)
|
||||
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user