aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS1
-rw-r--r--Makefile4
-rw-r--r--NEWS6
-rw-r--r--doc/emms.texinfo2
-rw-r--r--lisp/emms-info.el2
-rw-r--r--src/emms-print-metadata.cpp112
6 files changed, 123 insertions, 4 deletions
diff --git a/AUTHORS b/AUTHORS
index 869a940..d6700bb 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -19,6 +19,7 @@ Martin Schoenmakers <aiviru@diamond-age.net>
Matthew Kennedy <mkennedy@gentoo.org>
Michael Olson <mwolson@gnu.org>
Nick Alcock <nix@esperi.org.uk>
+Petteri Hintsanen <petterih@iki.fi>
Tassilo Horn <tassilo@member.fsf.org>
Thierry Volpiatto
Trent Buck <trentbuck@gmail.com>
diff --git a/Makefile b/Makefile
index 1b896dd..4e4584c 100644
--- a/Makefile
+++ b/Makefile
@@ -35,8 +35,8 @@ lisp:
docs:
$(MAKE) -C $(DOCDIR)
-emms-print-metadata: $(SRCDIR)/emms-print-metadata.c
- $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $(SRCDIR)/$@ $< `taglib-config --cflags --libs` -ltag_c
+emms-print-metadata: $(SRCDIR)/emms-print-metadata.cpp
+ $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $(SRCDIR)/$@ $< `taglib-config --cflags --libs`
install:
test -d $(SITELISP) || mkdir -p $(SITELISP)
diff --git a/NEWS b/NEWS
index 62123bc..b6d5379 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,9 @@
+News since version 4.2:
+
+ - New (C++) emms-print-metadata brings more TagLib features.
+ - Compilation warnings gone (excl. cl).
+ - Bug fix: emms-lyrics free variable fix.
+
News since version 4.1:
- Removed defunct streams.
diff --git a/doc/emms.texinfo b/doc/emms.texinfo
index 8bc25a4..159e94e 100644
--- a/doc/emms.texinfo
+++ b/doc/emms.texinfo
@@ -922,7 +922,7 @@ track as argument.
@cindex using taglib
The communication with the TagLib library is done via a tiny program
-written in C @file{emms-print-metadata.c}. To compile
+written in C++ @file{emms-print-metadata.cpp}. To compile
@file{emms-print-metadata} invoke:
@command{make emms-print-metadata}
diff --git a/lisp/emms-info.el b/lisp/emms-info.el
index cfc206b..50b1813 100644
--- a/lisp/emms-info.el
+++ b/lisp/emms-info.el
@@ -1,6 +1,6 @@
;;; emms-info.el --- Retrieving track information
-;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation Inc.
+;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2015 Free Software Foundation Inc.
;; Author: Jorgen Schaefer <forcer@forcix.cx>
diff --git a/src/emms-print-metadata.cpp b/src/emms-print-metadata.cpp
new file mode 100644
index 0000000..7283657
--- /dev/null
+++ b/src/emms-print-metadata.cpp
@@ -0,0 +1,112 @@
+/* emms-print-metadata.cpp --- Info function for TagLib
+ Copyright (C) 2016 Free Software Foundation, Inc.
+
+ Author: Petteri Hintsanen <petterih@iki.fi>
+
+ 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, 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; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA. */
+
+#include <taglib/fileref.h>
+#include <taglib/tag.h>
+#include <taglib/tpropertymap.h>
+#include <iostream>
+
+static const char* const tags_to_extract[] = {
+ "album",
+ "albumsort",
+ "albumartist",
+ "albumartistsort",
+ "artist",
+ "artistsort",
+ "composer",
+ "composersort",
+ "performer",
+ "year",
+ "originalyear",
+ "date",
+ "originaldate",
+ "genre",
+ "label",
+ "title",
+ "titlesort",
+ "tracknumber",
+ "discnumber"
+};
+
+void print_tag (const TagLib::PropertyMap& tags, const std::string& tag);
+
+int
+main (int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ std::cerr << argv[0] << ": "
+ << "usage: emms-print-metadata FILENAME"
+ << std::endl
+ << "FILENAME must end to one of these extensions: "
+ << TagLib::FileRef::defaultFileExtensions ().toString ()
+ << std::endl;
+ return 1;
+ }
+
+ TagLib::FileRef file (argv[1]);
+ if (file.isNull ()) {
+ std::cerr << argv[0] << ": "
+ << argv[1] << ": "
+ << "file does not exist or is of an unknown type"
+ << std::endl;
+ return 1;
+ }
+
+ const TagLib::PropertyMap tags = file.file ()->properties ();
+ if (tags.isEmpty ()) {
+ std::cerr << argv[0] << ": "
+ << argv[1] << ": "
+ << "file does not have tags or is of an unknown type"
+ << std::endl;
+ return 1;
+ }
+
+ for (unsigned int i = 0; i < sizeof (tags_to_extract) / sizeof (char*);
+ i++)
+ {
+ print_tag (tags, tags_to_extract[i]);
+ }
+
+ int length = 0;
+ if (file.audioProperties ())
+ {
+ const TagLib::AudioProperties* properties = file.audioProperties ();
+ length = properties->length ();
+ }
+ std::cout << "info-playing-time=" << length << std::endl;
+
+ return 0;
+}
+
+void
+print_tag (const TagLib::PropertyMap& tags, const std::string& tag)
+{
+ TagLib::StringList values = tags[tag];
+ if (!values.isEmpty ())
+ {
+ const TagLib::String& value = values.front ();
+ std::cout << "info-" << tag << "=" << value.to8Bit (true) << std::endl;
+ }
+}
+
+/* emms-print-taglib-metadata.cpp ends here. */