1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
/* emms-print-metadata.c --- Info function for libtag
Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
Author: Trent Buck <trentbuck@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, 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 <stdlib.h>
#include <stdio.h>
#include <tag_c.h>
int
main (int argc, char **argv)
{
TagLib_File *file;
TagLib_Tag *tag;
const TagLib_AudioProperties *properties;
if (argc != 2)
{
fprintf (stderr, "usage: emms-print-metadata file.{mp3,ogg,flac}\nother formats may work as well.\n");
exit (1);
}
file = taglib_file_new (argv[1]);
if (!file)
{
fprintf (stderr, "%s: File does not exist or is of an unknown type\n", argv[1]);
exit (1);
}
tag = taglib_file_tag (file);
/* Apparently, if the file is named foo.mp3 or similar, the library
still can open it, for whatever reason.
*/
if (!tag)
{
fprintf (stderr, "%s: File does not exist or is of an unknown type\n", argv[1]);
exit (1);
}
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));
properties = taglib_file_audioproperties (file);
printf ("info-playing-time=%d\n",
properties ? taglib_audioproperties_length (properties) : 0);
taglib_tag_free_strings ();
taglib_file_free (file);
return 0;
}
/* emms-print-metadata.c ends here. */
|