scripts

misc scripts and tools
git clone git://git.2f30.org/scripts.git
Log | Files | Refs

commit 779ab2000d1700fc47114fc91719fb0dc1b5ec76
parent 997d449ef0b1cf49d929c76293bd49393bdb4890
Author: lostd <lostd@2f30.org>
Date:   Wed Jan  1 17:32:34 +0200

Use taglib to read tags

Diffstat:
taginfo/Makefile | 10++++++++++
taginfo/taginfo.cc | 48++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 58 insertions(+), 0 deletions(-)
diff --git a/taginfo/Makefile b/taginfo/Makefile @@ -0,0 +1,10 @@ +CFLAGS != pkg-config --cflags taglib +LDFLAGS != pkg-config --libs-only-L taglib +LDLIBS != pkg-config --libs-only-l taglib + +BIN = taginfo + +all: $(BIN) + +clean: + rm -f $(BIN) diff --git a/taginfo/taginfo.cc b/taginfo/taginfo.cc @@ -0,0 +1,48 @@ +#include <iostream> + +#include <fileref.h> +#include <tag.h> + +// dump tags of audio files +// depends: taglib + +using namespace std; + +int +main(int argc, char *argv[]) +{ + if (argc == 1) { + cerr << "usage: taginfo file ..." << endl; + return 1; + } + + // detect unicode locale + setlocale(LC_ALL, ""); + string lc = string(setlocale(LC_CTYPE, NULL)); + bool unicode = lc.find("UTF-8") != string::npos; + + for (int i = 1; i < argc; i++) { + TagLib::FileRef f(argv[i]); + TagLib::Tag *tag = f.tag(); + + if (f.isNull() || !tag) + continue; + + string a = tag->artist().toCString(unicode); + string t = tag->title().toCString(unicode); + string b = tag->album().toCString(unicode); + uint y = tag->year(); + uint n = tag->track(); + string g = tag->genre().toCString(unicode); + string c = tag->comment().toCString(unicode); + + cout << a; + cout << " - "; + cout << b; + cout << " - "; + cout << t; + cout << endl; + } + + return 0; +}