From 6601ba8ef710b8ed260773e18a3baa940a7adc3a Mon Sep 17 00:00:00 2001 From: Yoni Rabkin Date: Wed, 1 Mar 2017 17:06:42 -0500 Subject: Move to a new emms-print-metadata. The new emms-print-metadata is written in C++ and brings on board new features from TagLib. Patch by Petteri Hintsanen . --- AUTHORS | 1 + Makefile | 4 +- NEWS | 6 +++ doc/emms.texinfo | 2 +- lisp/emms-info.el | 2 +- src/emms-print-metadata.cpp | 112 ++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 123 insertions(+), 4 deletions(-) create mode 100644 src/emms-print-metadata.cpp diff --git a/AUTHORS b/AUTHORS index 869a940..d6700bb 100644 --- a/AUTHORS +++ b/AUTHORS @@ -19,6 +19,7 @@ Martin Schoenmakers Matthew Kennedy Michael Olson Nick Alcock +Petteri Hintsanen Tassilo Horn Thierry Volpiatto Trent Buck 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 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 + + 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 +#include +#include +#include + +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. */ -- cgit v1.2.3