Echonest::CatalogUpdateEntry
EchonestCatalogSynchronizer::entryFromTrack( const QStringList& track, Echonest::CatalogTypes::Action action ) const
{
    //qDebug() << "UPLOADING:" << track[0] << track[1] << track[2];
    Echonest::CatalogUpdateEntry entry;
    entry.setAction( action );
    entry.setItemId(track[ 0 ].toLatin1() ); // track dbid
    entry.setSongName( escape( track[ 1 ] ) );
    entry.setArtistName( escape( track[ 2 ] ) );
    entry.setRelease( escape( track[ 3 ] ) );

    return entry;
}
Ejemplo n.º 2
0
void CatalogTest::testCreateUpdateDeleteSong()
{

    {
        Echonest::Catalog c( "CAQBYCW132B7313E1A" );
        QNetworkReply* reply = c.deleteCatalog();
    QEventLoop loop;
    loop.connect( reply, SIGNAL(finished()), SLOT(quit()) );
    loop.exec(); exit(1);}

    try {
        QNetworkReply* reply = Echonest::Catalog::create( QLatin1String( "unittest_catalog_song_X" ), Echonest::CatalogTypes::Song );
    //
        QEventLoop loop;
        loop.connect( reply, SIGNAL(finished()), SLOT(quit()) );
        loop.exec();

        m_songC = Echonest::Catalog::parseCreate( reply );
        qDebug() << "CREATED NEW CATALOG:" << m_songC;
        QVERIFY( !m_songC.id().isEmpty() );
        QVERIFY( !m_songC.name().isEmpty() );
    //     m_songC = Echonest::Catalog( "CAGFEYU12BFD4789A2" ); // for deleting manually a catalog
        Echonest::CatalogUpdateEntry entry;
        entry.setSongName( QLatin1String( "Your Hand In Mine" ) );
        entry.setArtistName( QLatin1String( "Explosions in the sky" ) );
    //     entry.S( "fooid" );
    //     entry.setFingerpring( "FINGERPRINT" );
    //     entry.setRelease( QLatin1String( "FooAlbum:" ) );
    //     entry.setGenre( QLatin1String( "Rock" ) );
    //     entry.setRating( 5 );
    //     entry.setTrackNumber( 5 );
    //     entry.setDiscNumber( 1 );
    //     entry.setUrl( QLatin1String( "myurl" ) );
        entry.setFavorite( true );
        entry.setAction( Echonest::CatalogTypes::Update );
        Echonest::CatalogUpdateEntries entries;
        entries << entry;

        reply = m_songC.update( entries );
        loop.connect( reply, SIGNAL(finished()), SLOT(quit()) );
        loop.exec();

        QByteArray ticket = Echonest::Catalog::parseTicket( reply );
        qDebug() << ticket;

        QVERIFY( !ticket.isEmpty() );
        // now check the ticket status after 10s
        QTest::qWait( 10000 );
        reply = Echonest::Catalog::status( ticket );
        qDebug() << "Getting status info:" << reply->url().toString();
        loop.connect( reply, SIGNAL(finished()), SLOT(quit()) );
        loop.exec();
        Echonest::CatalogStatus cs = Echonest::Catalog::parseStatus( reply );
        qDebug() << "Catalog status:" << cs.status << cs.items_updated << cs.items;

        // now read the catalog
        reply = m_songC.readSongCatalog();
        loop.connect( reply, SIGNAL(finished()), SLOT(quit()) );
        loop.exec();
        m_songC.parseRead( reply );
        qDebug() << m_songC;
        QCOMPARE( m_songC.songs().size(), 1 );
    } catch( const Echonest::ParseError& e ) {
        qWarning() << "Got exception, failing:" << e.what();
        QVERIFY( false );
    }

}