From c959a9d8568e5a5fa318ff2a8e8c46b324a44676 Mon Sep 17 00:00:00 2001 From: Trent Buck Date: Sat, 19 Nov 2005 18:15:00 +0000 Subject: Implement an emms-info function using the libtag package. darcs-hash:20051119181528-8f417-cccb6d14779011d1e58eac89474282257768e631.gz --- Makefile | 5 +++- debian/control | 15 ++++++++++- debian/dirs | 2 -- debian/docs | 1 - debian/emms-extras.dirs | 1 + debian/emms.dirs | 2 ++ debian/emms.docs | 1 + debian/rules | 58 ++++++++++++++++++++++++++++------------- emms-info-libtag.el | 68 +++++++++++++++++++++++++++++++++++++++++++++++++ emms-print-metadata.c | 33 ++++++++++++++++++++++++ 10 files changed, 164 insertions(+), 22 deletions(-) delete mode 100644 debian/dirs delete mode 100644 debian/docs create mode 100644 debian/emms-extras.dirs create mode 100644 debian/emms.dirs create mode 100644 debian/emms.docs create mode 100644 emms-info-libtag.el create mode 100644 emms-print-metadata.c diff --git a/Makefile b/Makefile index ae54f71..0017e0b 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,9 @@ emms-auto.el: emms-auto.in $(SOURCE) %.info: %.texinfo makeinfo $< +emms-print-metadata: emms-print-metadata.c + $(CC) -o $@ $< -I/usr/include/taglib -L/usr/lib -ltag_c + install: test -d $(DESTDIR) || mkdir -p $(DESTDIR) install -m 644 $(ALLSOURCE) $(DESTDIR)/usr/share/emacs/site-lisp/emms/ @@ -39,4 +42,4 @@ ChangeLog: darcs changes > $@ clean: - -rm -f *~ *.elc emms-auto.el emms.info ChangeLog + -rm -f *~ *.elc emms-auto.el emms.info ChangeLog emms-print-metadata diff --git a/debian/control b/debian/control index b62482e..67189ce 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: emms Section: sound Priority: optional Maintainer: Jorgen Schaefer -Build-Depends: debhelper (>= 4.0.0), emacs21, texinfo +Build-Depends: debhelper (>= 4.0.0), emacs21, texinfo, libtagc0-dev Standards-Version: 3.6.2.1 Package: emms @@ -16,3 +16,16 @@ Description: The Emacs MultiMedia System application to play multimedia files from Emacs using external players. +Package: emms-extras +Architecture: any +Depends: emms, libtagc0 +Recommends: mpg321, vorbis-tools +Conflicts: emacs20 +Description: The Emacs MultiMedia System + EMMS is the Emacs Multi-Media System. It tries to be a clean and small + application to play multimedia files from Emacs using external + players. + . + This package provides emms-print-metadata, a small binary program that emms + can use to extract track metadata from music files. + diff --git a/debian/dirs b/debian/dirs deleted file mode 100644 index ddac531..0000000 --- a/debian/dirs +++ /dev/null @@ -1,2 +0,0 @@ -usr/share/emacs/site-lisp/emms -usr/share/info diff --git a/debian/docs b/debian/docs deleted file mode 100644 index e845566..0000000 --- a/debian/docs +++ /dev/null @@ -1 +0,0 @@ -README diff --git a/debian/emms-extras.dirs b/debian/emms-extras.dirs new file mode 100644 index 0000000..e772481 --- /dev/null +++ b/debian/emms-extras.dirs @@ -0,0 +1 @@ +usr/bin diff --git a/debian/emms.dirs b/debian/emms.dirs new file mode 100644 index 0000000..ddac531 --- /dev/null +++ b/debian/emms.dirs @@ -0,0 +1,2 @@ +usr/share/emacs/site-lisp/emms +usr/share/info diff --git a/debian/emms.docs b/debian/emms.docs new file mode 100644 index 0000000..e845566 --- /dev/null +++ b/debian/emms.docs @@ -0,0 +1 @@ +README diff --git a/debian/rules b/debian/rules index 16aece6..65c8978 100755 --- a/debian/rules +++ b/debian/rules @@ -25,42 +25,64 @@ configure-stamp: touch configure-stamp -build: build-stamp - -build-stamp: configure-stamp +build: +build-indep: build-indep-stamp +build-arch: build-arch-stamp +build-arch-stamp: + make emms-print-metadata + touch build-arch-stamp +build-indep-stamp: configure-stamp dh_testdir make emms.info make emms-auto.el make ChangeLog - touch build-stamp + touch build-indep-stamp clean: dh_testdir dh_testroot - rm -f build-stamp configure-stamp + rm -f build-arch-stamp build-indep-stamp configure-stamp # Add here commands to clean up after the build process. -$(MAKE) clean dh_clean -install: build +install: install-indep install-arch +install-indep: dh_testdir dh_testroot - dh_clean -k - dh_installdirs + dh_clean -k -i + dh_installdirs -i - # Add here commands to install the package into debian/emms. + # Add here commands to install the indep part of the package into + # debian/emms. $(MAKE) deb-install DESTDIR=$(CURDIR)/debian/emms + dh_installinfo -i emms.info + + dh_install -i + +install-arch: + dh_testdir + dh_testroot + dh_clean -k -s + dh_installdirs -s + + # Add here commands to install the arch part of the package into + # debian/emms-extras. + install emms-print-metadata debian/emms-extras/usr/bin/ + + dh_install -s -# Build architecture-independent files here. -binary-indep: build install +# Must not depend on anything. This is to be called by +# binary-arch/binary-indep +# in another 'make' thread. +binary-common: dh_testdir dh_testroot dh_installchangelogs ChangeLog dh_installdocs # dh_installexamples - dh_install # dh_installmenu # dh_installdebconf # dh_installlogrotate @@ -69,10 +91,9 @@ binary-indep: build install # dh_installmime # dh_installinit # dh_installcron - dh_installinfo emms.info # dh_installman dh_link -# dh_strip + dh_strip dh_compress dh_fixperms # dh_perl @@ -83,10 +104,13 @@ binary-indep: build install dh_gencontrol dh_md5sums dh_builddeb +# Build architecture independent packages using the common target. +binary-indep: build-indep install-indep + $(MAKE) -f debian/rules DH_OPTIONS=-i binary-common -# Build architecture-dependent files here. -binary-arch: build install -# We have nothing to do by default. +# Build architecture dependant packages using the common target. +binary-arch: build-arch install-arch + $(MAKE) -f debian/rules DH_OPTIONS=-a binary-common binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary install configure diff --git a/emms-info-libtag.el b/emms-info-libtag.el new file mode 100644 index 0000000..fa0019a --- /dev/null +++ b/emms-info-libtag.el @@ -0,0 +1,68 @@ +;;; emms-info-libtag.el --- Info-method for EMMS using libtag + +;; Copyright (C) 2003 Free Software Foundation, Inc. + +;; Authors: Ulrik Jensen +;; Jorgen Schäfer +;; Keywords: + +;; This file 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 2, or (at your option) +;; any later version. + +;; This file 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 GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +;; Boston, MA 02110-1301 USA + +;;; Commentary: + +;; This code has been adapted from code found in mp3player.el, written +;; by Jean-Philippe Theberge (jphiltheberge@videotron.ca), Mario +;; Domgoergen (kanaldrache@gmx.de) and Jorgen Schäfer +;; + +;; To activate this method for getting info, use something like: + +;; (require 'emms-info-libtag) +;; (add-to-list 'emms-info-functions 'emms-info-libtag) + +;;; Code: + +(require 'rx) + +(defvar emms-info-libtag-coding-system 'utf-8) +(defvar emms-info-libtag-program-name "emms-print-metadata") + +(defun emms-info-libtag (track) + (when (and (eq 'file (emms-track-type track)) + (string-match + "\\.\([Mm][Pp]3\|[oO][gG][gG]\|[fF][lL][aA][cC]\)\\'" + (emms-track-name track))) + (with-temp-buffer + (when (zerop + (let ((coding-system-for-read 'utf-8)) + (call-process "emms-print-metadata" + nil t nil + (emms-track-name track)))) + (goto-char (point-min)) + (while (looking-at "^\\([^=]+\\)=\\(.*\\)$") + (let ((name (intern (match-string 1))) + (value (match-string 2))) + (when (> (length value) + 0) + (emms-track-set track + name + (if (eq name 'info-playing-time) + (string-to-number value) + value)))) + (forward-line 1)))))) + +(provide 'emms-info-libtag) +;;; emms-info-libtag.el ends here diff --git a/emms-print-metadata.c b/emms-print-metadata.c new file mode 100644 index 0000000..505bd52 --- /dev/null +++ b/emms-print-metadata.c @@ -0,0 +1,33 @@ +#include +#include +#include + +int +main (int argc, char **argv) +{ + TagLib_File *file; + TagLib_Tag *tag; + + if (argc != 2) + { + fprintf (stderr, "usage: emms-print-metadata file.{mp3,ogg,flac}\n"); + exit (1); + } + + file = taglib_file_new (argv[1]); + tag = taglib_file_tag (file); + + printf ("info-artist=%s\n", taglib_tag_artist (tag)); + printf ("info-title=%s\n", taglib_tag_title (tag)); + printf ("info-album=%s\n", taglib_tag_album (tag)); + printf ("info-tracknumber=%d\n", taglib_tag_track (tag)); + printf ("info-year=%d\n", taglib_tag_year (tag)); + printf ("info-genre=%s\n", taglib_tag_genre (tag)); + printf ("info-note=%s\n", taglib_tag_comment (tag)); + printf ("info-playing-time=%d\n", taglib_audioproperties_length (taglib_file_audioproperties (file))); + + taglib_tag_free_strings (); + taglib_file_free (file); + + return 0; +} -- cgit v1.2.3