emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/listen 9ce822e09c 059/103: Add: basic library view


From: ELPA Syncer
Subject: [elpa] externals/listen 9ce822e09c 059/103: Add: basic library view
Date: Mon, 26 Feb 2024 12:59:29 -0500 (EST)

branch: externals/listen
commit 9ce822e09c52b33a1516390155c052ab3ced2a2e
Author: Adam Porter <adam@alphapapa.net>
Commit: Adam Porter <adam@alphapapa.net>

    Add: basic library view
---
 listen-lib.el     |  3 ++
 listen-library.el | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 listen-queue.el   |  1 +
 listen.el         |  2 +-
 4 files changed, 90 insertions(+), 1 deletion(-)

diff --git a/listen-lib.el b/listen-lib.el
index b9a12d0d3c..9b7a6cf8d8 100644
--- a/listen-lib.el
+++ b/listen-lib.el
@@ -37,6 +37,9 @@
 (cl-defstruct listen-track
   filename artist title album number genre length date rating etc)
 
+(cl-defmethod cl-print-object ((track listen-track) stream)
+  (princ (listen-track-filename track) stream))
+
 ;;;; Variables
 
 (defvar listen-player nil)
diff --git a/listen-library.el b/listen-library.el
new file mode 100644
index 0000000000..6873a9cfe6
--- /dev/null
+++ b/listen-library.el
@@ -0,0 +1,85 @@
+;;; listen-library.el --- Music library              -*- lexical-binding: t; 
-*-
+
+;; Copyright (C) 2024  Adam Porter
+
+;; Author: Adam Porter <adam@alphapapa.net>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This implements a basic "library" view based on `taxy' and
+;; `taxy-magit-section'.
+
+;; TODO: Commands to add tracks to queues from this view.
+;; TODO: Commands to view a queue's files in library view.
+
+;;; Code:
+
+(require 'taxy)
+(require 'taxy-magit-section)
+
+(require 'listen-lib)
+(require 'listen-queue)
+
+(defvar listen-library-taxy
+  (cl-labels ((genre (track)
+                (or (listen-track-genre track) "[unknown genre]"))
+              (date (track)
+                (or (listen-track-date track) "[unknown date]"))
+              (artist (track)
+                (or (listen-track-artist track) "[unknown artist]"))
+              (album (track)
+                (or (listen-track-album track) "[unknown album]"))
+              (title (track)
+                (or (listen-track-title track) "[unknown title]"))
+              (number (track)
+                (or (listen-track-number track) ""))
+              (track-string (track)
+                (concat (pcase (number track)
+                          ("" "")
+                          (else (format "%s: " else)))
+                        (title track)))
+              (make-fn (&rest args)
+                (apply #'make-taxy-magit-section
+                       :make #'make-fn
+                       :format-fn #'cl-prin1-to-string
+                       args)))
+    (make-fn
+     :name "Listen-Library"
+     :taxys (list (make-fn
+                   :name "Genres"
+                   :take (apply-partially #'taxy-take-keyed
+                                          (list #'genre #'artist #'date 
#'album #'track-string)))))))
+
+;;;###autoload
+(defun listen-library (paths)
+  "Show a library view of PATHS.
+PATHS is a list of paths to files and/or directories."
+  (interactive (list (list (read-file-name "View library for: "))))
+  (let* ((filenames (cl-loop for path in paths
+                             if (file-directory-p path)
+                             append (directory-files-recursively path "." t)
+                             else collect path))
+         (tracks (remq nil (mapcar #'listen-queue-track filenames))))
+    (thread-last listen-library-taxy
+                 taxy-emptied
+                 (taxy-fill tracks)
+                 ;; (taxy-sort #'string< #'listen-queue-track-)
+                 (taxy-sort* #'string< #'taxy-name)
+                 taxy-magit-section-pp)))
+
+(provide 'listen-library)
+
+;;; listen-library.el ends here
diff --git a/listen-queue.el b/listen-queue.el
index 6cef3064c8..1995292341 100644
--- a/listen-queue.el
+++ b/listen-queue.el
@@ -273,6 +273,7 @@ PROMPT is passed to `format-prompt', which see."
 (defun listen-queue-track (filename)
   "Return track for FILENAME."
   (when-let ((metadata (listen-info--decode-info-fields filename)))
+    ;; FIXME: This assertion.
     (cl-assert metadata nil "Track has no metadata: %S" filename)
     (make-listen-track
      ;; Abbreviate the filename so as to not include the user's
diff --git a/listen.el b/listen.el
index b41482fd3b..6b403ed99a 100755
--- a/listen.el
+++ b/listen.el
@@ -4,7 +4,7 @@
 
 ;; Author: Adam Porter <adam@alphapapa.net>
 ;; Keywords: multimedia
-;; Package-Requires: ((emacs "29.1") (persist "0.6"))
+;; Package-Requires: ((emacs "29.1") (persist "0.6") (taxy "0.10") 
(taxy-magit-section "0.13"))
 ;; Version: 0.1-pre
 ;; URL: https://github.com/alphapapa/listen.el
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]