1 /* Copyright (C) 2003 Scott Wheeler <wheeler@kde.org>
2 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions
5 * are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */
24
25 #include <iostream>
26 #include <stdlib.h>
27
28 #include <tbytevector.h>
29
30 #include <mpegfile.h>
31
32 #include <id3v2tag.h>
33 #include <id3v2frame.h>
34 #include <id3v2header.h>
35 #include <commentsframe.h>
36
37 #include <id3v1tag.h>
38
39 #include <apetag.h>
40
41 using namespace std;
42 using namespace TagLib;
43
main(int argc,char * argv[])44 int main(int argc, char *argv[])
45 {
46 // process the command line args
47
48
49 for(int i = 1; i < argc; i++) {
50
51 cout << "******************** \"" << argv[i] << "\"********************" << endl;
52
53 MPEG::File f(argv[i]);
54
55 ID3v2::Tag *id3v2tag = f.ID3v2Tag();
56
57 if(id3v2tag) {
58
59 cout << "ID3v2."
60 << id3v2tag->header()->majorVersion()
61 << "."
62 << id3v2tag->header()->revisionNumber()
63 << ", "
64 << id3v2tag->header()->tagSize()
65 << " bytes in tag"
66 << endl;
67
68 ID3v2::FrameList::ConstIterator it = id3v2tag->frameList().begin();
69 for(; it != id3v2tag->frameList().end(); it++) {
70 cout << (*it)->frameID();
71
72 if(ID3v2::CommentsFrame *comment = dynamic_cast<ID3v2::CommentsFrame *>(*it))
73 if(!comment->description().isEmpty())
74 cout << " [" << comment->description() << "]";
75
76 cout << " - \"" << (*it)->toString() << "\"" << endl;
77 }
78 }
79 else
80 cout << "file does not have a valid id3v2 tag" << endl;
81
82 cout << endl << "ID3v1" << endl;
83
84 ID3v1::Tag *id3v1tag = f.ID3v1Tag();
85
86 if(id3v1tag) {
87 cout << "title - \"" << id3v1tag->title() << "\"" << endl;
88 cout << "artist - \"" << id3v1tag->artist() << "\"" << endl;
89 cout << "album - \"" << id3v1tag->album() << "\"" << endl;
90 cout << "year - \"" << id3v1tag->year() << "\"" << endl;
91 cout << "comment - \"" << id3v1tag->comment() << "\"" << endl;
92 cout << "track - \"" << id3v1tag->track() << "\"" << endl;
93 cout << "genre - \"" << id3v1tag->genre() << "\"" << endl;
94 }
95 else
96 cout << "file does not have a valid id3v1 tag" << endl;
97
98 APE::Tag *ape = f.APETag();
99
100 cout << endl << "APE" << endl;
101
102 if(ape) {
103 for(APE::ItemListMap::ConstIterator it = ape->itemListMap().begin();
104 it != ape->itemListMap().end(); ++it)
105 {
106 if((*it).second.type() != APE::Item::Binary)
107 cout << (*it).first << " - \"" << (*it).second.toString() << "\"" << endl;
108 else
109 cout << (*it).first << " - Binary data (" << (*it).second.binaryData().size() << " bytes)" << endl;
110 }
111 }
112 else
113 cout << "file does not have a valid APE tag" << endl;
114
115 cout << endl;
116 }
117 }
118