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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
|
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
using namespace std;
struct idestruct{
char header[3];
char title[30];
char artist[30];
char album[30];
char year[4];
char comment[29];
char track;
char genre;
};
/*struct test{
char comment[29];
char track;
char genre;
};*/
int main()
{
ifstream fin;
char select;
char genre[126][128] = {"Blues", "Classic Rock", "Country", "Dance", "Disco", "Funk", "Grunge", "Hip-Hop", "Jazz", "Metal", "New Age", "Oldies", "Other", "Pop", "R&B", "Rap", "Regae", "Rock", "Techno",
"Industrial", "Alternative", "Ska", "Death Metal", "Pranks", "Soundtrack", "Euro-Techno", "Ambient", "Trip-Hop", "Vocal", "Jazz+Funk", "Fusion", "Trance", "Classical", "Instrumental",
"Acid", "House", "Game", "Sound Clip", "Gospel", "Noise", "AlternRock", "Bass", "Soul", "Punk", "Space", "Meditative", "Instrumental Pop", "Instrumental Rock", "Ethnic", "Gothic",
"Darkwave", "Techno-Industrial", "Electronic", "Pop-Folk", "Eurodance", "Dream", "Souther Rock", "Comedy", "Cult", "Gangsta", "Top 40", "Christian Rap", "Pop/Funk", "Jungle",
"Native American", "Cabaret", "New Wave", "Psychadelic", "Rave", "Showtunes", "Trailer", "Lo-Fi", "Tribal", "Acid Punk", "Acid Jazz", "Polka", "Retro", "Musical", "Rock & Roll",
"Hard Rock", "Folk", "Folk-Rock", "National Folk", "Swing", "Fast Fusion", "Bebob", "Latin", "Revival", "Celtic", "Bluegrass", "Avantgarde", "Gothic Rock", "Progressive Rock",
"Psychadelic Rock", "Symphonic Rock", "Slow Rock", "Big Band", "Chorus", "Easy Listening", "Acoustic", "Humour", "Speech", "Chanson", "Opera", "Chamber Music", "Sonata", "Symphony",
"Booty Bass", "Primus", "Porn Groove", "Satire", "Slow Jam", "Club", "Tango", "Samba", "Folklore", "Ballad", "Power Ballad", "Rhythmic Soul", "Freestyle", "Duet", "Punk Rock",
"Drum Solo", "Acapella", "Euro-House", "Dance Hall"};
int track, genre_num;
string file, filename, filetype, header, year, comment;
idestruct ide;
int ide_size = sizeof(ide);
int comment_loc = 31;
cout << comment_loc << endl;
cout << "Enter your MP3 filename: ";
getline(cin, filename,'.');
getline(cin, filetype);
if(filetype != "mp3")
{
cout << "Sorry that is not a valid MP3 file. Program Terminating" << endl;
}
else
{
file = filename + '.' + filetype;
//cout << file << endl;
fin.open(file.c_str(), ios::binary | ios::in);
fin.seekg(-(ide_size), ios::end);
//cout << fin.tellg() << endl;
fin.read((char *) &ide, (ide_size));
for(int i = 0; i < 3; i++)
{
header += ide.header[i];
}
for(int i = 0; i < 4; i++)
{
year += ide.year[i];
}
if(header != "TAG")
{
cout << header << endl;
cout << "There is no valid header on the file. Program Terminating" << endl;
}
else
{
cout << "File is OK and has a valid ID3v1.1 " << header << endl << endl;
cout << "Title: " << ide.title << endl;
cout << "Artist: " << ide.artist << endl;
cout << "Album: " << ide.album << endl;
cout << "Year: " << year << endl;
cout << "Genre: " << genre[ide.genre] << endl;
track = static_cast<int>(ide.track);
cout << "Trank Number: " << track << endl;
cout << "Comment: " << ide.comment << endl;
cout << endl;
}
}
cout << "Would you like to update the comment? [Y/N]: ";
cin >> select;
select = toupper(select);
switch(select)
{
case 'Y':
{
//test idetest;
ofstream fout;
fin.seekg(-(comment_loc), ios::end);
//cout << fin.tellg() << endl;
//fin.read((char *) &idetest, sizeof(idetest));
//cout << idetest.comment << endl;
cout << "Enter new information for the comment: ";
getline(cin, comment, '\n');
cout << comment << endl;
}
}
return 0;
}
|