tagger 0.2 checkin
git-svn-id: https://svn.salfter.gotdns.org/svn/tagger@126 1b90f75b-8b96-4784-87c0-14078182fce6
This commit is contained in:
@@ -1,3 +1,24 @@
|
||||
/*
|
||||
|
||||
tagger 0.2
|
||||
MP3/Ogg Vorbis/AAC file tagger
|
||||
Copyright © 2005-2006 Scott Alfter (http://alfter.us/)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License (version 2) as
|
||||
published by the Free Software Foundation.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "delete.h"
|
||||
|
||||
int deletetag (int argc, char** argv, int startarg)
|
||||
|
||||
21
src/delete.h
21
src/delete.h
@@ -1,3 +1,24 @@
|
||||
/*
|
||||
|
||||
tagger 0.2
|
||||
MP3/Ogg Vorbis/AAC file tagger
|
||||
Copyright © 2005-2006 Scott Alfter (http://alfter.us/)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License (version 2) as
|
||||
published by the Free Software Foundation.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _ID3DELETE_H
|
||||
#define _ID3DELETE_H
|
||||
|
||||
|
||||
25
src/help.cpp
25
src/help.cpp
@@ -1,7 +1,32 @@
|
||||
/*
|
||||
|
||||
tagger 0.2
|
||||
MP3/Ogg Vorbis/AAC file tagger
|
||||
Copyright © 2005-2006 Scott Alfter (http://alfter.us/)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License (version 2) as
|
||||
published by the Free Software Foundation.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "help.h"
|
||||
|
||||
void help(char* progname)
|
||||
{
|
||||
cout << "tagger 0.2" << endl;
|
||||
cout << "Copyright <20> 2005-2006 by Scott Alfter" << endl;
|
||||
cout << "http://alfter.us/" << endl;
|
||||
cout << endl;
|
||||
cout << "Usage: " << progname << " [options] file1.mp3 ..." << endl;
|
||||
cout << endl;
|
||||
cout << "-v view tag text" << endl;
|
||||
|
||||
23
src/help.h
23
src/help.h
@@ -1,8 +1,29 @@
|
||||
/*
|
||||
|
||||
tagger 0.2
|
||||
MP3/Ogg Vorbis/AAC file tagger
|
||||
Copyright © 2005-2006 Scott Alfter (http://alfter.us/)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License (version 2) as
|
||||
published by the Free Software Foundation.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _ID3HELP_H
|
||||
#define _ID3HELP_H
|
||||
|
||||
#include <iostream>
|
||||
#include <id3/tag.h>
|
||||
//#include <id3/tag.h>
|
||||
#include <unistd.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -1,155 +1,176 @@
|
||||
/*
|
||||
|
||||
tagger 0.2
|
||||
MP3/Ogg Vorbis/AAC file tagger
|
||||
Copyright © 2005-2006 Scott Alfter (http://alfter.us/)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License (version 2) as
|
||||
published by the Free Software Foundation.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "id3v1_genres.h"
|
||||
|
||||
// source: http://en.wikipedia.org/wiki/ID3
|
||||
|
||||
char* id3v1_genres[]=
|
||||
{
|
||||
"Blues",
|
||||
"Classic Rock",
|
||||
"Country",
|
||||
"Dance",
|
||||
"Disco",
|
||||
"Funk",
|
||||
"Grunge",
|
||||
"Hip-Hop",
|
||||
"Jazz",
|
||||
"Metal",
|
||||
"New Age",
|
||||
"Oldies",
|
||||
"Other",
|
||||
"Pop",
|
||||
"R&B",
|
||||
"Rap",
|
||||
"Reggae",
|
||||
"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",
|
||||
"Alt. Rock",
|
||||
"Bass",
|
||||
"Soul",
|
||||
"Punk",
|
||||
"Space",
|
||||
"Meditative",
|
||||
"Instrumental pop",
|
||||
"Instrumental rock",
|
||||
"Ethnic",
|
||||
"Gothic",
|
||||
"Darkwave",
|
||||
"Techno-Industrial",
|
||||
"Electronic",
|
||||
"Pop-Folk",
|
||||
"Eurodance",
|
||||
"Dream",
|
||||
"Southern Rock",
|
||||
"Comedy",
|
||||
"Cult",
|
||||
"Gangsta",
|
||||
"Top 40",
|
||||
"Christian Rap",
|
||||
"Pop/Funk",
|
||||
"Jungle",
|
||||
"Native American",
|
||||
"Cabaret",
|
||||
"New Wave",
|
||||
"Psychedelic",
|
||||
"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",
|
||||
"Psychedelic 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",
|
||||
"A cappella",
|
||||
"Euro-House",
|
||||
"Dance Hall",
|
||||
"Goa",
|
||||
"Drum & Bass",
|
||||
"Club-House",
|
||||
"Hardcore",
|
||||
"Terror",
|
||||
"Indie",
|
||||
"BritPop",
|
||||
"Negerpunk",
|
||||
"Polsk Punk",
|
||||
"Beat",
|
||||
"Christian gangsta rap",
|
||||
"Heavy Metal",
|
||||
"Black Metal",
|
||||
"Crossover",
|
||||
"Contemporary Christian",
|
||||
"Christian Rock",
|
||||
"Merengue",
|
||||
"Salsa",
|
||||
"Thrash Metal",
|
||||
"Anime",
|
||||
"JPop",
|
||||
"Synthpop"
|
||||
(char*)"Blues",
|
||||
(char*)"Classic Rock",
|
||||
(char*)"Country",
|
||||
(char*)"Dance",
|
||||
(char*)"Disco",
|
||||
(char*)"Funk",
|
||||
(char*)"Grunge",
|
||||
(char*)"Hip-Hop",
|
||||
(char*)"Jazz",
|
||||
(char*)"Metal",
|
||||
(char*)"New Age",
|
||||
(char*)"Oldies",
|
||||
(char*)"Other",
|
||||
(char*)"Pop",
|
||||
(char*)"R&B",
|
||||
(char*)"Rap",
|
||||
(char*)"Reggae",
|
||||
(char*)"Rock",
|
||||
(char*)"Techno",
|
||||
(char*)"Industrial",
|
||||
(char*)"Alternative",
|
||||
(char*)"Ska",
|
||||
(char*)"Death metal",
|
||||
(char*)"Pranks",
|
||||
(char*)"Soundtrack",
|
||||
(char*)"Euro-Techno",
|
||||
(char*)"Ambient",
|
||||
(char*)"Trip-hop",
|
||||
(char*)"Vocal",
|
||||
(char*)"Jazz+Funk",
|
||||
(char*)"Fusion",
|
||||
(char*)"Trance",
|
||||
(char*)"Classical",
|
||||
(char*)"Instrumental",
|
||||
(char*)"Acid",
|
||||
(char*)"House",
|
||||
(char*)"Game",
|
||||
(char*)"Sound Clip",
|
||||
(char*)"Gospel",
|
||||
(char*)"Noise",
|
||||
(char*)"Alt. Rock",
|
||||
(char*)"Bass",
|
||||
(char*)"Soul",
|
||||
(char*)"Punk",
|
||||
(char*)"Space",
|
||||
(char*)"Meditative",
|
||||
(char*)"Instrumental pop",
|
||||
(char*)"Instrumental rock",
|
||||
(char*)"Ethnic",
|
||||
(char*)"Gothic",
|
||||
(char*)"Darkwave",
|
||||
(char*)"Techno-Industrial",
|
||||
(char*)"Electronic",
|
||||
(char*)"Pop-Folk",
|
||||
(char*)"Eurodance",
|
||||
(char*)"Dream",
|
||||
(char*)"Southern Rock",
|
||||
(char*)"Comedy",
|
||||
(char*)"Cult",
|
||||
(char*)"Gangsta",
|
||||
(char*)"Top 40",
|
||||
(char*)"Christian Rap",
|
||||
(char*)"Pop/Funk",
|
||||
(char*)"Jungle",
|
||||
(char*)"Native American",
|
||||
(char*)"Cabaret",
|
||||
(char*)"New Wave",
|
||||
(char*)"Psychedelic",
|
||||
(char*)"Rave",
|
||||
(char*)"Showtunes",
|
||||
(char*)"Trailer",
|
||||
(char*)"Lo-Fi",
|
||||
(char*)"Tribal",
|
||||
(char*)"Acid Punk",
|
||||
(char*)"Acid Jazz",
|
||||
(char*)"Polka",
|
||||
(char*)"Retro",
|
||||
(char*)"Musical",
|
||||
(char*)"Rock & Roll",
|
||||
(char*)"Hard Rock",
|
||||
(char*)"Folk",
|
||||
(char*)"Folk-Rock",
|
||||
(char*)"National Folk",
|
||||
(char*)"Swing",
|
||||
(char*)"Fast Fusion",
|
||||
(char*)"Bebob",
|
||||
(char*)"Latin",
|
||||
(char*)"Revival",
|
||||
(char*)"Celtic",
|
||||
(char*)"Bluegrass",
|
||||
(char*)"Avantgarde",
|
||||
(char*)"Gothic Rock",
|
||||
(char*)"Progressive Rock",
|
||||
(char*)"Psychedelic Rock",
|
||||
(char*)"Symphonic Rock",
|
||||
(char*)"Slow Rock",
|
||||
(char*)"Big Band",
|
||||
(char*)"Chorus",
|
||||
(char*)"Easy Listening",
|
||||
(char*)"Acoustic",
|
||||
(char*)"Humour",
|
||||
(char*)"Speech",
|
||||
(char*)"Chanson",
|
||||
(char*)"Opera",
|
||||
(char*)"Chamber Music",
|
||||
(char*)"Sonata",
|
||||
(char*)"Symphony",
|
||||
(char*)"Booty Bass",
|
||||
(char*)"Primus",
|
||||
(char*)"Porn Groove",
|
||||
(char*)"Satire",
|
||||
(char*)"Slow Jam",
|
||||
(char*)"Club",
|
||||
(char*)"Tango",
|
||||
(char*)"Samba",
|
||||
(char*)"Folklore",
|
||||
(char*)"Ballad",
|
||||
(char*)"Power Ballad",
|
||||
(char*)"Rhythmic Soul",
|
||||
(char*)"Freestyle",
|
||||
(char*)"Duet",
|
||||
(char*)"Punk Rock",
|
||||
(char*)"Drum Solo",
|
||||
(char*)"A cappella",
|
||||
(char*)"Euro-House",
|
||||
(char*)"Dance Hall",
|
||||
(char*)"Goa",
|
||||
(char*)"Drum & Bass",
|
||||
(char*)"Club-House",
|
||||
(char*)"Hardcore",
|
||||
(char*)"Terror",
|
||||
(char*)"Indie",
|
||||
(char*)"BritPop",
|
||||
(char*)"Negerpunk",
|
||||
(char*)"Polsk Punk",
|
||||
(char*)"Beat",
|
||||
(char*)"Christian gangsta rap",
|
||||
(char*)"Heavy Metal",
|
||||
(char*)"Black Metal",
|
||||
(char*)"Crossover",
|
||||
(char*)"Contemporary Christian",
|
||||
(char*)"Christian Rock",
|
||||
(char*)"Merengue",
|
||||
(char*)"Salsa",
|
||||
(char*)"Thrash Metal",
|
||||
(char*)"Anime",
|
||||
(char*)"JPop",
|
||||
(char*)"Synthpop"
|
||||
};
|
||||
|
||||
@@ -1,3 +1,24 @@
|
||||
/*
|
||||
|
||||
tagger 0.2
|
||||
MP3/Ogg Vorbis/AAC file tagger
|
||||
Copyright © 2005-2006 Scott Alfter (http://alfter.us/)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License (version 2) as
|
||||
published by the Free Software Foundation.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _ID3V1_GENRES_H
|
||||
#define _ID3V1_GENRES_H
|
||||
|
||||
|
||||
373
src/modify.cpp
373
src/modify.cpp
@@ -1,176 +1,197 @@
|
||||
#include "modify.h"
|
||||
|
||||
int modifytag (char* filename, char* title, char* artist, char* album,
|
||||
char* tracknum, char* year, char* genre, char* comment,
|
||||
char* imgfilename, int imgtype)
|
||||
{
|
||||
int rtnval=0;
|
||||
int numconv;
|
||||
int imgsize=0;
|
||||
ByteVector imgbuffer((TagLib::uint)0);
|
||||
|
||||
if (imgfilename!=NULL) // preload image, if necessary
|
||||
{
|
||||
ifstream infile;
|
||||
infile.open(imgfilename,ios_base::binary);
|
||||
if (!infile.is_open())
|
||||
{
|
||||
cerr << "unable to open " << imgfilename << endl;
|
||||
exit(-1);
|
||||
}
|
||||
infile.seekg(0,ios::end);
|
||||
imgsize=infile.tellg();
|
||||
infile.close();
|
||||
infile.open(imgfilename,ios_base::binary);
|
||||
imgbuffer.resize((TagLib::uint)imgsize);
|
||||
infile.read(imgbuffer.data(),imgsize);
|
||||
infile.close();
|
||||
}
|
||||
|
||||
if (strcmp(filename+strlen(filename)-4,".mp3")==0) // MP3
|
||||
{
|
||||
MPEG::File* file=new MPEG::File(filename);
|
||||
ID3v2::Tag* v2tag=file->ID3v2Tag(true);
|
||||
if (title!=NULL)
|
||||
v2tag->setTitle(title);
|
||||
if (artist!=NULL)
|
||||
v2tag->setArtist(artist);
|
||||
if (album!=NULL)
|
||||
v2tag->setAlbum(album);
|
||||
if (tracknum!=NULL)
|
||||
{
|
||||
sscanf(tracknum,"%i",&numconv);
|
||||
v2tag->setTrack(numconv);
|
||||
}
|
||||
if (year!=NULL)
|
||||
{
|
||||
sscanf(year,"%i",&numconv);
|
||||
v2tag->setYear(numconv);
|
||||
}
|
||||
if (genre!=NULL)
|
||||
v2tag->setGenre(genre);
|
||||
if (comment!=NULL)
|
||||
v2tag->setComment(comment);
|
||||
if (imgfilename!=NULL)
|
||||
{
|
||||
v2tag->removeFrames("APIC");
|
||||
ID3v2::AttachedPictureFrame* pic=new ID3v2::AttachedPictureFrame;
|
||||
switch (imgtype)
|
||||
{
|
||||
case 1:
|
||||
pic->setMimeType("image/jpeg");
|
||||
break;
|
||||
case 2:
|
||||
pic->setMimeType("image/png");
|
||||
break;
|
||||
}
|
||||
pic->setType((ID3v2::AttachedPictureFrame::Type)3); // front cover
|
||||
pic->setPicture(imgbuffer);
|
||||
v2tag->addFrame(pic);
|
||||
}
|
||||
file->save();
|
||||
cout << filename << ": ID3 tag modified" << endl;
|
||||
}
|
||||
// else if ((strcmp(filename+strlen(filename)-4,".m4a")==0) ||
|
||||
// (strcmp(filename+strlen(filename)-4,".m4p")==0)) // AAC
|
||||
else if (strcmp(filename+strlen(filename)-4,".m4a")==0) // AAC
|
||||
{
|
||||
int numconv;
|
||||
MP4FileHandle file=MP4Modify(filename);
|
||||
if (file!=MP4_INVALID_FILE_HANDLE)
|
||||
{
|
||||
if (title!=NULL)
|
||||
MP4SetMetadataName(file,title);
|
||||
if (artist!=NULL)
|
||||
MP4SetMetadataArtist(file,artist);
|
||||
if (album!=NULL)
|
||||
MP4SetMetadataAlbum(file,album);
|
||||
if (tracknum!=NULL)
|
||||
{
|
||||
sscanf(tracknum,"%i",&numconv);
|
||||
MP4SetMetadataTrack(file,numconv,0);
|
||||
}
|
||||
if (year!=NULL)
|
||||
MP4SetMetadataYear(file,year);
|
||||
if (genre!=NULL)
|
||||
MP4SetMetadataGenre(file,genre);
|
||||
if (comment!=NULL)
|
||||
MP4SetMetadataComment(file,comment);
|
||||
if (imgfilename!=NULL)
|
||||
{
|
||||
if (imgtype==1)
|
||||
MP4SetMetadataCoverArt(file, (u_int8_t*)imgbuffer.data(), imgbuffer.size());
|
||||
else
|
||||
{
|
||||
cerr << filename << ": MPEG4 tags support JPEG images only" << endl;
|
||||
MP4Close(file);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
MP4Close(file);
|
||||
cout << filename << ": MPEG4 tag modified" << endl;
|
||||
}
|
||||
}
|
||||
else if (strcmp(filename+strlen(filename)-4,".ogg")==0) // Ogg Vorbis
|
||||
{
|
||||
Ogg::Vorbis::File* file=new Ogg::Vorbis::File(filename);
|
||||
Ogg::XiphComment* tag=file->tag();
|
||||
if (title!=NULL)
|
||||
tag->setTitle(title);
|
||||
if (artist!=NULL)
|
||||
tag->setArtist(artist);
|
||||
if (album!=NULL)
|
||||
tag->setAlbum(album);
|
||||
if (tracknum!=NULL)
|
||||
{
|
||||
sscanf(tracknum,"%i",&numconv);
|
||||
tag->setTrack(numconv);
|
||||
}
|
||||
if (year!=NULL)
|
||||
{
|
||||
sscanf(year,"%i",&numconv);
|
||||
tag->setYear(numconv);
|
||||
}
|
||||
if (genre!=NULL)
|
||||
tag->setGenre(genre);
|
||||
if (comment!=NULL)
|
||||
tag->setComment(comment);
|
||||
if (imgfilename!=NULL)
|
||||
cerr << filename << ": file format doesn't support images" << endl;
|
||||
file->save();
|
||||
cout << filename << ": Vorbis tag modified" << endl;
|
||||
}
|
||||
else if (strcmp(filename+strlen(filename)-5,".flac")==0) // FLAC
|
||||
{
|
||||
FLAC::File* file=new FLAC::File(filename);
|
||||
Ogg::XiphComment* tag=file->xiphComment();
|
||||
if (title!=NULL)
|
||||
tag->setTitle(title);
|
||||
if (artist!=NULL)
|
||||
tag->setArtist(artist);
|
||||
if (album!=NULL)
|
||||
tag->setAlbum(album);
|
||||
if (tracknum!=NULL)
|
||||
{
|
||||
sscanf(tracknum,"%i",&numconv);
|
||||
tag->setTrack(numconv);
|
||||
}
|
||||
if (year!=NULL)
|
||||
{
|
||||
sscanf(year,"%i",&numconv);
|
||||
tag->setYear(numconv);
|
||||
}
|
||||
if (genre!=NULL)
|
||||
tag->setGenre(genre);
|
||||
if (comment!=NULL)
|
||||
tag->setComment(comment);
|
||||
if (imgfilename!=NULL)
|
||||
cerr << filename << ": file format doesn't support images" << endl;
|
||||
file->save();
|
||||
cout << filename << ": FLAC tag modified" << endl;
|
||||
}
|
||||
else
|
||||
cout << filename << ": file type not supported" << endl;
|
||||
|
||||
return rtnval;
|
||||
}
|
||||
/*
|
||||
|
||||
tagger 0.2
|
||||
MP3/Ogg Vorbis/AAC file tagger
|
||||
Copyright © 2005-2006 Scott Alfter (http://alfter.us/)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License (version 2) as
|
||||
published by the Free Software Foundation.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "modify.h"
|
||||
|
||||
int modifytag (char* filename, char* title, char* artist, char* album,
|
||||
char* tracknum, char* year, char* genre, char* comment,
|
||||
char* imgfilename, int imgtype)
|
||||
{
|
||||
int rtnval=0;
|
||||
int numconv;
|
||||
int imgsize=0;
|
||||
ByteVector imgbuffer((TagLib::uint)0);
|
||||
|
||||
if (imgfilename!=NULL) // preload image, if necessary
|
||||
{
|
||||
ifstream infile;
|
||||
infile.open(imgfilename,ios_base::binary);
|
||||
if (!infile.is_open())
|
||||
{
|
||||
cerr << "unable to open " << imgfilename << endl;
|
||||
exit(-1);
|
||||
}
|
||||
infile.seekg(0,ios::end);
|
||||
imgsize=infile.tellg();
|
||||
infile.close();
|
||||
infile.open(imgfilename,ios_base::binary);
|
||||
imgbuffer.resize((TagLib::uint)imgsize);
|
||||
infile.read(imgbuffer.data(),imgsize);
|
||||
infile.close();
|
||||
}
|
||||
|
||||
if (strcmp(filename+strlen(filename)-4,".mp3")==0) // MP3
|
||||
{
|
||||
MPEG::File* file=new MPEG::File(filename);
|
||||
ID3v2::Tag* v2tag=file->ID3v2Tag(true);
|
||||
if (title!=NULL)
|
||||
v2tag->setTitle(title);
|
||||
if (artist!=NULL)
|
||||
v2tag->setArtist(artist);
|
||||
if (album!=NULL)
|
||||
v2tag->setAlbum(album);
|
||||
if (tracknum!=NULL)
|
||||
{
|
||||
sscanf(tracknum,"%i",&numconv);
|
||||
v2tag->setTrack(numconv);
|
||||
}
|
||||
if (year!=NULL)
|
||||
{
|
||||
sscanf(year,"%i",&numconv);
|
||||
v2tag->setYear(numconv);
|
||||
}
|
||||
if (genre!=NULL)
|
||||
v2tag->setGenre(genre);
|
||||
if (comment!=NULL)
|
||||
v2tag->setComment(comment);
|
||||
if (imgfilename!=NULL)
|
||||
{
|
||||
v2tag->removeFrames("APIC");
|
||||
ID3v2::AttachedPictureFrame* pic=new ID3v2::AttachedPictureFrame;
|
||||
switch (imgtype)
|
||||
{
|
||||
case 1:
|
||||
pic->setMimeType("image/jpeg");
|
||||
break;
|
||||
case 2:
|
||||
pic->setMimeType("image/png");
|
||||
break;
|
||||
}
|
||||
pic->setType((ID3v2::AttachedPictureFrame::Type)3); // front cover
|
||||
pic->setPicture(imgbuffer);
|
||||
v2tag->addFrame(pic);
|
||||
}
|
||||
file->save();
|
||||
cout << filename << ": ID3 tag modified" << endl;
|
||||
}
|
||||
// else if ((strcmp(filename+strlen(filename)-4,".m4a")==0) ||
|
||||
// (strcmp(filename+strlen(filename)-4,".m4p")==0)) // AAC
|
||||
else if (strcmp(filename+strlen(filename)-4,".m4a")==0) // AAC
|
||||
{
|
||||
int numconv;
|
||||
MP4FileHandle file=MP4Modify(filename);
|
||||
if (file!=MP4_INVALID_FILE_HANDLE)
|
||||
{
|
||||
if (title!=NULL)
|
||||
MP4SetMetadataName(file,title);
|
||||
if (artist!=NULL)
|
||||
MP4SetMetadataArtist(file,artist);
|
||||
if (album!=NULL)
|
||||
MP4SetMetadataAlbum(file,album);
|
||||
if (tracknum!=NULL)
|
||||
{
|
||||
sscanf(tracknum,"%i",&numconv);
|
||||
MP4SetMetadataTrack(file,numconv,0);
|
||||
}
|
||||
if (year!=NULL)
|
||||
MP4SetMetadataYear(file,year);
|
||||
if (genre!=NULL)
|
||||
MP4SetMetadataGenre(file,genre);
|
||||
if (comment!=NULL)
|
||||
MP4SetMetadataComment(file,comment);
|
||||
if (imgfilename!=NULL)
|
||||
{
|
||||
if (imgtype==1)
|
||||
MP4SetMetadataCoverArt(file, (u_int8_t*)imgbuffer.data(), imgbuffer.size());
|
||||
else
|
||||
{
|
||||
cerr << filename << ": MPEG4 tags support JPEG images only" << endl;
|
||||
MP4Close(file);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
MP4Close(file);
|
||||
cout << filename << ": MPEG4 tag modified" << endl;
|
||||
}
|
||||
}
|
||||
else if (strcmp(filename+strlen(filename)-4,".ogg")==0) // Ogg Vorbis
|
||||
{
|
||||
Ogg::Vorbis::File* file=new Ogg::Vorbis::File(filename);
|
||||
Ogg::XiphComment* tag=file->tag();
|
||||
if (title!=NULL)
|
||||
tag->setTitle(title);
|
||||
if (artist!=NULL)
|
||||
tag->setArtist(artist);
|
||||
if (album!=NULL)
|
||||
tag->setAlbum(album);
|
||||
if (tracknum!=NULL)
|
||||
{
|
||||
sscanf(tracknum,"%i",&numconv);
|
||||
tag->setTrack(numconv);
|
||||
}
|
||||
if (year!=NULL)
|
||||
{
|
||||
sscanf(year,"%i",&numconv);
|
||||
tag->setYear(numconv);
|
||||
}
|
||||
if (genre!=NULL)
|
||||
tag->setGenre(genre);
|
||||
if (comment!=NULL)
|
||||
tag->setComment(comment);
|
||||
if (imgfilename!=NULL)
|
||||
cerr << filename << ": file format doesn't support images" << endl;
|
||||
file->save();
|
||||
cout << filename << ": Vorbis tag modified" << endl;
|
||||
}
|
||||
else if (strcmp(filename+strlen(filename)-5,".flac")==0) // FLAC
|
||||
{
|
||||
FLAC::File* file=new FLAC::File(filename);
|
||||
Ogg::XiphComment* tag=file->xiphComment();
|
||||
if (title!=NULL)
|
||||
tag->setTitle(title);
|
||||
if (artist!=NULL)
|
||||
tag->setArtist(artist);
|
||||
if (album!=NULL)
|
||||
tag->setAlbum(album);
|
||||
if (tracknum!=NULL)
|
||||
{
|
||||
sscanf(tracknum,"%i",&numconv);
|
||||
tag->setTrack(numconv);
|
||||
}
|
||||
if (year!=NULL)
|
||||
{
|
||||
sscanf(year,"%i",&numconv);
|
||||
tag->setYear(numconv);
|
||||
}
|
||||
if (genre!=NULL)
|
||||
tag->setGenre(genre);
|
||||
if (comment!=NULL)
|
||||
tag->setComment(comment);
|
||||
if (imgfilename!=NULL)
|
||||
cerr << filename << ": file format doesn't support images" << endl;
|
||||
file->save();
|
||||
cout << filename << ": FLAC tag modified" << endl;
|
||||
}
|
||||
else
|
||||
cout << filename << ": file type not supported" << endl;
|
||||
|
||||
return rtnval;
|
||||
}
|
||||
|
||||
21
src/modify.h
21
src/modify.h
@@ -1,3 +1,24 @@
|
||||
/*
|
||||
|
||||
tagger 0.2
|
||||
MP3/Ogg Vorbis/AAC file tagger
|
||||
Copyright © 2005-2006 Scott Alfter (http://alfter.us/)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License (version 2) as
|
||||
published by the Free Software Foundation.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _ID3MODIFY_H
|
||||
#define _ID3MODIFY_H
|
||||
|
||||
|
||||
@@ -1,3 +1,24 @@
|
||||
/*
|
||||
|
||||
tagger 0.2
|
||||
MP3/Ogg Vorbis/AAC file tagger
|
||||
Copyright © 2005-2006 Scott Alfter (http://alfter.us/)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License (version 2) as
|
||||
published by the Free Software Foundation.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "saveimage.h"
|
||||
|
||||
int saveimage (int argc, char** argv, int startarg)
|
||||
@@ -25,9 +46,10 @@ int saveimage (int argc, char** argv, int startarg)
|
||||
strcpy(outfilename,argv[i]);
|
||||
ID3v2::Frame* frame=imglist.front();
|
||||
ID3v2::AttachedPictureFrame* pic=(ID3v2::AttachedPictureFrame*)frame;
|
||||
cout << pic->mimeType().toCString() << endl;
|
||||
if (strcmp(pic->mimeType().toCString(),"image/png")==0)
|
||||
strcat(outfilename,".png");
|
||||
else if (strcmp(pic->mimeType().toCString(),"image/jpg")==0)
|
||||
else if (strcmp(pic->mimeType().toCString(),"image/jpeg")==0)
|
||||
strcat(outfilename,".jpg");
|
||||
else
|
||||
strcat(outfilename,".bin");
|
||||
@@ -55,9 +77,9 @@ int saveimage (int argc, char** argv, int startarg)
|
||||
char* outfilename=new char[strlen(argv[i])+5];
|
||||
strcpy(outfilename,argv[i]);
|
||||
int* magic=(int*)img;
|
||||
if (*magic==0x474E5089)
|
||||
if (htonl(*magic)==htonl(0x474E5089))
|
||||
strcat(outfilename,".png");
|
||||
else if (*magic==0xE0FFD8FF)
|
||||
else if (htonl(*magic)==htonl(0xE0FFD8FF))
|
||||
strcat(outfilename,".jpg");
|
||||
else
|
||||
strcat(outfilename,".bin");
|
||||
|
||||
@@ -1,3 +1,24 @@
|
||||
/*
|
||||
|
||||
tagger 0.2
|
||||
MP3/Ogg Vorbis/AAC file tagger
|
||||
Copyright © 2005-2006 Scott Alfter (http://alfter.us/)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License (version 2) as
|
||||
published by the Free Software Foundation.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _ID3SAVEIMAGE_H
|
||||
#define _ID3SAVEIMAGE_H
|
||||
|
||||
|
||||
@@ -1,3 +1,24 @@
|
||||
/*
|
||||
|
||||
tagger 0.2
|
||||
MP3/Ogg Vorbis/AAC file tagger
|
||||
Copyright © 2005-2006 Scott Alfter (http://alfter.us/)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License (version 2) as
|
||||
published by the Free Software Foundation.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "tagger.h"
|
||||
#include "view.h"
|
||||
#include "saveimage.h"
|
||||
@@ -21,7 +42,7 @@ int main (int argc, char** argv)
|
||||
char* comment=NULL;
|
||||
char* imgfilename=NULL;
|
||||
ifstream imgfile;
|
||||
uint32 magic;
|
||||
unsigned long magic;
|
||||
int imgtype;
|
||||
|
||||
while ((c=getopt(argc,argv,"hvdGrt:a:l:n:y:g:c:m:"))!=-1) // parse options
|
||||
@@ -57,14 +78,14 @@ int main (int argc, char** argv)
|
||||
imgfile.open(imgfilename,ios_base::binary);
|
||||
imgfile.read((char*)&magic,sizeof(magic));
|
||||
imgfile.close();
|
||||
if ((magic!=0xE0FFD8FF)&&(magic!=0x474E5089))
|
||||
if ((htonl(magic)!=0xFFD8FFE0)&&(htonl(magic)!=0x89504E47))
|
||||
{
|
||||
cerr << "image must be JPEG or PNG" << endl;
|
||||
return -1;
|
||||
}
|
||||
if (magic==0xE0FFD8FF) // JPEG
|
||||
if (htonl(magic)==0xFFD8FFE0) // JPEG
|
||||
imgtype=1;
|
||||
if (magic==0x474E5089) // PNG
|
||||
if (htonl(magic)==0x89504E47) // PNG
|
||||
imgtype=2;
|
||||
break;
|
||||
case 'G':
|
||||
|
||||
23
src/tagger.h
23
src/tagger.h
@@ -1,8 +1,29 @@
|
||||
/*
|
||||
|
||||
tagger 0.2
|
||||
MP3/Ogg Vorbis/AAC file tagger
|
||||
Copyright © 2005-2006 Scott Alfter (http://alfter.us/)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License (version 2) as
|
||||
published by the Free Software Foundation.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _ID3TAGGER_H
|
||||
#define _ID3TAGGER_H
|
||||
|
||||
#include <iostream>
|
||||
#include <id3/tag.h>
|
||||
//#include <id3/tag.h>
|
||||
#include <unistd.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
21
src/view.cpp
21
src/view.cpp
@@ -1,3 +1,24 @@
|
||||
/*
|
||||
|
||||
tagger 0.2
|
||||
MP3/Ogg Vorbis/AAC file tagger
|
||||
Copyright © 2005-2006 Scott Alfter (http://alfter.us/)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License (version 2) as
|
||||
published by the Free Software Foundation.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "view.h"
|
||||
#include "id3v1_genres.h"
|
||||
|
||||
|
||||
21
src/view.h
21
src/view.h
@@ -1,3 +1,24 @@
|
||||
/*
|
||||
|
||||
tagger 0.2
|
||||
MP3/Ogg Vorbis/AAC file tagger
|
||||
Copyright © 2005-2006 Scott Alfter (http://alfter.us/)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License (version 2) as
|
||||
published by the Free Software Foundation.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _ID3VIEW_H
|
||||
#define _ID3VIEW_H
|
||||
|
||||
|
||||
Reference in New Issue
Block a user