mbtest.cpp 1.64 KB
Newer Older
Zack Rusin's avatar
Zack Rusin committed
1 2 3 4 5 6 7 8 9 10 11 12
//Zack - Pizza license - you agree to eat pizza if you modify this file.
//Compile with :
//g++ -Wall -g -lmusicbrainz -L$QTDIR/lib -L$KDEDIR/lib -I$QTDIR/include -I$KDEDIR/include -lqt-mt -lkdecore musicbrainzquery.cpp mbtest.cpp -o mbtest
//First create mocs of course:
//moc mbtest.cpp -o mbtest.moc
//moc musicbrainzquery.h -o musicbrainzquery.moc
//then "./test some_file.mp3" will identify (or at least try to) the file


#include <kapplication.h>
#include <kdebug.h>

13 14 15
#include "mbtest.h"

TestMB::TestMB( const QString& file ) : QObject(0, "hello") {
Zack Rusin's avatar
Zack Rusin committed
16 17 18 19
    QStringList l;
    l<<file;
    MusicBrainzQuery *query = new MusicBrainzQuery( MusicBrainzQuery::File ,
                                                    l );
20
    connect( query, SIGNAL(signalDone(const MusicBrainzQuery::TrackList&)),
Zack Rusin's avatar
Zack Rusin committed
21 22
             SLOT(slotTrack(const MusicBrainzQuery::TrackList&)) );
    query->start();
23 24 25
}

void TestMB::slotTrack( const MusicBrainzQuery::TrackList& res ) {
Zack Rusin's avatar
Zack Rusin committed
26 27 28 29 30 31 32
    for( MusicBrainzQuery::TrackList::ConstIterator itr = res.begin();
         itr != res.end(); ++itr ) {
      kdDebug() <<"Album     = "<< (*itr).album <<endl;
      kdDebug() <<"Artist    = "<< (*itr).artist << endl;
      kdDebug() <<"Id        = "<< (*itr).id <<endl;
      kdDebug() <<"Name      = "<< (*itr).name <<endl;
      kdDebug() <<"Artist id = "<< (*itr).artistId <<endl;
33
      kdDebug() <<"Song Num  = "<< (*itr).number <<endl;
Zack Rusin's avatar
Zack Rusin committed
34 35
    }
    kapp->quit();
36
}
Zack Rusin's avatar
Zack Rusin committed
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57

#include "mbtest.moc"

int
main( int argc, char **argv )
{
  KApplication app( argc, argv, "test" );

  if ( argc != 2 ) {
    kdDebug()<<"Usage = "<<argv[0]<<" some_file.mp3"<<endl;
    exit(1);
  }

  TestMB mb(argv[1]);

  return app.exec();
}