diff options
-rw-r--r-- | doc/emms.texinfo | 16 | ||||
-rw-r--r-- | lisp/emms-info-opusinfo.el | 85 | ||||
-rw-r--r-- | lisp/emms-setup.el | 3 |
3 files changed, 97 insertions, 7 deletions
diff --git a/doc/emms.texinfo b/doc/emms.texinfo index 36b39cd..e5b5db9 100644 --- a/doc/emms.texinfo +++ b/doc/emms.texinfo @@ -204,8 +204,8 @@ More detail about setting up Emms can be found in the setup chapter, Emms tries to display the tags (the name of the song, as opposed to the name of the file) of the music you listen to. Emms can use libtag, see @xref{Using TagLib}, or a combination of other software such as -`mp3info' and `ogginfo' (make sure that they are installed if you want -Emms to use them.) +`mp3info', `ogginfo' and `opusinfo' (make sure that they are installed +if you want Emms to use them.) The last thing to do is to tell Emms where your music is; the root directory of our music collection. Let's say all your music is in @@ -876,11 +876,13 @@ The current Emms playlist buffer is stored in the variable Emms is distributed with multiple predefined methods for retrieving info, provided by modules such as @file{emms-info-mp3info.el}, -@file{emms-info-ogginfo.el}, @file{emms-cue.el} and -@file{emms-info-libtag.el}. The first two packages are front-ends for -command-line tools. Ogg track information is retrieved using the -@uref{http://directory.fsf.org/audio/ogg/vorbistools.html, ogginfo} -software. Likewise, mp3 track information is available using +@file{emms-info-ogginfo.el}, @file{emms-info-opusinfo.el}, +@file{emms-cue.el} and @file{emms-info-libtag.el}. The first three +packages are front-ends for command-line tools. Ogg track information is +retrieved using the +@uref{http://directory.fsf.org/audio/ogg/vorbistools.html, ogginfo} and +the @uref{https://www.opus-codec.org/ opusinfo} software. Likewise, mp3 +track information is available using @uref{http://www.ibiblio.org/mp3info/, mp3info}. @file{emms-cue.el} retrieves tracks information for ape/flac files by parsing a cue sheet file, which is plain text. Finally, @file{emms-info-libtag.el} uses a diff --git a/lisp/emms-info-opusinfo.el b/lisp/emms-info-opusinfo.el new file mode 100644 index 0000000..6762bc1 --- /dev/null +++ b/lisp/emms-info-opusinfo.el @@ -0,0 +1,85 @@ +;;; emms-info-opusinfo.el --- Emms information from Ogg Opus files. + +;; Copyright (C) 2018 Free Software Foundation, Inc. + +;; Author: Pierre Neidhardt <ambrevar@gmail.com> + +;; This file is part of EMMS. + +;; EMMS 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. + +;; EMMS 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 EMMS; if not, write to the Free Software Foundation, +;; Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + +;;; Commentary: +;; + +;;; Code: + +(require 'emms-info) + +(defgroup emms-info-opusinfo nil + "An EMMS-info method for getting, using the external opusinfo +program" + :group 'emms-info) + +(defcustom emms-info-opusinfo-coding-system 'utf-8 + "*Coding system used in the output of opusinfo." + :type 'coding-system + :group 'emms-info-opusinfo) + +(defcustom emms-info-opusinfo-program-name "opusinfo" + "*The name/path of the opusinfo tag program." + :type 'string + :group 'emms-info-opusinfo) + +(defun emms-info-opusinfo (track) + "Add track information to TRACK. +This is a useful element for `emms-info-functions'." + (when (and (eq 'file (emms-track-type track)) + (or (string-match "\\.[Oo][Gg][Gg]\\'" (emms-track-name track)) + (string-match "\\.[Oo][Pp][Uu][Ss]\\'" (emms-track-name track)))) + + (with-temp-buffer + (call-process emms-info-opusinfo-program-name + nil t nil (emms-track-name track)) + + ;; play time + (goto-char (point-min)) + (when (re-search-forward + "Playback length: \\([0-9]*\\)m:\\([0-9]*\\)" nil t) + (let* ((minutes (string-to-number (match-string 1))) + (seconds (string-to-number (match-string 2))) + (ptime-total (+ (* minutes 60) seconds)) + (ptime-min minutes) + (ptime-sec seconds)) + (emms-track-set track 'info-playing-time ptime-total) + (emms-track-set track 'info-playing-time-min ptime-min) + (emms-track-set track 'info-playing-time-sec ptime-sec) + (emms-track-set track 'info-file (emms-track-name track)))) + + ;; all the rest of the info available + (goto-char (point-min)) + (when (re-search-forward "^.*\\.\\.\\.$" (point-max) t) + (while (zerop (forward-line 1)) + (when (looking-at "^\t\\(.*?\\)=\\(.*\\)$") ; recognize the first '=' + (let ((a (match-string 1)) + (b (match-string 2))) + (when (and (< 0 (length a)) + (< 0 (length b))) + (emms-track-set track + (intern (downcase (concat "info-" (match-string 1)))) + (match-string 2)))))))))) + +(provide 'emms-info-opusinfo) + +;;; emms-info-opusinfo.el ends here diff --git a/lisp/emms-setup.el b/lisp/emms-setup.el index 3c214fe..47260b5 100644 --- a/lisp/emms-setup.el +++ b/lisp/emms-setup.el @@ -81,6 +81,7 @@ the stable features which come with the Emms distribution." (require 'emms-info) (require 'emms-info-mp3info) (require 'emms-info-ogginfo) + (require 'emms-info-opusinfo) (require 'emms-cache) (require 'emms-mode-line) (require 'emms-mark) @@ -113,6 +114,8 @@ the stable features which come with the Emms distribution." (add-to-list 'emms-info-functions 'emms-info-mp3info)) (when (executable-find emms-info-ogginfo-program-name) (add-to-list 'emms-info-functions 'emms-info-ogginfo)) + (when (executable-find emms-info-opusinfo-program-name) + (add-to-list 'emms-info-functions 'emms-info-opusinfo)) (setq emms-track-description-function 'emms-info-track-description) (when (fboundp 'emms-cache) ; work around compiler warning (emms-cache 1)) |