From c55c6130a0dc0cf34190c3fd4636534e38259fbc Mon Sep 17 00:00:00 2001 From: John Maguire Date: Fri, 6 Feb 2015 15:55:07 +0100 Subject: [PATCH] Remove our copy of libechonest. --- 3rdparty/libechonest/Artist.cpp | 626 ---------- 3rdparty/libechonest/Artist.h | 395 ------ 3rdparty/libechonest/ArtistTypes.cpp | 572 --------- 3rdparty/libechonest/ArtistTypes.h | 390 ------ 3rdparty/libechonest/ArtistTypes_p.h | 166 --- 3rdparty/libechonest/Artist_p.h | 97 -- 3rdparty/libechonest/AudioSummary.cpp | 339 ------ 3rdparty/libechonest/AudioSummary.h | 243 ---- 3rdparty/libechonest/AudioSummary_p.h | 105 -- 3rdparty/libechonest/CMakeLists.txt | 62 - 3rdparty/libechonest/Catalog.cpp | 334 ----- 3rdparty/libechonest/Catalog.h | 225 ---- 3rdparty/libechonest/CatalogArtist.cpp | 59 - 3rdparty/libechonest/CatalogArtist.h | 50 - 3rdparty/libechonest/CatalogItem.cpp | 93 -- 3rdparty/libechonest/CatalogItem.h | 90 -- 3rdparty/libechonest/CatalogItem_p.h | 51 - 3rdparty/libechonest/CatalogSong.cpp | 54 - 3rdparty/libechonest/CatalogSong.h | 49 - 3rdparty/libechonest/CatalogUpdateEntry.cpp | 232 ---- 3rdparty/libechonest/CatalogUpdateEntry.h | 174 --- 3rdparty/libechonest/CatalogUpdateEntry_p.h | 88 -- 3rdparty/libechonest/Catalog_p.h | 57 - 3rdparty/libechonest/Config.cpp | 213 ---- 3rdparty/libechonest/Config.h | 130 -- 3rdparty/libechonest/Generator.cpp | 119 -- 3rdparty/libechonest/Generator_p.h | 40 - 3rdparty/libechonest/Parsing.cpp | 1214 ------------------- 3rdparty/libechonest/Parsing_p.h | 121 -- 3rdparty/libechonest/Playlist.cpp | 422 ------- 3rdparty/libechonest/Playlist.h | 280 ----- 3rdparty/libechonest/Playlist_p.h | 34 - 3rdparty/libechonest/Song.cpp | 432 ------- 3rdparty/libechonest/Song.h | 243 ---- 3rdparty/libechonest/Song_p.h | 67 - 3rdparty/libechonest/Track.cpp | 310 ----- 3rdparty/libechonest/Track.h | 229 ---- 3rdparty/libechonest/Track_p.h | 96 -- 3rdparty/libechonest/TypeInformation.cpp | 183 --- 3rdparty/libechonest/TypeInformation.h | 135 --- 3rdparty/libechonest/Util.cpp | 139 --- 3rdparty/libechonest/Util.h | 132 -- 3rdparty/libechonest/echonest_export.h | 28 - CMakeLists.txt | 6 - debian/control | 1 + dist/clementine.spec.in | 2 +- 46 files changed, 2 insertions(+), 9125 deletions(-) delete mode 100644 3rdparty/libechonest/Artist.cpp delete mode 100644 3rdparty/libechonest/Artist.h delete mode 100644 3rdparty/libechonest/ArtistTypes.cpp delete mode 100644 3rdparty/libechonest/ArtistTypes.h delete mode 100644 3rdparty/libechonest/ArtistTypes_p.h delete mode 100644 3rdparty/libechonest/Artist_p.h delete mode 100644 3rdparty/libechonest/AudioSummary.cpp delete mode 100644 3rdparty/libechonest/AudioSummary.h delete mode 100644 3rdparty/libechonest/AudioSummary_p.h delete mode 100644 3rdparty/libechonest/CMakeLists.txt delete mode 100644 3rdparty/libechonest/Catalog.cpp delete mode 100644 3rdparty/libechonest/Catalog.h delete mode 100644 3rdparty/libechonest/CatalogArtist.cpp delete mode 100644 3rdparty/libechonest/CatalogArtist.h delete mode 100644 3rdparty/libechonest/CatalogItem.cpp delete mode 100644 3rdparty/libechonest/CatalogItem.h delete mode 100644 3rdparty/libechonest/CatalogItem_p.h delete mode 100644 3rdparty/libechonest/CatalogSong.cpp delete mode 100644 3rdparty/libechonest/CatalogSong.h delete mode 100644 3rdparty/libechonest/CatalogUpdateEntry.cpp delete mode 100644 3rdparty/libechonest/CatalogUpdateEntry.h delete mode 100644 3rdparty/libechonest/CatalogUpdateEntry_p.h delete mode 100644 3rdparty/libechonest/Catalog_p.h delete mode 100644 3rdparty/libechonest/Config.cpp delete mode 100644 3rdparty/libechonest/Config.h delete mode 100644 3rdparty/libechonest/Generator.cpp delete mode 100644 3rdparty/libechonest/Generator_p.h delete mode 100644 3rdparty/libechonest/Parsing.cpp delete mode 100644 3rdparty/libechonest/Parsing_p.h delete mode 100644 3rdparty/libechonest/Playlist.cpp delete mode 100644 3rdparty/libechonest/Playlist.h delete mode 100644 3rdparty/libechonest/Playlist_p.h delete mode 100644 3rdparty/libechonest/Song.cpp delete mode 100644 3rdparty/libechonest/Song.h delete mode 100644 3rdparty/libechonest/Song_p.h delete mode 100644 3rdparty/libechonest/Track.cpp delete mode 100644 3rdparty/libechonest/Track.h delete mode 100644 3rdparty/libechonest/Track_p.h delete mode 100644 3rdparty/libechonest/TypeInformation.cpp delete mode 100644 3rdparty/libechonest/TypeInformation.h delete mode 100644 3rdparty/libechonest/Util.cpp delete mode 100644 3rdparty/libechonest/Util.h delete mode 100644 3rdparty/libechonest/echonest_export.h diff --git a/3rdparty/libechonest/Artist.cpp b/3rdparty/libechonest/Artist.cpp deleted file mode 100644 index 0b5510187..000000000 --- a/3rdparty/libechonest/Artist.cpp +++ /dev/null @@ -1,626 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - -#include "Artist.h" -#include "Artist_p.h" -#include "ArtistTypes.h" -#include "Parsing_p.h" - -#include -#include - -Echonest::Artist::Artist() - : d( new ArtistData ) -{ - init(); -} - -Echonest::Artist::Artist( const QByteArray& id, const QString& name ) - : d( new ArtistData ) -{ - init(); - d->id = id; - d->name = name; -} - -Echonest::Artist::Artist( const QString& name ) - : d( new ArtistData ) -{ - init(); - setName( name ); -} - -Echonest::Artist::Artist( const QByteArray& id ) -: d( new ArtistData ) -{ - init(); - setId( id ); -} -Echonest::Artist::Artist(const Echonest::Artist& other) - : d( other.d ) -{ - init(); -} - -Echonest::Artist& Echonest::Artist::operator=(const Echonest::Artist& artist) -{ - d = artist.d; - return *this; -} - -Echonest::Artist::~Artist() -{ - -} - -void Echonest::Artist::init() -{ - qRegisterMetaType("Echonest::Artist"); -} - -QByteArray Echonest::Artist::id() const -{ - return d->id; -} - -QString Echonest::Artist::name() const -{ - return d->name; -} - -void Echonest::Artist::setId(const QByteArray& id) -{ - d->id = id; -} - -void Echonest::Artist::setName(const QString& name) -{ - d->name = name; -} - -Echonest::AudioList Echonest::Artist::audio() const -{ - return d->audio; -} - -void Echonest::Artist::setAudio(const Echonest::AudioList& audio) -{ - d->audio = audio; -} - - -Echonest::BiographyList Echonest::Artist::biographies() const -{ - return d->biographies; -} - -void Echonest::Artist::setBiographies(const Echonest::BiographyList& bios ) -{ - d->biographies = bios; -} - -Echonest::BlogList Echonest::Artist::blogs() const -{ - return d->blogs; -} - -void Echonest::Artist::setBlogs(const Echonest::BlogList& blogs ) -{ - d->blogs = blogs; -} - -qreal Echonest::Artist::familiarity() const -{ - return d->familiarity; -} - -void Echonest::Artist::setFamiliarity(qreal familiar) -{ - d->familiarity = familiar; -} - -qreal Echonest::Artist::hotttnesss() const -{ - return d->hotttnesss; -} - -void Echonest::Artist::setHotttnesss(qreal hotttnesss) -{ - d->hotttnesss = hotttnesss; -} - -Echonest::ArtistImageList Echonest::Artist::images() const -{ - return d->images; -} - -void Echonest::Artist::setImages(const Echonest::ArtistImageList& imgs) -{ - d->images = imgs; -} - -Echonest::NewsList Echonest::Artist::news() const -{ - return d->news; -} - -void Echonest::Artist::setNews(const Echonest::NewsList& news) -{ - d->news = news; -} - -Echonest::ReviewList Echonest::Artist::reviews() const -{ - return d->reviews; -} - -void Echonest::Artist::setReviews(const Echonest::ReviewList& reviews) -{ - d->reviews = reviews; -} - -Echonest::SongList Echonest::Artist::songs() const -{ - return d->songs; -} - -void Echonest::Artist::setSongs(const Echonest::SongList& songs) -{ - d->songs = songs; -} - -Echonest::TermList Echonest::Artist::terms() const -{ - return d->terms; -} - -void Echonest::Artist::setTerms(const Echonest::TermList& terms) -{ - d->terms = terms; -} - -QUrl Echonest::Artist::amazonUrl() const -{ - return d->amazon_url; -} - -void Echonest::Artist::setVideos(const Echonest::VideoList& videos) -{ - d->videos = videos; -} - -void Echonest::Artist::setAmazonUrl(const QUrl& url) -{ - d->amazon_url = url; -} - - -QUrl Echonest::Artist::aolMusicUrl() const -{ - return d->aolmusic_url; -} - -void Echonest::Artist::setAolMusicUrl(const QUrl& url) -{ - d->aolmusic_url = url; -} - -QUrl Echonest::Artist::itunesUrl() const -{ - return d->itunes_url; -} - -void Echonest::Artist::setItunesUrl( const QUrl& url ) -{ - d->itunes_url = url; -} - -QUrl Echonest::Artist::lastFmUrl() const -{ - return d->lastfm_url; -} - -void Echonest::Artist::setLastFmUrl(const QUrl& url ) -{ - d->lastfm_url = url; -} - -QUrl Echonest::Artist::myspaceUrl() const -{ - return d->myspace_url; -} - -void Echonest::Artist::setMyspaceUrl( const QUrl& url ) -{ - d->myspace_url = url; -} - -QUrl Echonest::Artist::musicbrainzUrl() const -{ - return d->mb_url; -} - -void Echonest::Artist::setMusicbrainzUrl(const QUrl& url) -{ - d->mb_url = url; -} - - -Echonest::VideoList Echonest::Artist::videos() const -{ - return d->videos; -} - -Echonest::ForeignIds Echonest::Artist::foreignIds() const -{ - return d->foreign_ids; -} - -void Echonest::Artist::setForeignIds(const Echonest::ForeignIds& ids) -{ - d->foreign_ids = ids; -} - -QNetworkReply* Echonest::Artist::fetchAudio(int numResults, int offset) const -{ - QUrl url = setupQuery( "audio", numResults, offset ); - return Echonest::Config::instance()->nam()->get( QNetworkRequest( url ) ); -} - -QNetworkReply* Echonest::Artist::fetchBiographies(const QString& license, int numResults, int offset) const -{ - QUrl url = setupQuery( "biographies", numResults, offset ); - if( !license.isEmpty() ) - url.addQueryItem( QLatin1String( "license" ), license ); - - return Echonest::Config::instance()->nam()->get( QNetworkRequest( url ) ); -} - -QNetworkReply* Echonest::Artist::fetchBlogs( bool highRelevanceOnly, int numResults, int offset ) const -{ - QUrl url = setupQuery( "blogs", numResults, offset ); - if( highRelevanceOnly ) // false is default - url.addEncodedQueryItem( "high_relevance", "true" ); - - return Echonest::Config::instance()->nam()->get( QNetworkRequest( url ) ); -} - -QNetworkReply* Echonest::Artist::fetchFamiliarity() const -{ - QUrl url = setupQuery( "familiarity", 0, -1 ); - - return Echonest::Config::instance()->nam()->get( QNetworkRequest( url ) ); -} - -QNetworkReply* Echonest::Artist::fetchHotttnesss(const QString& type) const -{ - QUrl url = setupQuery( "hotttnesss", 0, -1 ); - if( type != QLatin1String( "normal" ) ) - url.addQueryItem( QLatin1String( "type" ), type ); - - return Echonest::Config::instance()->nam()->get( QNetworkRequest( url ) ); -} - -QNetworkReply* Echonest::Artist::fetchImages( const QString& license, int numResults, int offset ) const -{ - QUrl url = setupQuery( "images", numResults, offset ); - if( !license.isEmpty() ) - url.addQueryItem( QLatin1String( "license" ), license ); - - return Echonest::Config::instance()->nam()->get( QNetworkRequest( url ) ); -} - -QNetworkReply* Echonest::Artist::fetchProfile(Echonest::ArtistInformation information) const -{ - QUrl url = setupQuery( "profile", 0, -1 ); - addQueryInformation( url, information ); - - return Echonest::Config::instance()->nam()->get( QNetworkRequest( url ) ); -} - -QNetworkReply* Echonest::Artist::fetchNews( bool highRelevanceOnly, int numResults, int offset ) const -{ - QUrl url = setupQuery( "news", numResults, offset ); - if( highRelevanceOnly ) // false is default - url.addEncodedQueryItem( "high_relevance", "true" ); - - return Echonest::Config::instance()->nam()->get( QNetworkRequest( url ) ); -} - -QNetworkReply* Echonest::Artist::fetchReviews(int numResults, int offset) const -{ - QUrl url = setupQuery( "reviews", numResults, offset ); - - return Echonest::Config::instance()->nam()->get( QNetworkRequest( url ) ); -} - -QNetworkReply* Echonest::Artist::fetchSimilar(const Echonest::Artist::SearchParams& params, Echonest::ArtistInformation information, int numResults, int offset ) -{ - QUrl url = Echonest::baseGetQuery( "artist", "similar" ); - addQueryInformation( url, information ); - - if( numResults > 0 ) - url.addEncodedQueryItem( "results", QByteArray::number( numResults ) ); - if( offset >= 0 ) - url.addEncodedQueryItem( "start", QByteArray::number( offset ) ); - - Echonest::Artist::SearchParams::const_iterator iter = params.constBegin(); - for( ; iter < params.constEnd(); ++iter ) - url.addEncodedQueryItem( searchParamToString( iter->first ), Echonest::escapeSpacesAndPluses( iter->second.toString() ) ); - - return Echonest::Config::instance()->nam()->get( QNetworkRequest( url ) ); -} - -QNetworkReply* Echonest::Artist::fetchSongs( int numResults, int offset ) const -{ - QUrl url = setupQuery( "songs", numResults, offset ); - - return Echonest::Config::instance()->nam()->get( QNetworkRequest( url ) ); -} - -QNetworkReply* Echonest::Artist::fetchTerms( Echonest::Artist::TermSorting sorting ) const -{ - QUrl url = setupQuery( "terms", 0, -1 ); - if( sorting == Echonest::Artist::Weight ) - url.addEncodedQueryItem( "sort", "weight" ); - else if( sorting == Echonest::Artist::Frequency ) - url.addEncodedQueryItem( "sort", "frequency" ); - - return Echonest::Config::instance()->nam()->get( QNetworkRequest( url ) ); -} - - -QNetworkReply* Echonest::Artist::fetchUrls() const -{ - QUrl url = setupQuery( "urls", 0, -1 ); - - return Echonest::Config::instance()->nam()->get( QNetworkRequest( url ) ); -} - -QNetworkReply* Echonest::Artist::fetchVideo(int numResults, int offset) const -{ - QUrl url = setupQuery( "video", numResults, offset ); - - return Echonest::Config::instance()->nam()->get( QNetworkRequest( url ) ); -} - -QNetworkReply* Echonest::Artist::search(const Echonest::Artist::SearchParams& params, Echonest::ArtistInformation information, bool limit) -{ - QUrl url = Echonest::baseGetQuery( "artist", "search" ); - - Echonest::Artist::SearchParams::const_iterator iter = params.constBegin(); - for( ; iter < params.constEnd(); ++iter ) - url.addEncodedQueryItem( searchParamToString( iter->first ), Echonest::escapeSpacesAndPluses( iter->second.toString() ) ); - url.addEncodedQueryItem( "limit", limit ? "true" : "false" ); - addQueryInformation( url, information ); - - return Echonest::Config::instance()->nam()->get( QNetworkRequest( url ) ); -} - -QNetworkReply* Echonest::Artist::topHottt(Echonest::ArtistInformation information, int numResults, int offset, bool limit) -{ - QUrl url = Echonest::baseGetQuery( "artist", "top_hottt" ); - addQueryInformation( url, information ); - - if( numResults > 0 ) - url.addEncodedQueryItem( "results", QByteArray::number( numResults ) ); - if( offset >= 0 ) - url.addEncodedQueryItem( "start", QByteArray::number( offset ) ); - - url.addEncodedQueryItem( "limit", limit ? "true" : "false" ); - - return Echonest::Config::instance()->nam()->get( QNetworkRequest( url ) ); -} - -QNetworkReply* Echonest::Artist::topTerms(int numResults) -{ - QUrl url = Echonest::baseGetQuery( "artist", "top_terms" ); - url.addEncodedQueryItem( "results", QByteArray::number( numResults ) ); - - return Echonest::Config::instance()->nam()->get( QNetworkRequest( url ) ); -} - -QNetworkReply* Echonest::Artist::listTerms( const QString& type ) -{ - QUrl url = Echonest::baseGetQuery( "artist", "list_terms" ); - url.addQueryItem( QLatin1String( "type" ), type ); - - return Echonest::Config::instance()->nam()->get( QNetworkRequest( url ) ); -} - - -QNetworkReply* Echonest::Artist::suggest( const QString& name, int results ) -{ - QUrl url = Echonest::baseGetQuery( "artist", "suggest" ); - QString realname = name; - url.addEncodedQueryItem( "name", Echonest::escapeSpacesAndPluses( realname ) ); - url.addEncodedQueryItem( "results", QByteArray::number( results ) ); - - return Echonest::Config::instance()->nam()->get( QNetworkRequest( url ) ); -} - - -int Echonest::Artist::parseProfile( QNetworkReply* reply ) throw( Echonest::ParseError ) -{ - Echonest::Parser::checkForErrors( reply ); - - QXmlStreamReader xml( reply->readAll() ); - - Echonest::Parser::readStatus( xml ); - - int numResults = Echonest::Parser::parseArtistInfoOrProfile( xml, *this ); - - reply->deleteLater(); - return numResults; -} - -Echonest::Artists Echonest::Artist::parseSearch( QNetworkReply* reply ) throw( Echonest::ParseError ) -{ - Echonest::Parser::checkForErrors( reply ); - - QByteArray data = reply->readAll(); - QXmlStreamReader xml( data ); - - Echonest::Parser::readStatus( xml ); - - Echonest::Artists artists = Echonest::Parser::parseArtists( xml ); - - reply->deleteLater(); - return artists; -} - -Echonest::Artists Echonest::Artist::parseSimilar( QNetworkReply* reply ) throw( Echonest::ParseError ) -{ - return parseSearch( reply ); -} - -Echonest::Artists Echonest::Artist::parseTopHottt( QNetworkReply* reply ) throw( Echonest::ParseError ) -{ - return parseSearch( reply ); -} - -Echonest::TermList Echonest::Artist::parseTopTerms( QNetworkReply* reply ) throw( Echonest::ParseError ) -{ - Echonest::Parser::checkForErrors( reply ); - - QXmlStreamReader xml( reply->readAll() ); - - Echonest::Parser::readStatus( xml ); - - Echonest::TermList terms = Echonest::Parser::parseTopTermList( xml ); - - reply->deleteLater(); - return terms; -} - -Echonest::Artists Echonest::Artist::parseSuggest( QNetworkReply* reply ) throw( Echonest::ParseError ) -{ - Echonest::Parser::checkForErrors( reply ); - - QXmlStreamReader xml( reply->readAll() ); - - Echonest::Parser::readStatus( xml ); - - Echonest::Artists artists = Echonest::Parser::parseArtistSuggestList( xml ); - - reply->deleteLater(); - return artists; -} - -QVector< QString > Echonest::Artist::parseTermList( QNetworkReply* reply ) throw( Echonest::ParseError ) -{ - Echonest::Parser::checkForErrors( reply ); - - QXmlStreamReader xml( reply->readAll() ); - - Echonest::Parser::readStatus( xml ); - - QVector< QString > terms = Echonest::Parser::parseTermList( xml ); - - reply->deleteLater(); - return terms; -} - -QUrl Echonest::Artist::setupQuery( const QByteArray& methodName, int numResults, int start ) const -{ - QUrl url = Echonest::baseGetQuery( "artist", methodName ); - if( !d->id.isEmpty() ) - url.addEncodedQueryItem( "id", d->id ); - else if( !d->name.isEmpty() ) { - url.addEncodedQueryItem( "name", Echonest::escapeSpacesAndPluses( d->name ) ); - } else { - qWarning() << "Artist method" << methodName << "called on an artist object without name or id!"; - return QUrl(); - } - if( numResults > 0 ) - url.addEncodedQueryItem( "results", QByteArray::number( numResults ) ); - if( start >= 0 ) - url.addEncodedQueryItem( "start", QByteArray::number( start ) ); - - return url; -} - -QByteArray Echonest::Artist::searchParamToString(Echonest::Artist::SearchParam param) -{ - switch( param ) - { - case Id: - return "id"; - case Name: - return "name"; - case Results: - return "results"; - case Description: - return "description"; - case FuzzyMatch: - return "fuzzy_match"; - case MaxFamiliarity: - return "max_familiarity"; - case MinFamiliarity: - return "min_familiarity"; - case MaxHotttnesss: - return "max_hotttnesss"; - case MinHotttnesss: - return "min_hotttnesss"; - case Reverse: - return "reverse"; - case Sort: - return "sort"; - case Mood: - return "mood"; - case IdSpace: - return "bucket"; - default: - return ""; - } -} - -void Echonest::Artist::addQueryInformation(QUrl& url, Echonest::ArtistInformation information) -{ - if( information.flags().testFlag( Echonest::ArtistInformation::Audio ) ) - url.addEncodedQueryItem( "bucket", "audio" ); - if( information.flags().testFlag( Echonest::ArtistInformation::Biographies ) ) - url.addEncodedQueryItem( "bucket", "biographies" ); - if( information.flags().testFlag( Echonest::ArtistInformation::Blogs ) ) - url.addEncodedQueryItem( "bucket", "blogs" ); - if( information.flags().testFlag( Echonest::ArtistInformation::Familiarity ) ) - url.addEncodedQueryItem( "bucket", "familiarity" ); - if( information.flags().testFlag( Echonest::ArtistInformation::Hotttnesss ) ) - url.addEncodedQueryItem( "bucket", "hotttnesss" ); - if( information.flags().testFlag( Echonest::ArtistInformation::Images ) ) - url.addEncodedQueryItem( "bucket", "images" ); - if( information.flags().testFlag( Echonest::ArtistInformation::News ) ) - url.addEncodedQueryItem( "bucket", "news" ); - if( information.flags().testFlag( Echonest::ArtistInformation::Reviews ) ) - url.addEncodedQueryItem( "bucket", "reviews" ); - if( information.flags().testFlag( Echonest::ArtistInformation::Terms ) ) - url.addEncodedQueryItem( "bucket", "terms" ); - if( information.flags().testFlag( Echonest::ArtistInformation::Urls ) ) - url.addEncodedQueryItem( "bucket", "urls" ); - if( information.flags().testFlag( Echonest::ArtistInformation::Videos ) ) - url.addEncodedQueryItem( "bucket", "video" ); - - if( !information.idSpaces().isEmpty() ) { - foreach( const QString& idSpace, information.idSpaces() ) - url.addEncodedQueryItem( "bucket", "id:" + idSpace.toUtf8() ); - } -} - - -QDebug Echonest::operator<<(QDebug d, const Echonest::Artist& artist) -{ - return d.maybeSpace() << QString::fromLatin1( "Artist(%1, %2)" ).arg( artist.name() ).arg( QString::fromLatin1(artist.id()) ); -} diff --git a/3rdparty/libechonest/Artist.h b/3rdparty/libechonest/Artist.h deleted file mode 100644 index 54274305c..000000000 --- a/3rdparty/libechonest/Artist.h +++ /dev/null @@ -1,395 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - - -#ifndef ECHONEST_ARTIST_H -#define ECHONEST_ARTIST_H - - -#include "ArtistTypes.h" -#include "Config.h" -#include "echonest_export.h" -#include "TypeInformation.h" -#include "Song.h" - -#include -#include -#include - -class QNetworkReply; -class ArtistData; -class Term; -namespace Echonest{ - - class Biography; - class Catalog; - - class Artist; - typedef QVector< Artist > Artists; - - /** - * This encapsulates an Echo Nest artist---it always holds the basic info of artist id and - * artist name, and can be queried for more data. - * - * It is also possible to fetch more information from a given artist name or ID by creating an Artist - * object yourself and calling the fetch() functions directly. - */ - class ECHONEST_EXPORT Artist - { - - public: - enum TermSorting { - Weight, - Frequency - } ; - - /** - * The following are the various search parameters to the search() and similar() functions. - * - * Not all are acceptable for each API call, check the API documentation at - * http://developer.echonest.com/docs/v4/artist.html#search for details. - * - * - id QVector< QByteArray > A list of the artist IDs to be searched (e.g. [ARH6W4X1187B99274F, musicbrainz:artist:a74b1b7f-71a5-4011-9441-d0b5e4122711 ,ARH6W4X1187B99274F^2]) - * - name QVector< QString > A list of artist names to be searched (e.g. [Weezer, the beatles ,the beatles^0.5]) - * - description QVector< QString > A list of descriptors [ alt-rock,-emo,harp^2 ] - * - results 0 < results < 200, (Default=15) The number of results desired - * - min_results 0 < results < 200, (Default=0) Indicates the minimum number of results to be returned regardless of constraints - * - max_familiarity 0.0 < familiarity < 1.0 The maximum familiarity for returned artists - * - min_familiarity 0.0 < familiarity < 1.0 The minimum familiarity for returned artists - * - max_hotttnesss 0.0 < hotttnesss < 1.0 The maximum hotttnesss for returned artists - * - min_hotttness 0.0 < hotttnesss < 1.0 The minimum hotttnesss for returned artists - * - reverse [true, false] If true, return artists that are disimilar to the seeds - * -sort QString How to sort the results. Options: familiarity-asc, hotttnesss-asc, familiarity-desc, hotttnesss-desc. - * - */ - enum SearchParam { - Id, - Name, - Results, - Description, - FuzzyMatch, - MaxFamiliarity, - MinFamiliarity, - MaxHotttnesss, - MinHotttnesss, - Reverse, - Sort, - IdSpace, - Mood - }; - typedef QPair< Echonest::Artist::SearchParam, QVariant > SearchParamEntry; - typedef QVector< SearchParamEntry > SearchParams; - - Artist(); - Artist( const QByteArray& id, const QString& name ); - explicit Artist( const QString& name ); - explicit Artist( const QByteArray& id ); - - Artist( const Artist& other ); - Artist& operator=( const Artist& artist ); - virtual ~Artist(); - - void init(); - - QByteArray id() const; - void setId( const QByteArray& id ); - - QString name() const; - void setName( const QString& name ); - - /** - * The following require fetching from The Echo Nest, so return a QNetworkReply* - * that is ready for parsing when the finished() signal is emitted. - * - * Call parseProfile() on the Artist object to populate it with the result of the - * query. - * - */ - - /** - * A list of audio files on the web for this artist. - */ - AudioList audio() const; - void setAudio( const AudioList& ); - - /** - * A list of biographies for this artist. - */ - BiographyList biographies() const; - void setBiographies( const BiographyList& ); - - /** - * Blogs about this artist, around the web. - */ - BlogList blogs() const; - void setBlogs( const BlogList& ); - - /** - * How familiar this artist is. - */ - qreal familiarity() const; - void setFamiliarity( qreal familiar ); - - /** - * The hotttness of this artist. - */ - qreal hotttnesss() const; - void setHotttnesss( qreal hotttnesss ); - - /** - * Images related to this artist. - */ - ArtistImageList images() const; - void setImages( const ArtistImageList& ); - - /** - * News about this artist. - */ - NewsList news() const; - void setNews( const NewsList& ); - - /** - * Reviews of this artist - */ - ReviewList reviews() const; - void setReviews( const ReviewList& ); - - /** - * Echo Nest song objects belonging to this artist. - */ - SongList songs() const; - void setSongs( const SongList& ); - - /** - * Terms describing this artist. - */ - TermList terms() const; - void setTerms( const TermList& ); - - /** - * Urls pointing to this artists' basic information around the web. - */ - QUrl lastFmUrl() const; - void setLastFmUrl( const QUrl& ); - QUrl aolMusicUrl() const; - void setAolMusicUrl( const QUrl& ); - QUrl amazonUrl() const; - void setAmazonUrl( const QUrl& ); - QUrl itunesUrl() const; - void setItunesUrl( const QUrl& ); - QUrl myspaceUrl() const; - void setMyspaceUrl( const QUrl& ); - QUrl musicbrainzUrl() const; - void setMusicbrainzUrl( const QUrl& url ); - - /** - * Videos related to this artist. - */ - VideoList videos() const; - void setVideos( const VideoList& ); - - /** - * The list of foreign ids for this artist, if fetched. - */ - ForeignIds foreignIds() const; - void setForeignIds( const ForeignIds& ids ); - - /** - * Fetch a list of audio documents found on the web that are related to this artist. - * - * @param numResults Limit how many results are returned - * @param offset The offset of the results, if paging through results in increments. - */ - QNetworkReply* fetchAudio( int numResults = 0, int offset = -1 ) const; - - /** - * Fetch a list of biographies for this artist from various places on the web. - */ - QNetworkReply* fetchBiographies( const QString& license = QString(), int numResults = 0, int offset = -1 ) const; - - /** - * Fetch a list of blog articles relating to this artist. - */ - QNetworkReply* fetchBlogs( bool highRelevanceOnly = false, int numResults = 0, int offset = -1 ) const; - - /** - * Fetch The Echo Nest's numerical estimate of how familiar this artist is to the world. - */ - QNetworkReply* fetchFamiliarity() const; - - /** - * Fetch the numerical description of how hot this artist is. - * - * Currently the only supported type is 'normal' - */ - QNetworkReply* fetchHotttnesss( const QString& type = QLatin1String( "normal" ) ) const; - - /** - * Fetch a list of images related to this artist. - */ - QNetworkReply* fetchImages( const QString& license = QString(), int numResults = 0, int offset = -1 ) const; - - /** - * Fetch a list of news articles found on the web related to this artist. - */ - QNetworkReply* fetchNews( bool highRelevanceOnly = false, int numResults = 0, int offset = -1 ) const; - - /** - * Fetch any number of pieces of artist information all at once. - */ - QNetworkReply* fetchProfile( ArtistInformation information = ArtistInformation() ) const; - - /** - * Fetch reviews related to the artist. - */ - QNetworkReply* fetchReviews( int numResults = 0, int offset = -1 ) const; - - /** - * Fetch a list of songs created by this artist. - */ - QNetworkReply* fetchSongs( int numResults = 0, int offset = -1 ) const; - - /** - * Fetch a list of the most descriptive terms for this artist. - */ - QNetworkReply* fetchTerms( TermSorting sorting = Frequency ) const; - - /** - * Fetch links to the artist's official site, MusicBrainz site, MySpace site, Wikipedia article, Amazon list, and iTunes page. - */ - QNetworkReply* fetchUrls() const; - - /** - * Fetch a list of video documents found on the web related to an artist. - */ - QNetworkReply* fetchVideo( int numResults = 0, int offset = -1 ) const; - - - /** - * Parse a completed QNetworkReply* that has fetched more information about this artist. - * This will update the artist object with the new values that have been fetched. - * - * @return The number of results available on the server. - */ - int parseProfile( QNetworkReply* ) throw( ParseError ); - - /** - * Fetch a list of similar artists given one or more artists for comparison. - * - * Up to five artist names or ids can be included for the similarity search. - * - * - * So they are passed as a list of [paramname, paramvalue] to be included in the query. - * - * Boosting: This method can take multiple seed artists. You an give a seed artist more or less weight by boosting the artist. A boost is an - * affinity for a seed that gives it more or less weight when making calculations based on the argument. In case seeds are not meant to be equally - * valued, the boost can help clarify where along a spectrum each argument falls. The boost is a positive floating point value, where 1 gives the normal - * weight. It is signified by appending a caret and weight to the argument. - * - * See http://developer.echonest.com/docs/v4/artist.html#similar for boosting examples. - * - * Call parseSimilar() once the returned QNetworkReply* has emitted its finished() signal - */ - static QNetworkReply* fetchSimilar( const SearchParams& params, ArtistInformation information = ArtistInformation(), int numResults = 0, int offset = -1 ); - - /** - * Search for artists. - * - * Warning: If limit is set to true, at least one idspace must also be provided. - * - * One of name or description is required, but only one can be used in a query at one time - * - */ - static QNetworkReply* search( const SearchParams& params, ArtistInformation information = ArtistInformation(), bool limit = false ); - - /** - * Fetch a list of the current top artists in terms of hotttnesss. - * - * Warning If limit is set to true, at least one idspace must also be provided in the bucket parameter. - * - */ - static QNetworkReply* topHottt( ArtistInformation information = ArtistInformation(), int numResults = 0, int offset = -1, bool limit = false ); - - /** - * Fetch a list of the top overall terms. - */ - static QNetworkReply* topTerms( int numResults = 15 ); - - /** - * Suggest artists based on a partial name. - * - * \param results How many results to return, between 0 and 15. Default is 10 - */ - static QNetworkReply* suggest( const QString& name, int results = 10 ); - - /** - * Returns a list of terms of the given type, for use in other calls. - * - * \param type Which type of term to return, at the moment only 'style' or 'mood' - */ - static QNetworkReply* listTerms( const QString& type = QLatin1String("style") ); - - /** - * Parse the result of a fetchSimilar() call, which returns a list of artists similar to the - * original pair. - */ - static Artists parseSimilar( QNetworkReply* ) throw( ParseError ); - - /** - * Parse the result of an artist search. - */ - static Artists parseSearch( QNetworkReply* ) throw( ParseError ); - - /** - * Parse the result of a top hottness query. - */ - static Artists parseTopHottt( QNetworkReply* ) throw( ParseError ); - - /** - * Parse the result of a top terms query. - */ - static TermList parseTopTerms( QNetworkReply* ) throw( ParseError ); - - /** - * Parse the result of a suggest query - * - * Returns a list of suggested artists - */ - static Artists parseSuggest( QNetworkReply* ) throw( ParseError ); - - /** - * Parse the result of a termList query. Returns the list of values returned. - */ - static QVector< QString > parseTermList( QNetworkReply* ) throw( ParseError ); - - private: - QUrl setupQuery( const QByteArray& methodName, int numResults = 0, int start = -1 ) const; - - static QByteArray searchParamToString( SearchParam param ); - static void addQueryInformation( QUrl& url, ArtistInformation information ); - - QSharedDataPointer d; - - friend class Catalog; - }; - - ECHONEST_EXPORT QDebug operator<<(QDebug d, const Echonest::Artist& artist); - -} // namespace - -Q_DECLARE_METATYPE( Echonest::Artist ) - -#endif diff --git a/3rdparty/libechonest/ArtistTypes.cpp b/3rdparty/libechonest/ArtistTypes.cpp deleted file mode 100644 index 43ff794a1..000000000 --- a/3rdparty/libechonest/ArtistTypes.cpp +++ /dev/null @@ -1,572 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - -#include "ArtistTypes.h" - -#include "ArtistTypes_p.h" - -#include -#include - -Echonest::ArtistImage::ArtistImage() : d( new ArtistImageData ) -{ - -} - -Echonest::ArtistImage::ArtistImage(const Echonest::ArtistImage& other) -{ - d = other.d; -} - -Echonest::ArtistImage& Echonest::ArtistImage::operator=(const Echonest::ArtistImage& img) -{ - d = img.d; - return *this; -} - -Echonest::ArtistImage::~ArtistImage() -{ - -} - - -QUrl Echonest::ArtistImage::url() const -{ - return d->url; -} - -void Echonest::ArtistImage::setUrl(const QUrl& url) -{ - d->url = url; -} - -Echonest::License Echonest::ArtistImage::license() const -{ - return d->license; -} - -void Echonest::ArtistImage::setLicense(const Echonest::License& license) -{ - d->license = license; -} - -Echonest::AudioFile::AudioFile() : d( new AudioFileData ) -{ - -} - -Echonest::AudioFile::AudioFile(const Echonest::AudioFile& other) -{ - d = other.d; -} - -Echonest::AudioFile& Echonest::AudioFile::operator=(const Echonest::AudioFile& artist) -{ - d = artist.d; - return *this; -} - -Echonest::AudioFile::~AudioFile() -{ - -} - -void Echonest::AudioFile::setTitle(const QString& title) -{ - d->title = title; -} - -QString Echonest::AudioFile::title() const -{ - return d->title; -} - - -QString Echonest::AudioFile::artist() const -{ - return d->artist; -} - -void Echonest::AudioFile::setArtist(const QString& artist) -{ - d->artist = artist; -} - -QDateTime Echonest::AudioFile::date() const -{ - return d->date; -} - -void Echonest::AudioFile::setDate(const QDateTime& date) -{ - d->date = date; -} - -QString Echonest::AudioFile::release() const -{ - return d->release; -} - -void Echonest::AudioFile::setRelease(const QString& release) -{ - d->release = release; -} - -QByteArray Echonest::AudioFile::id() const -{ - return d->id; -} - -void Echonest::AudioFile::setId(const QByteArray& id) -{ - d->id = id; -} - -qreal Echonest::AudioFile::length() const -{ - return d->length; -} - -void Echonest::AudioFile::setLength(qreal length) -{ - d->length = length; -} - -QUrl Echonest::AudioFile::link() const -{ - return d->link; -} - -void Echonest::AudioFile::setLink(const QUrl& url) -{ - d->link = url; -} - -QUrl Echonest::AudioFile::url() const -{ - return d->url; -} - -void Echonest::AudioFile::setUrl(const QUrl& url) -{ - d->url = url; -} - -Echonest::Biography::Biography() : d( new BiographyData ) -{ - -} - -Echonest::Biography::Biography(const Echonest::Biography& other) -{ - d = other.d; -} - -Echonest::Biography& Echonest::Biography::operator=(const Echonest::Biography& biblio) -{ - d = biblio.d; - return *this; -} - -Echonest::Biography::~Biography() -{ - -} - -Echonest::License Echonest::Biography::license() const -{ - return d->license; -} - -void Echonest::Biography::setLicense(const Echonest::License& license) -{ - d->license = license; -} - -QString Echonest::Biography::site() const -{ - return d->site; -} - -void Echonest::Biography::setSite(const QString& site) -{ - d->site = site; -} - -QString Echonest::Biography::text() const -{ - return d->text; -} - -void Echonest::Biography::setText(const QString& text) -{ - d->text = text; -} - -QUrl Echonest::Biography::url() const -{ - return d->url; -} - -void Echonest::Biography::setUrl(const QUrl& url) -{ - d->url = url; -} - -Echonest::Blog::Blog() : d( new BlogData ) -{ - -} - -Echonest::Blog::Blog(const Echonest::Blog& other) : d( other.d ) -{ - -} - -Echonest::Blog& Echonest::Blog::operator=(const Echonest::Blog& other) -{ - d = other.d; - return *this; -} - -Echonest::Blog::~Blog() -{ - -} - - -QDateTime Echonest::Blog::dateFound() const -{ - return d->date_found; -} - -void Echonest::Blog::setDateFound(const QDateTime& date) -{ - d->date_found = date; -} - -QDateTime Echonest::Blog::datePosted() const -{ - return d->date_posted; -} - -void Echonest::Blog::setDatePosted(const QDateTime& date) -{ - d->date_posted = date; -} - -QByteArray Echonest::Blog::id() const -{ - return d->id; -} - -void Echonest::Blog::setId(const QByteArray& id) -{ - d->id = id; -} - -QString Echonest::Blog::name() const -{ - return d->name; -} - -void Echonest::Blog::setName(const QString& name) -{ - d->name = name; -} - -QString Echonest::Blog::summary() const -{ - return d->summary; -} - -void Echonest::Blog::setSummary(const QString& text) -{ - d->summary = text; -} - -QUrl Echonest::Blog::url() const -{ - return d->url; -} - -void Echonest::Blog::setUrl(const QUrl& url) -{ - d->url = url; -} - -Echonest::Review::Review() : d( new ReviewData ) -{ - -} - -Echonest::Review::Review(const Echonest::Review& other) : d( other.d ) -{ - -} - -Echonest::Review& Echonest::Review::operator=(const Echonest::Review& other) -{ - d = other.d; - return *this; -} - -Echonest::Review::~Review() -{ - -} - - -QDateTime Echonest::Review::dateFound() const -{ - return d->date_found; -} - -void Echonest::Review::setDateFound(const QDateTime& date) -{ - d->date_found = date; -} - -QDateTime Echonest::Review::dateReviewed() const -{ - return d->date_reviewed; -} - -void Echonest::Review::setDateReviewed(const QDateTime& date) -{ - d->date_reviewed = date; -} - -QByteArray Echonest::Review::id() const -{ - return d->id; -} - -void Echonest::Review::setId(const QByteArray& id) -{ - d->id = id; -} - -QUrl Echonest::Review::imageUrl() const -{ - return d->image_url; -} - -void Echonest::Review::setImageUrl(const QUrl& imageUrl) -{ - d->image_url = imageUrl; -} - -QString Echonest::Review::name() const -{ - return d->name; -} - -void Echonest::Review::setName(const QString& name) -{ - d->name = name; -} - -QString Echonest::Review::release() const -{ - return d->release; -} - -void Echonest::Review::setRelease(const QString& release) -{ - d->release = release; -} - -QString Echonest::Review::summary() const -{ - return d->summary; -} - -void Echonest::Review::setSummary(const QString& text) -{ - d->summary = text; -} - -QUrl Echonest::Review::url() const -{ - return d->url; -} - -void Echonest::Review::setUrl(const QUrl& url) -{ - d->url = url; -} - -Echonest::Term::Term() : d( new TermData ) -{ - -} - -Echonest::Term::Term(const Echonest::Term& other) : d( other.d ) -{ - -} - -Echonest::Term& Echonest::Term::operator=(const Echonest::Term& other) -{ - d = other.d; - return *this; -} - -Echonest::Term::~Term() -{ - -} - -qreal Echonest::Term::frequency() const -{ - return d->frequency; -} - -void Echonest::Term::setFrequency(qreal freq) -{ - d->frequency = freq; -} - -QString Echonest::Term::name() const -{ - return d->name; -} - -void Echonest::Term::setName(const QString& name) -{ - d->name = name; -} - -qreal Echonest::Term::weight() const -{ - return d->weight; -} - -void Echonest::Term::setWeight(qreal weight) -{ - d->weight = weight; -} - -Echonest::Video::Video() : d( new VideoData ) -{ - -} - -Echonest::Video::Video(const Echonest::Video& other) : d( other.d ) -{ - -} - -Echonest::Video& Echonest::Video::operator=(const Echonest::Video& other) -{ - d = other.d; - return *this; -} - -Echonest::Video::~Video() -{ - -} - -QDateTime Echonest::Video::dateFound() const -{ - return d->date_found; -} - -void Echonest::Video::setDateFound(const QDateTime& date) -{ - d->date_found = date; -} - -QByteArray Echonest::Video::id() const -{ - return d->id; -} - -void Echonest::Video::setId(const QByteArray& id) -{ - d->id = id; -} - -QUrl Echonest::Video::imageUrl() const -{ - return d->image_url; -} - -void Echonest::Video::setImageUrl(const QUrl& imageUrl) -{ - d->image_url = imageUrl; -} - -QString Echonest::Video::site() const -{ - return d->site; -} - -void Echonest::Video::setSite(const QString& site) -{ - d->site = site; -} - -QString Echonest::Video::title() const -{ - return d->title; -} - -void Echonest::Video::setTitle(const QString& title) -{ - d->title = title; -} - -QUrl Echonest::Video::url() const -{ - return d->url; -} - -void Echonest::Video::setUrl(const QUrl& url) -{ - d->url = url; -} - -QDebug Echonest::operator<<(QDebug d, const Echonest::AudioFile& audio) -{ - return d.maybeSpace() << QString::fromLatin1( "AudioFile [%1, %2, %3, %4]" ).arg( audio.title() ) .arg( audio.artist() ).arg( audio.release() ).arg( audio.url().toString() ); -} -QDebug Echonest::operator<<(QDebug d, const Echonest::Biography& biblio) -{ - return d.maybeSpace() << QString::fromLatin1( "Bibliography [%1, %2, %3, %4]" ).arg( biblio.site() ).arg( biblio.url().toString() ).arg( biblio.license().type ).arg( biblio.text().left( 100 ) ); -} -QDebug Echonest::operator<<(QDebug d, const Echonest::Blog& blog) -{ - return d.maybeSpace() << QString::fromLatin1( "Blog [%1, %2, %3, %4, %5, %6]" ).arg( blog.name() ).arg( blog.datePosted().toString() ).arg( blog.dateFound().toString() ).arg( blog.url().toString() ).arg( QLatin1String( blog.id() ) ).arg( blog.summary().left( 100 ) ); -} -QDebug Echonest::operator<<(QDebug d, const Echonest::ArtistImage& img) -{ - return d.maybeSpace() << QString::fromLatin1( "ArtistImage [%1, %2]" ).arg( img.url().toString() ).arg( img.license().type ); -} -QDebug Echonest::operator<<(QDebug d, const Echonest::Review& review) -{ - return d.maybeSpace() << QString::fromLatin1( "Review [%1, %2, %3]" ).arg( review.name() ).arg( review.release() ).arg( review.summary().left( 100 ) ); -} -QDebug Echonest::operator<<(QDebug d, const Echonest::Term& term) -{ - return d.maybeSpace() << QString::fromLatin1( "Term [%1, %2, %3]" ).arg( term.name() ).arg( term.frequency() ).arg( term.weight() ); -} -QDebug Echonest::operator<<(QDebug d, const Echonest::Video& video) -{ - return d.maybeSpace() << QString::fromLatin1( "Video [%1, %2, %3]" ).arg( video.title() ).arg( video.site() ).arg( video.url().toString() ); -} diff --git a/3rdparty/libechonest/ArtistTypes.h b/3rdparty/libechonest/ArtistTypes.h deleted file mode 100644 index 420604905..000000000 --- a/3rdparty/libechonest/ArtistTypes.h +++ /dev/null @@ -1,390 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - -#ifndef ECHONEST_ARTISTTYPES_H -#define ECHONEST_ARTISTTYPES_H - -#include "echonest_export.h" -#include "Util.h" - -#include -#include - -class QDateTime; -class QUrl; -class AudioFileData; -class BiographyData; -class BlogData; -class ArtistImageData; -class ReviewData; -class TermData; -class VideoData; - -namespace Echonest{ - - /** - * A link to an audio file related to an artist on the web. - */ - class ECHONEST_EXPORT AudioFile - { - - public: - AudioFile(); - AudioFile( const AudioFile& other ); - AudioFile& operator=( const AudioFile& artist ); - ~AudioFile(); - - /** - * The title of the audio file. - */ - QString title() const; - void setTitle( const QString& title ); - - /** - * The artist name that this audio file is related to. - */ - QString artist() const; - void setArtist( const QString& ); - - /** - * The URL pointing to the audio file. - */ - QUrl url() const; - void setUrl( const QUrl& url ); - - /** - * The length of the referenced audio file. - */ - qreal length() const; - void setLength( qreal length ); - - /** - * The link to the website where the audio file is from. - */ - QUrl link() const; - void setLink( const QUrl& url ); - - /** - * The date that this audio was posted. - */ - QDateTime date() const; - void setDate( const QDateTime& ); - - /** - * The released album name of this audio file. - */ - QString release() const; - void setRelease( const QString& release ); - - /** - * The unique identifier for this artist audio file. - */ - QByteArray id() const; - void setId( const QByteArray& id ); - - private: - QSharedDataPointer d; - }; - - /** - * A biography of an artist, including the full text content - * of the biography itself. - */ - class ECHONEST_EXPORT Biography { - - public: - Biography(); - Biography( const Biography& other ); - Biography& operator=( const Biography& biblio ); - ~Biography(); - - /** - * The URL to the biography. - */ - QUrl url() const; - void setUrl( const QUrl& url ); - - /** - * The text contents of the biography. May be very long. - */ - QString text() const; - void setText( const QString& text ); - - /** - * The site that this biography is from. - */ - QString site() const; - void setSite( const QString& site ); - - /** - * The license that this biography is licensed under. - */ - License license() const; - void setLicense( const License& license ); - private: - QSharedDataPointer d; - }; - - /** - * A blog post about a certain artist or track. - */ - class ECHONEST_EXPORT Blog { - - public: - Blog(); - Blog( const Blog& other ); - Blog& operator=( const Blog& other ); - ~Blog(); - - /** - * The name of the blog or news article. - */ - QString name() const; - void setName( const QString& name ); - - /** - * The URL to the blog post or news article. - */ - QUrl url() const; - void setUrl( const QUrl& url ); - - /** - * The date when the blog post or news article was posted. - */ - QDateTime datePosted() const; - void setDatePosted( const QDateTime& date ); - - /** - * The date when this blog post or news article was found by The Echo Nest. - */ - QDateTime dateFound() const; - void setDateFound( const QDateTime& date ); - - /** - * A short summary of the blog or article. - */ - QString summary() const; - void setSummary( const QString& text ); - - /** - * The unique identifier for this entry. - */ - QByteArray id() const; - void setId( const QByteArray& id ); - - private: - QSharedDataPointer d; - }; - - /** - * A news article about an artist. - */ - typedef Blog NewsArticle; - - /** - * An image related to an artist. - */ - class ECHONEST_EXPORT ArtistImage { - - public: - ArtistImage(); - ArtistImage( const ArtistImage& other ); - ArtistImage& operator=( const ArtistImage& img ); - ~ArtistImage(); - - /** - * The image url. - */ - QUrl url() const; - void setUrl( const QUrl& url ); - - /** - * The license that governs this image. - */ - License license() const; - void setLicense( const License& license ); - - private: - QSharedDataPointer d; - }; - - /** - * A review of an artist, album, or track. - */ - class ECHONEST_EXPORT Review { - - public: - Review(); - Review( const Review& other ); - Review& operator=( const Review& other ); - ~Review(); - - /** - * The name of the review site. - */ - QString name() const; - void setName( const QString& name ); - - /** - * The URL to the review. - */ - QUrl url() const; - void setUrl( const QUrl& url ); - - /** - * The date when the review was posted. - */ - QDateTime dateReviewed() const; - void setDateReviewed( const QDateTime& date ); - - /** - * The date when this review was found and indexed by The Echo Nest - */ - QDateTime dateFound() const; - void setDateFound( const QDateTime& date ); - - /** - * A summary of the review. - */ - QString summary() const; - void setSummary( const QString& text ); - - /** - * The url to an image associated with the review, if it exists. - */ - QUrl imageUrl() const; - void setImageUrl( const QUrl& imageUrl ); - - /** - * The album being reviewed if it is an album review, including specific release info, if it exists. - */ - QString release() const; - void setRelease( const QString& release ); - - /** - * The unique identifier for this entry. - */ - QByteArray id() const; - void setId( const QByteArray& id ); - - private: - QSharedDataPointer d; - }; - - /** - * A term used to describe an artist or track. - */ - class ECHONEST_EXPORT Term { - - public: - Term(); - Term( const Term& other ); - Term& operator=( const Term& img ); - ~Term(); - - /** - * The term name. - */ - QString name() const; - void setName( const QString& name ); - - /** - * The frequency that this term is mentioned in relation to the artist/track. - */ - qreal frequency() const; - void setFrequency( qreal freq ); - - /** - * The weight that The Echo Nest assigns to this term. - */ - qreal weight() const; - void setWeight( qreal weight ); - - private: - QSharedDataPointer d; - }; - - - /** - * A link to a video related to an artist. - */ - class ECHONEST_EXPORT Video { - - public: - Video(); - Video( const Video& other ); - Video& operator=( const Video& other ); - ~Video(); - - /** - * The title of the video - */ - QString title() const; - void setTitle( const QString& title ); - - /** - * The URL to the title. - */ - QUrl url() const; - void setUrl( const QUrl& url ); - - /** - * The site that the video is from. - */ - QString site() const; - void setSite( const QString& site ); - - /** - * The date when this video was found - */ - QDateTime dateFound() const; - void setDateFound( const QDateTime& date ); - - /** - * The url to an image associated with this video, if it exists. - */ - QUrl imageUrl() const; - void setImageUrl( const QUrl& imageUrl ); - - /** - * The unique identifier for this video. - */ - QByteArray id() const; - void setId( const QByteArray& id ); - - private: - QSharedDataPointer d; - }; - - ECHONEST_EXPORT QDebug operator<<(QDebug d, const Echonest::AudioFile& artist); - ECHONEST_EXPORT QDebug operator<<(QDebug d, const Echonest::Biography& biblio); - ECHONEST_EXPORT QDebug operator<<(QDebug d, const Echonest::Blog& blog); - ECHONEST_EXPORT QDebug operator<<(QDebug d, const Echonest::ArtistImage& img); - ECHONEST_EXPORT QDebug operator<<(QDebug d, const Echonest::Review& review); - ECHONEST_EXPORT QDebug operator<<(QDebug d, const Echonest::Term& term); - ECHONEST_EXPORT QDebug operator<<(QDebug d, const Echonest::Video& video); - - typedef QVector< AudioFile > AudioList; - typedef QVector< Biography > BiographyList; - typedef QVector< Blog > BlogList; - typedef QVector< ArtistImage > ArtistImageList; - typedef QVector< NewsArticle > NewsList; - typedef QVector< Review > ReviewList; - typedef QVector< Term > TermList; - typedef QVector< Video > VideoList; - -} // namespace -#endif diff --git a/3rdparty/libechonest/ArtistTypes_p.h b/3rdparty/libechonest/ArtistTypes_p.h deleted file mode 100644 index 00bb5308d..000000000 --- a/3rdparty/libechonest/ArtistTypes_p.h +++ /dev/null @@ -1,166 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - -#ifndef ECHONEST_ARTISTTYPES_P_H -#define ECHONEST_ARTISTTYPES_P_H - -#include "Util.h" - -#include -#include -#include -#include -#include - -class AudioFileData : public QSharedData -{ -public: - AudioFileData() {} - AudioFileData( const AudioFileData& other ) : QSharedData( other ) { - title = other.title; - artist = other.artist; - url = other.url; - length = other.length; - link = other.link; - date = other.date; - id = other.id; - release = other.release; - } - - QString title; - QString artist; - QUrl url; - qreal length; - QUrl link; - QDateTime date; - QString release; - QByteArray id; -}; - -class BiographyData : public QSharedData -{ -public: - BiographyData() {} - BiographyData( const BiographyData& other ) : QSharedData( other ) { - url = other.url; - text = other.text; - site = other.site; - license = other.license; - } - - QUrl url; - QString text; - QString site; - Echonest::License license; -}; - -class BlogData : public QSharedData -{ -public: - BlogData() {} - BlogData( const BlogData& other ) : QSharedData( other ) { - name = other.name; - url = other.url; - date_posted = other.date_posted; - date_found = other.date_found; - summary = other.summary; - id = other.id; - } - - QString name; - QUrl url; - QDateTime date_posted; - QDateTime date_found; - QString summary; - QByteArray id; -}; - -class ArtistImageData : public QSharedData -{ -public: - ArtistImageData() {} - ArtistImageData( const ArtistImageData& other ) : QSharedData( other ) { - url = other.url; - license = other.license; - } - - QUrl url; - Echonest::License license; -}; - -class ReviewData : public QSharedData -{ -public: - ReviewData() {} - ReviewData( const ReviewData& other ) : QSharedData( other ) { - name = other.name; - url = other.url; - summary = other.summary; - date_reviewed = other.date_reviewed; - date_found = other.date_found; - image_url = other.image_url; - release = other.release; - id = other.id; - } - - QString name; - QUrl url; - QString summary; - QDateTime date_reviewed; - QDateTime date_found; - QUrl image_url; - QString release; - QByteArray id; -}; - -class TermData : public QSharedData -{ -public: - TermData() {} - TermData( const TermData& other ) : QSharedData( other ) { - name = other.name; - frequency = other.frequency; - weight = other.weight; - } - - QString name; - qreal frequency; - qreal weight; -}; - -class VideoData : public QSharedData -{ -public: - VideoData() {} - VideoData( const VideoData& other ) : QSharedData( other ) { - title = other.title; - url = other.url; - site = other.site; - date_found = other.date_found; - image_url = other.image_url; - id = other.id; - } - - QString title; - QUrl url; - QString site; - QDateTime date_found; - QUrl image_url; - QByteArray id; -}; - - -#endif diff --git a/3rdparty/libechonest/Artist_p.h b/3rdparty/libechonest/Artist_p.h deleted file mode 100644 index 32656c987..000000000 --- a/3rdparty/libechonest/Artist_p.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - -#ifndef ECHONEST_ARTIST_P_H -#define ECHONEST_ARTIST_P_H - -#include "Song.h" -#include "ArtistTypes.h" - -#include -#include -#include - -namespace Echonest { - class Artist; -} - -class ArtistData : public QSharedData -{ -public: - ArtistData() : familiarity( -1 ), hotttnesss( -1 ) {} - ArtistData( const QByteArray& id, const QString& name ) : id( id ), name( name ), familiarity( -1 ), hotttnesss( -1 ) {} - ArtistData(const ArtistData& other) : QSharedData( other ) - { - id = other.id; - name = other.name; - - audio = other.audio; - biographies = other.biographies; - blogs = other.blogs; - - familiarity = other.familiarity; - hotttnesss = other.hotttnesss; - - images = other.images; - news = other.news; - reviews = other.reviews; - songs = other.songs; - similar = other.similar; - terms = other.terms; - videos = other.videos; - - lastfm_url = other.lastfm_url; - aolmusic_url = other.aolmusic_url; - myspace_url = other.myspace_url; - amazon_url = other.amazon_url; - itunes_url = other.itunes_url; - mb_url = other.mb_url; - - foreign_ids = other.foreign_ids; - } - - // The following exist in all valid Artist objects - QByteArray id; - QString name; - - //The following are populated on demand, and may not exist - Echonest::AudioList audio; - Echonest::BiographyList biographies; - Echonest::BlogList blogs; - - qreal familiarity; - qreal hotttnesss; - - Echonest::ArtistImageList images; - Echonest::NewsList news; - Echonest::ReviewList reviews; - Echonest::SongList songs; - QVector similar; - Echonest::TermList terms; - Echonest::VideoList videos; - - QUrl lastfm_url; - QUrl aolmusic_url; - QUrl myspace_url; - QUrl amazon_url; - QUrl itunes_url; - QUrl mb_url; - - Echonest::ForeignIds foreign_ids; -}; - -#endif - diff --git a/3rdparty/libechonest/AudioSummary.cpp b/3rdparty/libechonest/AudioSummary.cpp deleted file mode 100644 index fc44621c6..000000000 --- a/3rdparty/libechonest/AudioSummary.cpp +++ /dev/null @@ -1,339 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - -#include "AudioSummary.h" - -#include "AudioSummary_p.h" -#include "Config.h" -#include "Parsing_p.h" - -#include - -Echonest::AudioSummary::AudioSummary() - : d( new AudioSummaryData ) -{ - -} - -Echonest::AudioSummary::AudioSummary(const Echonest::AudioSummary& other) - :d( other.d ) -{ - -} - -Echonest::AudioSummary::~AudioSummary() -{} - -QDebug Echonest::operator<<(QDebug d, const Echonest::AudioSummary& summary) -{ -// d << summary - return d.maybeSpace(); -} - -Echonest::AudioSummary& Echonest::AudioSummary::operator=(const Echonest::AudioSummary& audio) -{ - d = audio.d; - return *this; -} - -int Echonest::AudioSummary::analysisStatus() const -{ - return d->status; -} - -void Echonest::AudioSummary::setAnalysisStatus(int status) -{ - d->status = status; -} - -qreal Echonest::AudioSummary::analysisTime() const -{ - return d->analysis_time; -} - -void Echonest::AudioSummary::setAnalysisTime(qreal time) -{ - d->analysis_time = time; -} - -QString Echonest::AudioSummary::analyzerVersion() const -{ - return d->analyzer_version; -} - -void Echonest::AudioSummary::setAnalyzerVersion(QString version) -{ - d->analyzer_version = version; -} - -Echonest::BarList Echonest::AudioSummary::bars() const -{ - return d->bars; -} - -void Echonest::AudioSummary::setBars(const Echonest::BarList& bars) -{ - d->bars = bars; -} - -Echonest::BeatList Echonest::AudioSummary::beats() const -{ - return d->beats; -} - -void Echonest::AudioSummary::setBeats(const Echonest::BeatList& beats) -{ - d->beats = beats; -} - -QString Echonest::AudioSummary::detailedStatus() const -{ - return d->detailed_status; -} - -void Echonest::AudioSummary::setDetailedStatus( const QString& status ) -{ - d->detailed_status = status; -} - -qreal Echonest::AudioSummary::duration() const -{ - return d->duration; -} - -void Echonest::AudioSummary::setDuration(qreal duration) -{ - d->duration = duration; -} - - -qreal Echonest::AudioSummary::endOfFadeIn() const -{ - return d->end_of_fade_in; -} - -void Echonest::AudioSummary::setEndOfFadeIn(qreal time) -{ - d->end_of_fade_in = time; -} - -QNetworkReply* Echonest::AudioSummary::fetchFullAnalysis() const -{ - return Echonest::Config::instance()->nam()->get( QNetworkRequest( QUrl( d->analysis_url ) ) ); -} - -int Echonest::AudioSummary::key() const -{ - return d->key; -} - -void Echonest::AudioSummary::setKey(int key) -{ - d->key = key; -} - -qreal Echonest::AudioSummary::keyConfidence() const -{ - return d->key_confidence; -} - -void Echonest::AudioSummary::setKeyConfidence(qreal confidence) -{ - d->key_confidence = confidence; -} - -qreal Echonest::AudioSummary::loudness() const -{ - return d->loudness; -} - -void Echonest::AudioSummary::setLoudness(qreal loudness) -{ - d->loudness = loudness; -} - -qreal Echonest::AudioSummary::modeConfidence() const -{ - return d->mode_confidence; -} - -void Echonest::AudioSummary::setModeConfidence(qreal confidence) -{ - d->mode_confidence = confidence; -} - -qint64 Echonest::AudioSummary::numSamples() const -{ - return d->num_samples; -} - -void Echonest::AudioSummary::setNumSamples(qint64 num) -{ - d->num_samples = num; -} - -void Echonest::AudioSummary::parseFullAnalysis( QNetworkReply* reply ) throw( Echonest::ParseError ) -{ - Echonest::Parser::checkForErrors( reply ); - Echonest::Parser::parseDetailedAudioSummary( reply, *this ); - reply->deleteLater(); -} - -QString Echonest::AudioSummary::sampleMD5() const -{ - return d->sample_md5; -} - -void Echonest::AudioSummary::setSampleMD5(const QString& md5) -{ - d->sample_md5 = md5; -} - -qreal Echonest::AudioSummary::sampleRate() const -{ - return d->samplerate; -} - -void Echonest::AudioSummary::setSampleRate(qreal sampleRate) -{ - d->samplerate = sampleRate; -} - -Echonest::SectionList Echonest::AudioSummary::sections() const -{ - return d->sections; -} - -void Echonest::AudioSummary::setSections(const Echonest::SectionList& sections) -{ - d->sections = sections; -} - -Echonest::SegmentList Echonest::AudioSummary::segments() const -{ - return d->segments; -} - -void Echonest::AudioSummary::setSegments(const Echonest::SegmentList& segments) -{ - d->segments = segments; -} - -void Echonest::AudioSummary::setStartOfFadeOut(qreal time) -{ - d->start_of_fade_out = time; -} - -Echonest::TatumList Echonest::AudioSummary::tatums() const -{ - return d->tatums; -} - -void Echonest::AudioSummary::setTatums(const Echonest::TatumList& tatums) -{ - d->tatums = tatums; -} - -qreal Echonest::AudioSummary::startOfFadeOut() const -{ - return d->start_of_fade_out; -} - -qreal Echonest::AudioSummary::tempo() const -{ - return d->tempo; -} - -void Echonest::AudioSummary::setTempo(qreal tempo) -{ - d->tempo = tempo; -} - -qreal Echonest::AudioSummary::tempoConfidence() const -{ - return d->tempo_confidence; -} - -void Echonest::AudioSummary::setTempoConfidence(qreal confidence) -{ - d->tempo_confidence = confidence; -} - -int Echonest::AudioSummary::timeSignature() const -{ - return d->time_signature; -} - -void Echonest::AudioSummary::setTimeSignature(int timeSignature) -{ - d->time_signature = timeSignature; -} - -qreal Echonest::AudioSummary::timeSignatureConfidence() const -{ - return d->time_signature_confidence; -} - -void Echonest::AudioSummary::setTimeSignatureConfidence(qreal confidence) -{ - d->time_signature_confidence = confidence; -} - -void Echonest::AudioSummary::setTimestamp(qreal timestamp) -{ - d->timestamp = timestamp; -} - -qreal Echonest::AudioSummary::timestamp() const -{ - return d->timestamp; -} - -int Echonest::AudioSummary::mode() const -{ - return d->mode; -} - -void Echonest::AudioSummary::setAnalysisUrl(const QUrl& analysisUrl) -{ - d->analysis_url = analysisUrl; -} - -void Echonest::AudioSummary::setMode(int mode) -{ - d->mode = mode; -} - -qreal Echonest::AudioSummary::danceability() const -{ - return d->danceability; -} - -void Echonest::AudioSummary::setDanceability(qreal dance) -{ - d->danceability = dance; -} - -qreal Echonest::AudioSummary::energy() const -{ - return d->energy; -} - -void Echonest::AudioSummary::setEnergy(qreal energy) -{ - d->energy = energy; -} - diff --git a/3rdparty/libechonest/AudioSummary.h b/3rdparty/libechonest/AudioSummary.h deleted file mode 100644 index 38b883e87..000000000 --- a/3rdparty/libechonest/AudioSummary.h +++ /dev/null @@ -1,243 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - - -#ifndef ECHONEST_AUDIOSUMMARY_H -#define ECHONEST_AUDIOSUMMARY_H - -#include "echonest_export.h" - -#include -#include -#include "Util.h" -#include "Util.h" -#include "Config.h" - -class QNetworkReply; -class QNetworkReply; -class AudioSummaryData; - -namespace Echonest{ - - /** - * This encapsulates the audio summary of an Echo Nest track or song. - * - * It has two batches of data: the more generic acoustic information about the - * song is always populated, and additional detailed information about the song - * such as bars, beats, segments, tatus, and sections, can be fetched as well as - * an additional step. - * - * This class is implicitly shared. - */ - class ECHONEST_EXPORT AudioSummary - { - public: - AudioSummary(); - AudioSummary( const AudioSummary& other ); - ~AudioSummary(); - - AudioSummary& operator=( const AudioSummary& audio ); - - int key() const; - void setKey( int key ); - - /** - * The track's tempo. - */ - qreal tempo() const; - void setTempo( qreal tempo ); - - /** - * The track's mode. - */ - int mode() const; - void setMode( int mode ); - - /** - * The track's time signature, or -1 if it there is one, or 1 if it is - * too complex. - */ - int timeSignature() const; - void setTimeSignature( int timeSignature ); - - /** - * The duration of the song, in msecs. - */ - qreal duration() const; - void setDuration( qreal duration ); - - /** - * The loudness of the song, in dB. - */ - qreal loudness() const; - void setLoudness( qreal loudness ); - - /** - * The danceability of this track, from 0 to 1. - */ - qreal danceability() const; - void setDanceability( qreal dance ); - - /** - * The energy of this song, from 0 to 1. - */ - qreal energy() const; - void setEnergy( qreal energy ); - - /// The following require additional fetching to read /// - /** TODO: implement **/ - - /** - * If you wish to use any of the more detailed track analysis data, - * use this method to begin the fetch. One the returned QNetworkReply* - * has emitted the finished() signal, call parseFullAnalysis. - */ - QNetworkReply* fetchFullAnalysis() const; - - /** - * Parses the result of a fetchFullAnalysis() call. This contains - * information such as mode, fadein/fadeout, confidence metrics, - * and the division of the song into bars, beats, sections, and segments. - */ - void parseFullAnalysis( QNetworkReply* reply ) throw( ParseError ); - - /// The following methods *ALL REQUIRE THAT parseFullAnalysis be called first* - - /** - * How long it took to analyze this track. - */ - qreal analysisTime() const; - void setAnalysisTime( qreal time ); - - /** - * The version of the analyzer used on this track. - */ - QString analyzerVersion() const; - void setAnalyzerVersion( QString version ); - - /** - * Detailed status information about the analysis - */ - QString detailedStatus() const; - void setDetailedStatus( const QString& status ); - - /** - * The status code of the analysis - */ - int analysisStatus() const; - void setAnalysisStatus( int status ); - - /** - * The timestamp of the analysis. - */ - qreal timestamp() const; - void setTimestamp( qreal timestamp ); - - /** ECHONEST_EXPORT - * The sample rate of the track. - */ - qreal sampleRate() const; - void setSampleRate( qreal sampleRate ); - - /** - * The end of the track's fade in in msec. - */ - qreal endOfFadeIn() const; - void setEndOfFadeIn( qreal time ); - - /** - * The start of the fade out in msec. - */ - qreal startOfFadeOut() const; - void setStartOfFadeOut( qreal time ); - - /** - * The confidence of the key item. - */ - qreal keyConfidence() const; - void setKeyConfidence( qreal confidence ); - - /** - * The confidence of the mode item. - */ - qreal modeConfidence() const; - void setModeConfidence( qreal confidence ); - - /** - * The confidence of the tempo item. - */ - qreal tempoConfidence() const; - void setTempoConfidence( qreal confidence ); - - /** - * The confidence of the time signature item. - */ - qreal timeSignatureConfidence() const; - void setTimeSignatureConfidence( qreal confidence ); - - /** - * The number of samples in this track. - */ - qint64 numSamples() const; - void setNumSamples( qint64 num ); - - /** - * The MD5 of the sample. - */ - QString sampleMD5() const; - void setSampleMD5( const QString& md5 ); - - /** - * List of bars that are in the track. - */ - BarList bars() const; - void setBars( const BarList& bars ); - - /** - * List of beats in the track. - */ - BeatList beats() const; - void setBeats( const BeatList& beats ); - - /** - * List of sections in the track. - */ - SectionList sections() const; - void setSections( const SectionList& sections ); - - /** - * List of tatums in the track - */ - TatumList tatums() const; - void setTatums( const TatumList& tatums ); - - /** - * List of segments in the track with associated acoustic data. - */ - SegmentList segments() const; - void setSegments( const SegmentList& segments ); - - void setAnalysisUrl( const QUrl& analysisUrl ); - - private: - QSharedDataPointer d; - }; - - ECHONEST_EXPORT QDebug operator<<(QDebug d, const Echonest::AudioSummary& summary); - - -} // namespace -#endif diff --git a/3rdparty/libechonest/AudioSummary_p.h b/3rdparty/libechonest/AudioSummary_p.h deleted file mode 100644 index 11127bdc4..000000000 --- a/3rdparty/libechonest/AudioSummary_p.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - -#include "Util.h" - -#include -#include -#include -#include - -class AudioSummaryData : public QSharedData -{ -public: - AudioSummaryData() : key( -1 ), tempo( -1 ), mode( -1 ), time_signature( -1 ), duration( -1 ), loudness( -1 ), samplerate( -1 ), danceability( -1 ), energy( -1 ), - analysis_time( -1 ), status( -1 ), timestamp( -1 ), end_of_fade_in( -1 ), key_confidence( -1 ), mode_confidence( -1 ), num_samples( -1 ), - start_of_fade_out( -1 ), tempo_confidence( -1 ), time_signature_confidence( -1 ) {} - AudioSummaryData(const AudioSummaryData& other) : QSharedData( other ) - { - key = other.key; - tempo = other.tempo; - mode = other.mode; - time_signature = other.time_signature; - duration = other.duration; - loudness = other.loudness; - samplerate = other.samplerate; - danceability = other.danceability; - energy = other.energy; - - analysis_url = other.analysis_url; - - analysis_time = other.analysis_time; - analyzer_version = other.analyzer_version; - detailed_status = other.detailed_status; - status = other.status; - timestamp = other.timestamp; - - end_of_fade_in = other.end_of_fade_in; - key_confidence = other.key_confidence; - loudness = other.loudness; - mode_confidence = other.mode_confidence; - num_samples = other.num_samples; - sample_md5 = other.sample_md5; - start_of_fade_out = other.start_of_fade_out; - tempo_confidence = other.tempo_confidence; - time_signature = other.time_signature; - time_signature_confidence = other.time_signature_confidence; - - bars = other.bars; - beats = other.beats; - sections = other.sections; - tatums = other.tatums; - segments = other.segments; - - } - - // basic data that always exists in an Audio Summary object - int key; - qreal tempo; - int mode; - int time_signature; - qreal duration; - qreal loudness; - int samplerate; - qreal danceability; - qreal energy; - - QUrl analysis_url; // used to fetch the following pieces of data - - // meta section - qreal analysis_time; - QString analyzer_version; - QString detailed_status; - int status; - qreal timestamp; - - // track section - qreal end_of_fade_in; - qreal key_confidence; - qreal mode_confidence; - qint64 num_samples; - QString sample_md5; - qreal start_of_fade_out; - qreal tempo_confidence; - qreal time_signature_confidence; - - Echonest::BarList bars; - Echonest::BeatList beats; - Echonest::SectionList sections; - Echonest::TatumList tatums; - Echonest::SegmentList segments; - -}; diff --git a/3rdparty/libechonest/CMakeLists.txt b/3rdparty/libechonest/CMakeLists.txt deleted file mode 100644 index af2fecc26..000000000 --- a/3rdparty/libechonest/CMakeLists.txt +++ /dev/null @@ -1,62 +0,0 @@ - -include_directories( ${QJSON_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR} ) - -set( LIBECHONEST_SRC - Track.cpp - Song.cpp - Artist.cpp - Playlist.cpp - Config.cpp - Parsing.cpp - AudioSummary.cpp - Util.cpp - ArtistTypes.cpp - Generator.cpp - Catalog.cpp - CatalogUpdateEntry.cpp - CatalogSong.cpp - CatalogArtist.cpp - CatalogItem.cpp - TypeInformation.cpp -) - -set( LIBECHONEST_H - echonest_export.h - Track.h - Song.h - Artist.h - Playlist.h - Config.h - AudioSummary.h - ArtistTypes.h - Util.h - Catalog.h - CatalogUpdateEntry.h - CatalogSong.h - CatalogArtist.h - CatalogItem.h - TypeInformation.h -) - -QT4_WRAP_CPP( ${LIBECHONEST_H} ) - -if (CMAKE_COMPILER_IS_GNUCXX) - add_definitions( -Werror ) -endif (CMAKE_COMPILER_IS_GNUCXX) - -SET( OS_SPECIFIC_LINK_LIBRARIES "" ) -IF( APPLE OR MINGW ) - SET( OS_SPECIFIC_LINK_LIBRARIES ${QJSON_LIBRARIES} ) -ELSE( APPLE OR MINGW ) - SET( OS_SPECIFIC_LINK_LIBRARIES ${QJSON_LDFLAGS} ) -ENDIF( APPLE OR MINGW ) - - -add_library( echonest STATIC ${LIBECHONEST_SRC} ) -target_link_libraries( echonest ${OS_SPECIFIC_LINK_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTNETWORK_LIBRARY} ) - -foreach(file ${LIBECHONEST_H} echonest_export.h Util.h) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${file} - ${CMAKE_CURRENT_BINARY_DIR}/echonest/${file} - COPYONLY) -endforeach(file ${LIBECHONEST_H}) diff --git a/3rdparty/libechonest/Catalog.cpp b/3rdparty/libechonest/Catalog.cpp deleted file mode 100644 index a438a3709..000000000 --- a/3rdparty/libechonest/Catalog.cpp +++ /dev/null @@ -1,334 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - -#include "Catalog.h" - -#include "Catalog_p.h" -#include "Parsing_p.h" -#include "Generator_p.h" -#include "Track_p.h" - -Echonest::Catalog::Catalog() - : d( new CatalogData ) -{ - -} - -Echonest::Catalog::Catalog( const QByteArray& id ) - : d( new CatalogData ) -{ - d->id = id; -} - - -Echonest::Catalog::Catalog( const Echonest::Catalog& catalog ) - : d( catalog.d ) -{ -} - -Echonest::Catalog& Echonest::Catalog::operator=( const Echonest::Catalog& other ) -{ - d = other.d; - return *this; -} - -Echonest::Catalog::~Catalog() -{ -} - -Echonest::CatalogArtists Echonest::Catalog::artists() const -{ - return d->artists; -} - -void Echonest::Catalog::setArtists(const Echonest::CatalogArtists& artists) -{ - d->artists = artists; -} - -QByteArray Echonest::Catalog::id() const -{ - return d->id; -} - -void Echonest::Catalog::setId(const QByteArray& id) -{ - d->id = id; -} - -QString Echonest::Catalog::name() const -{ - return d->name; -} - -void Echonest::Catalog::setName(const QString& name) -{ - d->name = name; -} - -int Echonest::Catalog::resolved() const -{ - return d->resolved; -} - -void Echonest::Catalog::setResolved(int resolved) -{ - d->resolved = resolved; -} - -int Echonest::Catalog::pendingTickets() const -{ -// return d->pending_tickets; - return 0; -} - -void Echonest::Catalog::setPendingTickets(int pending) -{ -// d->pending_tickets = pending; -} - -Echonest::CatalogSongs Echonest::Catalog::songs() const -{ - return d->songs; -} - -void Echonest::Catalog::setSongs(const Echonest::CatalogSongs& songs) -{ - d->songs = songs; -} - -int Echonest::Catalog::total() const -{ - return d->total; -} - -void Echonest::Catalog::setTotal(int total) -{ - d->total = total; -} - -Echonest::CatalogTypes::Type Echonest::Catalog::type() const -{ - return d->type; -} - -void Echonest::Catalog::setType(Echonest::CatalogTypes::Type type) -{ - d->type = type; -} - -QNetworkReply* Echonest::Catalog::create(const QString& name, Echonest::CatalogTypes::Type type) -{ - QUrl url = Echonest::baseGetQuery( "catalog", "create" ); - url.addQueryItem( QLatin1String( "name" ), name ); - url.addEncodedQueryItem( "type", Echonest::catalogTypeToLiteral( type ) ); - - QNetworkRequest request = QNetworkRequest( url ); - request.setHeader( QNetworkRequest::ContentTypeHeader, QLatin1String( "multipart/form-data" ) ); - qDebug() << "Sending create url:" << url.toString(); - return Echonest::Config::instance()->nam()->post( request, QByteArray() ); -} - -QNetworkReply* Echonest::Catalog::deleteCatalog() const -{ - QUrl url = Echonest::baseGetQuery( "catalog", "delete" ); - Q_ASSERT( !d->id.isEmpty() ); - url.addEncodedQueryItem( "id", d->id ); - - return Echonest::doPost( url ); -} - -QNetworkReply* Echonest::Catalog::list(int results, int start) -{ - QUrl url = Echonest::baseGetQuery( "catalog", "list" ); - addLimits( url, results, start ); - - return Echonest::Config::instance()->nam()->get( QNetworkRequest( url ) ); -} - -QNetworkReply* Echonest::Catalog::profile() const -{ - QUrl url = Echonest::baseGetQuery( "catalog", "profile" ); - if( !d->id.isEmpty() ) - url.addEncodedQueryItem( "id", d->id ); - else if( !d->name.isEmpty() ) - url.addQueryItem( QLatin1String( "name" ), d->name ); - else - Q_ASSERT_X( false, "Catalog", "Not enough information!" ); - - return Echonest::Config::instance()->nam()->get( QNetworkRequest( url ) ); -} - -QNetworkReply* Echonest::Catalog::status(const QByteArray& ticket) -{ - QUrl url = Echonest::baseGetQuery( "catalog", "status" ); - url.addEncodedQueryItem( "ticket", ticket ); - - return Echonest::Config::instance()->nam()->get( QNetworkRequest( url ) ); -} - -QNetworkReply* Echonest::Catalog::update(const Echonest::CatalogUpdateEntries& entries) const -{ - QUrl url = Echonest::baseGetQuery( "catalog", "update" ); - Q_ASSERT( !d->id.isEmpty() ); - url.addEncodedQueryItem( "id", d->id ); - return Echonest::Catalog::updatePrivate( url, entries ); -} - -QNetworkReply* Echonest::Catalog::updateAndCreate(const Echonest::CatalogUpdateEntries& entries) -{ - QUrl url = Echonest::baseGetQuery( "catalog", "update" ); - return Echonest::Catalog::updatePrivate( url, entries ); -} - -QNetworkReply* Echonest::Catalog::readArtistCatalog(Echonest::ArtistInformation info, int results, int start) const -{ - QUrl url = Echonest::baseGetQuery( "catalog", "read" ); - Artist::addQueryInformation( url, info ); - - return readPrivate( url, results, start ); -} - -QNetworkReply* Echonest::Catalog::readSongCatalog(Echonest::SongInformation info, int results, int start) const -{ - QUrl url = Echonest::baseGetQuery( "catalog", "read" ); - Song::addQueryInformation( url, info ); - - return readPrivate( url, results, start ); -} - -QPair< QString, QByteArray > Echonest::Catalog::parseDelete( QNetworkReply* reply ) throw( Echonest::ParseError ) -{ - QByteArray data = reply->readAll(); -// qDebug() << "DATA:" << data; - QPair< QString, QByteArray > asd; - Echonest::Parser::checkForErrors( reply ); - - QXmlStreamReader xml( data ); - - Echonest::Parser::readStatus( xml ); - - // TODO, after create works :) - reply->deleteLater(); - return asd; -} - -Echonest::Catalogs Echonest::Catalog::parseList(QNetworkReply* reply) throw( Echonest::ParseError ) -{ - Echonest::Parser::checkForErrors( reply ); - QXmlStreamReader xml( reply->readAll() ); - Echonest::Parser::readStatus( xml ); - - Echonest::Catalogs catalogs = Echonest::Parser::parseCatalogList( xml ); - - reply->deleteLater(); - return catalogs; -} - -void Echonest::Catalog::parseProfile(QNetworkReply* reply) throw( Echonest::ParseError ) -{ - Echonest::Parser::checkForErrors( reply ); - QXmlStreamReader xml( reply->readAll() ); - Echonest::Parser::readStatus( xml ); - - Echonest::Catalog catalog = Echonest::Parser::parseCatalog( xml, true ); - d = catalog.d; - reply->deleteLater(); -} - -void Echonest::Catalog::parseRead(QNetworkReply* reply) throw( Echonest::ParseError ) -{ - Echonest::Parser::checkForErrors( reply ); - QXmlStreamReader xml( reply->readAll() ); - Echonest::Parser::readStatus( xml ); - - Echonest::Catalog catalog = Echonest::Parser::parseCatalog( xml, true ); - d = catalog.d; - reply->deleteLater(); -} - -Echonest::CatalogStatus Echonest::Catalog::parseStatus(QNetworkReply* reply) throw( Echonest::ParseError ) -{ - Echonest::Parser::checkForErrors( reply ); - QByteArray data = reply->readAll(); -// qDebug() << data; - QXmlStreamReader xml( data ); - Echonest::Parser::readStatus( xml ); - - Echonest::CatalogStatus status = Echonest::Parser::parseCatalogStatus( xml ); - reply->deleteLater(); - return status; -} - -QByteArray Echonest::Catalog::parseTicket(QNetworkReply* reply) throw( Echonest::ParseError ) -{ - Echonest::Parser::checkForErrors( reply ); - QByteArray data = reply->readAll(); -// qDebug() << data; - QXmlStreamReader xml( data ); - Echonest::Parser::readStatus( xml ); - - QByteArray ticket = Echonest::Parser::parseCatalogTicket( xml ); - reply->deleteLater(); - return ticket; -} - -Echonest::Catalog Echonest::Catalog::parseCreate(QNetworkReply* reply) throw( Echonest::ParseError ) -{ - QByteArray data = reply->readAll(); -// qDebug() << data; - Echonest::Parser::checkForErrors( reply ); - QXmlStreamReader xml( data ); - Echonest::Parser::readStatus( xml ); - - Catalog c = Echonest::Parser::parseNewCatalog( xml ); - reply->deleteLater(); - return c; -} - - -QNetworkReply* Echonest::Catalog::updatePrivate( QUrl& url, const Echonest::CatalogUpdateEntries& entries) -{ - url.addEncodedQueryItem( "data_type", "json" ); - - QByteArray payload = Generator::catalogEntriesToJson( entries ); - url.addEncodedQueryItem( "data", payload ); - - return Echonest::doPost( url ); -} - -void Echonest::Catalog::addLimits(QUrl& url, int results, int start) -{ - if( results != 30 ) - url.addEncodedQueryItem( "results", QString::number( results ).toLatin1() ); - if( start > -1 ) - url.addEncodedQueryItem( "start", QString::number( start ).toLatin1() ); -} - -QNetworkReply* Echonest::Catalog::readPrivate(QUrl& url, int results, int start) const -{ - Q_ASSERT( !d->id.isEmpty() ); - url.addEncodedQueryItem( "id", d->id ); - addLimits( url, results, start ); - - return Echonest::Config::instance()->nam()->get( QNetworkRequest( url ) ); -} - -QDebug Echonest::operator<<(QDebug d, const Echonest::Catalog& catalog) -{ - return d.maybeSpace() << QString::fromLatin1( "Catalog(%1, %2, %3, %4)" ).arg( catalog.name() ).arg( QLatin1String( catalog.id() ) ) - .arg( QString::fromLatin1( Echonest::catalogTypeToLiteral( catalog.type() ) ) ).arg( catalog.total() ) << catalog.artists() << catalog.songs(); -} diff --git a/3rdparty/libechonest/Catalog.h b/3rdparty/libechonest/Catalog.h deleted file mode 100644 index 70d48973f..000000000 --- a/3rdparty/libechonest/Catalog.h +++ /dev/null @@ -1,225 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - -#ifndef ECHONEST_CATALOG_H -#define ECHONEST_CATALOG_H - -#include "Artist.h" -#include "CatalogUpdateEntry.h" -#include "echonest_export.h" -#include "Song.h" -#include "TypeInformation.h" -#include "Util.h" - -#include -#include -#include "CatalogSong.h" -#include "CatalogArtist.h" - -class QNetworkReply; -class CatalogData; - -namespace Echonest -{ - - -class Catalog; -typedef QVector< Catalog > Catalogs; - -class ECHONEST_EXPORT Catalog -{ -public: - Catalog(); - explicit Catalog( const QByteArray& id ); - Catalog( const Catalog& ); - virtual ~Catalog(); - Catalog& operator=( const Catalog& ); - - /// Basic information about the catalog - - /** - * The name of this catalog. - */ - QString name() const; - void setName( const QString& name ); - - /** - * The id of this catalog. - */ - QByteArray id() const; - void setId( const QByteArray& id ); - - /** - * The type of this catalog. - */ - CatalogTypes::Type type() const; - void setType( CatalogTypes::Type type ); - - /** - * The total number of items in this catalog. - */ - int total() const; - void setTotal( int total ); - - /// The following fields only have data if the appropriate parse* methods have been called - - /** - * The number of resolved items in the catalog. - */ - int resolved() const; - void setResolved( int resolved ); - - /** - * The number of pending tickets still to be resolved - */ - int pendingTickets() const; - void setPendingTickets( int pending ); - - /** - * The songs in this catalog, if this is a song catalog. - */ - CatalogSongs songs() const; - void setSongs( const CatalogSongs& songs ); - - /** - * The artists in this catalog, if it is an artist catalog. - */ - CatalogArtists artists() const; - void setArtists( const CatalogArtists& artists ); - - /** - * Update this catalog with the given items. Each item has an associated action, default is Update. - * Call parseTicket() to access the result ticket from this call. - * - * See more information about this api call at http://developer.echonest.com/docs/v4/catalog.html#update - * - * Requires catalog id. - * - * \param entries The list of entries to update the catalog with. - */ - QNetworkReply* update( const CatalogUpdateEntries& entries ) const; - - /** - * Get basic information on a catalog. Only requires one of catalog id or name. - */ - QNetworkReply* profile() const; - - /** - * Fetch the full list of data from this catalog. It is possible to specify specific audio - * information that you wish to have included with each item. Use the appropriate artist- or - * song-specific method calls in order to achieve this. - * - * \param info The list of desired information to be included with each item. - * \param results How many results to return in total - * \param start The index of the first result - */ - QNetworkReply* readArtistCatalog( ArtistInformation info = ArtistInformation(), int results = 30, int start = -1 ) const; - QNetworkReply* readSongCatalog( SongInformation info = SongInformation(), int results = 30, int start = -1 ) const; - - /** - * Deletes this catalog from The Echo Nest. Only the API key used to create a catalog can delete it. - */ - QNetworkReply* deleteCatalog() const; - - /** - * Create a new catalog with the given name and type. - * - * Parse the finished QNetworkReply with parseCreate() - * - * \param name The name of the catalog to create - * \param type The type of the catalog to create - */ - static QNetworkReply* create( const QString& name, CatalogTypes::Type type ); - - /** - * Returns a list of catalogs created with this key. - */ - static QNetworkReply* list( int results = 30, int start = -1 ); - - /** - * Creates a new catalog with the given items. - * See more information about this api call at http://developer.echonest.com/docs/v4/catalog.html#update - * - * Call parseTicket() to access the result ticket from this call. - * - * \param entries The list of entries to populate the catalog with. - * - */ - static QNetworkReply* updateAndCreate( const CatalogUpdateEntries& entries ); - - /** - * Checks the status of a catalog operation given a catalog ticket. - * - * Parse the result with parseStatus() - * - * \param ticket The catalog ticket returned from an update() or updateAndCreate() call - */ - static QNetworkReply* status( const QByteArray& ticket ); - - /** - * Parses the result of a status call, returning the status information along with information on - * item resolution if available. - */ - static CatalogStatus parseStatus( QNetworkReply* ) throw( Echonest::ParseError ); - - /** - * Parses the result of a profile() call. Saves the data to this catalog object. - */ - void parseProfile( QNetworkReply* ) throw( Echonest::ParseError ); - - /** - * Parses the result of the read*Catalog() calls. Saves the catalog data to this object. - */ - void parseRead( QNetworkReply * ) throw( Echonest::ParseError ); - - /** - * Parse the result of a delete call. Will throw if the catalog was not successfully deleted, - * and returns the name/id pair. - * - * \return QPair of catalogName, catalogId that was just deleted. - */ - QPair< QString, QByteArray > parseDelete( QNetworkReply* ) throw( Echonest::ParseError ); - - /** - * Parse the result of the list() API call. Will return a list of catalogs---each catalog only - * has id, name, type, and total tracks information. - */ - static Catalogs parseList( QNetworkReply* ) throw( Echonest::ParseError ); - - /** - * Parse the result of a catalog call. The calls return a ticket that can be used to check the status - * of the call with status() - */ - static QByteArray parseTicket( QNetworkReply* ) throw( Echonest::ParseError ); - - /** - * Parse the result of a create() call. - */ - static Catalog parseCreate( QNetworkReply* reply ) throw( Echonest::ParseError ); -private: - static QNetworkReply* updatePrivate( QUrl&, const CatalogUpdateEntries& entries ); - QNetworkReply* readPrivate( QUrl& url, int results, int start ) const; - static void addLimits( QUrl&, int results, int start ); - QSharedDataPointer< CatalogData > d; -}; - -ECHONEST_EXPORT QDebug operator<<(QDebug d, const Catalog &catalog); - -} - -Q_DECLARE_METATYPE( Echonest::Catalog ) - -#endif diff --git a/3rdparty/libechonest/CatalogArtist.cpp b/3rdparty/libechonest/CatalogArtist.cpp deleted file mode 100644 index 0366379fc..000000000 --- a/3rdparty/libechonest/CatalogArtist.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - -#include "CatalogArtist.h" -#include "CatalogItem_p.h" - -Echonest::CatalogArtist::CatalogArtist() -{ - -} - -Echonest::CatalogArtist::CatalogArtist(const QString& name) - : Artist( name ) -{ - -} - -Echonest::CatalogArtist::CatalogArtist(const QByteArray& id, const QString& name) - : Artist(id, name) -{ - -} - -Echonest::CatalogArtist::CatalogArtist(const Echonest::CatalogArtist& other) - : Artist( other ) - , CatalogItem( other ) -{ - -} - -Echonest::CatalogArtist::~CatalogArtist() -{ - -} - -Echonest::CatalogArtist& Echonest::CatalogArtist::operator=(const Echonest::CatalogArtist& other) -{ - Artist::operator=( other ); - CatalogItem::operator=( other ); - return *this; -} - -Echonest::CatalogTypes::Type Echonest::CatalogArtist::type() const -{ - return Echonest::CatalogTypes::Artist; -} diff --git a/3rdparty/libechonest/CatalogArtist.h b/3rdparty/libechonest/CatalogArtist.h deleted file mode 100644 index f10f0c8f7..000000000 --- a/3rdparty/libechonest/CatalogArtist.h +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ -#ifndef ECHONEST_CATALOG_ARTIST_H -#define ECHONEST_CATALOG_ARTIST_H - -#include "echonest_export.h" -#include "Artist.h" -#include "CatalogItem.h" - -class CatalogArtistData; -namespace Echonest { - -/** - * An artist that includes some additional information returned when getting an artist from a catalog listing. - */ -class ECHONEST_EXPORT CatalogArtist : public Artist, public CatalogItem -{ -public: - CatalogArtist(); - explicit CatalogArtist(const QString& name); - CatalogArtist(const QByteArray& id, const QString& name); - CatalogArtist(const Echonest::CatalogArtist& other); - virtual ~CatalogArtist(); - CatalogArtist& operator=( const CatalogArtist& other ); - - /** - * The type of this catalog item: Artist. - */ - virtual CatalogTypes::Type type() const; -}; - -typedef QVector< CatalogArtist > CatalogArtists; - -} - -Q_DECLARE_METATYPE( Echonest::CatalogArtist ) -#endif diff --git a/3rdparty/libechonest/CatalogItem.cpp b/3rdparty/libechonest/CatalogItem.cpp deleted file mode 100644 index 423b387f1..000000000 --- a/3rdparty/libechonest/CatalogItem.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - -#include "CatalogItem.h" -#include "CatalogItem_p.h" - -// just an interface. - -Echonest::CatalogItem::CatalogItem() - : dd( new CatalogItemData ) -{ - -} - -Echonest::CatalogItem::CatalogItem(const Echonest::CatalogItem& other) - : dd( other.dd ) -{ -} - -Echonest::CatalogItem::~CatalogItem() -{ - -} - -Echonest::CatalogItem& Echonest::CatalogItem::operator=(const Echonest::CatalogItem& other) -{ - dd = other.dd; - return *this; -} - - -QDateTime Echonest::CatalogItem::dateAdded() const -{ - return dd->date_added; -} - -void Echonest::CatalogItem::setDateAdded(const QDateTime& dt) -{ - dd->date_added = dt; -} - -QByteArray Echonest::CatalogItem::foreignId() const -{ - return dd->foreign_id; -} - -void Echonest::CatalogItem::setForeignId(const QByteArray& id) -{ - dd->foreign_id = id; -} - -Echonest::CatalogUpdateEntry Echonest::CatalogItem::request() const -{ - return dd->request; -} - -void Echonest::CatalogItem::setRequest(const Echonest::CatalogUpdateEntry& request) -{ - dd->request = request; -} - -int Echonest::CatalogItem::rating() const -{ - return dd->rating; -} - -void Echonest::CatalogItem::setRating(int rating) -{ - dd->rating = rating; -} - -int Echonest::CatalogItem::playCount() const -{ - return dd->play_count; -} - -void Echonest::CatalogItem::setPlayCount(int count) -{ - dd->play_count = count; -} diff --git a/3rdparty/libechonest/CatalogItem.h b/3rdparty/libechonest/CatalogItem.h deleted file mode 100644 index d2ebed690..000000000 --- a/3rdparty/libechonest/CatalogItem.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - -#ifndef ECHONEST_CATALOG_ITEM_H -#define ECHONEST_CATALOG_ITEM_H - -#include "CatalogUpdateEntry.h" -#include "echonest_export.h" -#include "Util.h" - -#include -#include -#include - -class CatalogItemData; - -namespace Echonest { - -/** -* Since catalog items can be artists or songs, and we don't know sometimes until after we parse them, -* but we need to gather a list of them. A poor man's traits class? A rich man's interface? Far from either. -*/ - -class ECHONEST_EXPORT CatalogItem -{ -public: - CatalogItem(); - CatalogItem( const CatalogItem& other ); - CatalogItem& operator=( const CatalogItem& other ); - virtual ~CatalogItem(); - - /** - * The type of this item. - */ - virtual Echonest::CatalogTypes::Type type() const = 0; - - /** - * The foreign id of this item in the catalog. e.g. CAOFUDS12BB066268E:artist:ARUI8651187B9ACF52 - * - * See The Echo Nest API docs for more information. - */ - QByteArray foreignId() const; - void setForeignId( const QByteArray& id ); - - /** - * The request that generated this catalog item - */ - CatalogUpdateEntry request() const; - void setRequest( const CatalogUpdateEntry& request ); - - /** - * The date and time when this item was added to the catalog - */ - QDateTime dateAdded() const; - void setDateAdded( const QDateTime& dt ); - - /** - * The rating of this item. - */ - int rating() const; - void setRating( int rating ); - - /** - * The play count of this item. - */ - int playCount() const; - void setPlayCount( int count ); - -protected: - QSharedPointer dd; -}; - -typedef QVector< CatalogItem > CatalogItems; -} - - -#endif diff --git a/3rdparty/libechonest/CatalogItem_p.h b/3rdparty/libechonest/CatalogItem_p.h deleted file mode 100644 index ef2ca59a6..000000000 --- a/3rdparty/libechonest/CatalogItem_p.h +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - -#ifndef ECHONEST_CATALOG_ITEM_P_H -#define ECHONEST_CATALOG_ITEM_P_H - -#include "Song_p.h" - -#include -#include -#include -#include -#include "CatalogUpdateEntry.h" - - -class CatalogItemData : public QSharedData -{ -public: - CatalogItemData() {} - - CatalogItemData(const CatalogItemData& other) : QSharedData( other ) - { - foreign_id = other.foreign_id; - request = other.request; - date_added = other.date_added; - rating = other.rating; - play_count = other.play_count; - } - ~CatalogItemData() {} - - Echonest::CatalogUpdateEntry request; - QByteArray foreign_id; - QDateTime date_added; - int rating; - int play_count; -}; - -#endif diff --git a/3rdparty/libechonest/CatalogSong.cpp b/3rdparty/libechonest/CatalogSong.cpp deleted file mode 100644 index b6c137f28..000000000 --- a/3rdparty/libechonest/CatalogSong.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - -#include "CatalogSong.h" -#include "CatalogItem_p.h" - -Echonest::CatalogSong::CatalogSong() -{ - -} - -Echonest::CatalogSong::CatalogSong(const QByteArray& id, const QString& title, const QByteArray& artistId, const QString& artistName) - : Song(id, title, artistId, artistName) -{ - -} - -Echonest::CatalogSong::CatalogSong(const Echonest::CatalogSong& other) - : Song(other) - , CatalogItem( other ) -{ - -} - -Echonest::CatalogSong& Echonest::CatalogSong::operator=(const Echonest::CatalogSong& other) -{ - Song::operator=( other ); - CatalogItem::operator=( other ); - return *this; -} - -Echonest::CatalogSong::~CatalogSong() -{ -} - -Echonest::CatalogTypes::Type Echonest::CatalogSong::type() const -{ - return Echonest::CatalogTypes::Song; -} - - diff --git a/3rdparty/libechonest/CatalogSong.h b/3rdparty/libechonest/CatalogSong.h deleted file mode 100644 index 5b91d021e..000000000 --- a/3rdparty/libechonest/CatalogSong.h +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ -#ifndef ECHONEST_CATALOG_SONG_H -#define ECHONEST_CATALOG_SONG_H - -#include "echonest_export.h" -#include "Song.h" -#include "CatalogItem.h" - -class CatalogSongData; -namespace Echonest { -/** -* A song that includes some additional information returned when getting a song from a catalog listing. -*/ -class ECHONEST_EXPORT CatalogSong : public Song, public CatalogItem -{ -public: - CatalogSong(); - CatalogSong(const QByteArray& id, const QString& title, const QByteArray& artistId, const QString& artistName); - CatalogSong(const Echonest::CatalogSong& other); - virtual ~CatalogSong(); - CatalogSong& operator=( const CatalogSong& other ); - - /** - * The type of this item: Song. - */ - virtual CatalogTypes::Type type() const; - -}; - -typedef QVector< CatalogSong > CatalogSongs; -} - - -Q_DECLARE_METATYPE( Echonest::CatalogSong ) -#endif diff --git a/3rdparty/libechonest/CatalogUpdateEntry.cpp b/3rdparty/libechonest/CatalogUpdateEntry.cpp deleted file mode 100644 index bf27e6a77..000000000 --- a/3rdparty/libechonest/CatalogUpdateEntry.cpp +++ /dev/null @@ -1,232 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ -#include "CatalogUpdateEntry.h" -#include "CatalogUpdateEntry_p.h" - -Echonest::CatalogUpdateEntry::CatalogUpdateEntry() - : d( new CatalogUpdateEntryData ) -{ - -} - -Echonest::CatalogUpdateEntry::CatalogUpdateEntry( CatalogTypes::Action action ) - : d( new CatalogUpdateEntryData ) -{ - d->action = action; -} - -Echonest::CatalogUpdateEntry::CatalogUpdateEntry( const Echonest::CatalogUpdateEntry& other ) - : d( other.d ) -{ - -} - -Echonest::CatalogUpdateEntry::~CatalogUpdateEntry() -{ -} - -Echonest::CatalogUpdateEntry& Echonest::CatalogUpdateEntry::operator=(const Echonest::CatalogUpdateEntry& other) -{ - d = other.d; - return *this; -} - -QByteArray Echonest::CatalogUpdateEntry::itemId() const -{ - return d->item_id; -} - -void Echonest::CatalogUpdateEntry::setItemId(const QByteArray& id) -{ - d->item_id = id; -} - -Echonest::CatalogTypes::Action Echonest::CatalogUpdateEntry::action() const -{ - return d->action; -} - -void Echonest::CatalogUpdateEntry::setAction(Echonest::CatalogTypes::Action action) -{ - d->action = action; -} - -QByteArray Echonest::CatalogUpdateEntry::artistId() const -{ - return d->artist_id; -} - -void Echonest::CatalogUpdateEntry::setArtistId(const QByteArray& id) -{ - d->artist_id = id; -} - -QByteArray Echonest::CatalogUpdateEntry::fingerprint() const -{ - return d->fp_code; -} - -void Echonest::CatalogUpdateEntry::setFingerprint(const QByteArray& id) -{ - d->fp_code = id; -} - -void Echonest::CatalogUpdateEntry::setFingerpring(const QByteArray& id) -{ - setFingerprint(id); -} - -QString Echonest::CatalogUpdateEntry::artistName() const -{ - return d->artist_name; -} - -void Echonest::CatalogUpdateEntry::setArtistName(const QString& name) -{ - d->artist_name = name; -} - -bool Echonest::CatalogUpdateEntry::banned() const -{ - return d->banned; -} - -void Echonest::CatalogUpdateEntry::setBanned(bool banned) -{ - d->bannedSet = true; - d->banned = banned; -} - -int Echonest::CatalogUpdateEntry::discNumber() const -{ - return d->disc_number; -} - -void Echonest::CatalogUpdateEntry::setDiscNumber(int disc) -{ - d->disc_number = disc; -} - -bool Echonest::CatalogUpdateEntry::favorite() const -{ - return d->favorite; -} - -void Echonest::CatalogUpdateEntry::setFavorite(bool fav) -{ - d->favoriteSet = true; - d->favorite = fav; -} - -QString Echonest::CatalogUpdateEntry::genre() const -{ - return d->genre; -} - -void Echonest::CatalogUpdateEntry::setGenre(const QString& genre) -{ - d->genre = genre; -} - -int Echonest::CatalogUpdateEntry::playCount() const -{ - return d->play_count; -} - -void Echonest::CatalogUpdateEntry::setPlayCount(int playCount) -{ - d->play_count = playCount; -} - -int Echonest::CatalogUpdateEntry::rating() const -{ - return d->rating; -} - -void Echonest::CatalogUpdateEntry::setRating(int rating) -{ - d->rating = rating; -} - -QString Echonest::CatalogUpdateEntry::release() const -{ - return d->release; -} - -void Echonest::CatalogUpdateEntry::setRelease(const QString& release) -{ - d->release = release; -} - -int Echonest::CatalogUpdateEntry::skipCount() const -{ - return d->skip_count; -} - -void Echonest::CatalogUpdateEntry::setSkipCount(int skipCount) -{ - d->skip_count = skipCount; -} - -QByteArray Echonest::CatalogUpdateEntry::songId() const -{ - return d->song_id; -} - -void Echonest::CatalogUpdateEntry::setSongId(const QByteArray& id) -{ - d->song_id = id; -} - -QString Echonest::CatalogUpdateEntry::songName() const -{ - return d->song_name; -} - -void Echonest::CatalogUpdateEntry::setSongName(const QString& name) -{ - d->song_name = name; -} - -int Echonest::CatalogUpdateEntry::trackNumber() const -{ - return d->track_number; -} - -void Echonest::CatalogUpdateEntry::setTrackNumber(int trackNum) -{ - d->track_number = trackNum; -} - -QString Echonest::CatalogUpdateEntry::url() const -{ - return d->url; -} - -void Echonest::CatalogUpdateEntry::setUrl(const QString& url) -{ - d->url = url; -} - -bool Echonest::CatalogUpdateEntry::bannedSet() const -{ - return d->bannedSet; -} - -bool Echonest::CatalogUpdateEntry::favoriteSet() const -{ - return d->favoriteSet; -} diff --git a/3rdparty/libechonest/CatalogUpdateEntry.h b/3rdparty/libechonest/CatalogUpdateEntry.h deleted file mode 100644 index c22926e8f..000000000 --- a/3rdparty/libechonest/CatalogUpdateEntry.h +++ /dev/null @@ -1,174 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ -#ifndef ECHONEST_CATALOG_ENTRY_H -#define ECHONEST_CATALOG_ENTRY_H - -#include "echonest_export.h" -#include "Util.h" - -#include -#include -#include -#include - -class CatalogUpdateEntryData; - -namespace Echonest { - -/** - * This rather simple struct collects information about a status update - */ -typedef QVector< QPair< QByteArray, QString > > CatalogStatusItem; -typedef struct CatalogStatusStruct { - CatalogTypes::TicketStatus status; - QString details; - - int items_updated; - CatalogStatusItem items; // List of [ item_id, info ] - -// int percent_complete; - CatalogStatusStruct() : status( CatalogTypes::Unknown ), items_updated( -1 ) {} -} CatalogStatus; - -/** - * This class described a catalog entry for use in the Catalog update() call. - * All data fields are optional except Action, and only the ones specified will be sent. - */ -class ECHONEST_EXPORT CatalogUpdateEntry -{ -public: - CatalogUpdateEntry(); - CatalogUpdateEntry( CatalogTypes::Action action ); - virtual ~CatalogUpdateEntry(); - CatalogUpdateEntry( const CatalogUpdateEntry& other ); - CatalogUpdateEntry& operator=( const CatalogUpdateEntry& ); - - /** - * Optional, the item id for the catalog entry. hash( catalog_id + item_id ) - * MUST be unique. If this is not set, a unique id will be generated internally. - */ - QByteArray itemId() const; - void setItemId( const QByteArray& id ); - - /** - * The type of action that this item represents, required. - */ - CatalogTypes::Action action() const; - void setAction( CatalogTypes::Action action ); - - /** - * The Echo Nest fingerprint. - */ - QByteArray fingerprint() const; - void setFingerprint( const QByteArray& id ); - - // deprecated - void setFingerpring( const QByteArray& id ); - /** - * The song id. Rosetta id or Echo Nest ID. - */ - QByteArray songId() const; - void setSongId( const QByteArray& id ); - - /** - * The song name. Mutually exclusive with song id. - */ - QString songName() const; - void setSongName( const QString& name ); - - /** - * The artist id, either a rosetta stone ID or an Echo Nest ID. - */ - QByteArray artistId() const; - void setArtistId( const QByteArray& id ); - - /** - * The artist name, mutually exclusive with artist id. - */ - QString artistName() const; - void setArtistName( const QString& name ); - - /** - * The release, or album, name. - */ - QString release() const; - void setRelease( const QString& release ); - - /** - * The genre of the item. - */ - QString genre() const; - void setGenre( const QString& genre ); - - /** - * The track number. - */ - int trackNumber() const; - void setTrackNumber( int trackNum ); - - /** - * The disc number of this item. - */ - int discNumber() const; - void setDiscNumber( int disc ); - - /** - * The url or the local filename or remote url. - */ - QString url() const; - void setUrl( const QString& url ); - - /** - * If this song was marked as a favorite or not - */ - bool favorite() const; - void setFavorite( bool fav ); - - /** - * If this song was banned. - */ - bool banned() const; - void setBanned( bool banned ); - - /** - * The play count of this item. - */ - int playCount() const; - void setPlayCount( int playCount ); - - /** - * The skip count of this item. - */ - int skipCount() const; - void setSkipCount( int skipCount ); - - /** - * The rating of this item, from 1 to 10. - */ - int rating() const; - void setRating( int rating ); - - bool favoriteSet() const; - bool bannedSet() const; -private: - QSharedDataPointer d; -}; - -typedef QVector CatalogUpdateEntries; - -} - -#endif diff --git a/3rdparty/libechonest/CatalogUpdateEntry_p.h b/3rdparty/libechonest/CatalogUpdateEntry_p.h deleted file mode 100644 index fe2de3ab8..000000000 --- a/3rdparty/libechonest/CatalogUpdateEntry_p.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ -#ifndef CATALOG_UPDATE_ENTRY_H -#define CATALOG_UPDATE_ENTRY_H - -#include "Util.h" - -#include -#include -#include - -class CatalogUpdateEntryData : public QSharedData { - -public: - CatalogUpdateEntryData() : action( Echonest::CatalogTypes::Update ), track_number( -1 ), disc_number( -1 ), favorite( false ), - banned( false ), play_count( -1 ), skip_count( -1 ), rating( -1 ), - favoriteSet( false ), bannedSet( false ) - {} - - CatalogUpdateEntryData( const CatalogUpdateEntryData& other ) : QSharedData( other ) { - item_id = other.item_id; - action = other.action; - fp_code = other.fp_code; - - song_id = other.song_id; - song_name = other.song_name; - - artist_id = other.artist_id; - artist_name = other.artist_name; - - release = other.release; - genre = other.genre; - track_number = other.track_number; - disc_number = other.disc_number; - url = other.url; - - favorite = other.favorite; - banned = other.banned; - play_count = other.play_count; - skip_count = other.skip_count; - rating = other.rating; - - favoriteSet = other.favoriteSet; - bannedSet = other.banned; - } - Echonest::CatalogTypes::Action action; - - QByteArray item_id; - QByteArray fp_code; - - QByteArray song_id; - QString song_name; - - QByteArray artist_id; - QString artist_name; - - QString release; - QString genre; - int track_number; - int disc_number; - QString url; - - bool favorite; - bool banned; - int play_count; - int skip_count; - int rating; - - // internal - bool favoriteSet; - bool bannedSet; - -}; - -#endif diff --git a/3rdparty/libechonest/Catalog_p.h b/3rdparty/libechonest/Catalog_p.h deleted file mode 100644 index df20bec84..000000000 --- a/3rdparty/libechonest/Catalog_p.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - -#ifndef ECHONEST_CATALOG_P_H -#define ECHONEST_CATALOG_P_H - -#include "CatalogArtist.h" -#include "CatalogSong.h" -#include "Util.h" - -#include - -class CatalogData : public QSharedData -{ -public: - CatalogData() : total( 0 ), resolved( 0 ) {} - CatalogData( const CatalogData& other ) : QSharedData( other ) { - name = other.name; - id = other.id; - type = other.type; - total = other.total; - - resolved = other.resolved; - songs = other.songs; - artists = other.artists; - } - ~CatalogData() {} - - // Fields we always get in a catalog object - QString name; - QByteArray id; - Echonest::CatalogTypes::Type type; - int total; - - // Fields we sometimes get depending on the query - int resolved; - // pending_tickets - Echonest::CatalogSongs songs; // either has songs, or artists - Echonest::CatalogArtists artists; - - -}; - -#endif diff --git a/3rdparty/libechonest/Config.cpp b/3rdparty/libechonest/Config.cpp deleted file mode 100644 index e26202c2a..000000000 --- a/3rdparty/libechonest/Config.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * Copyright (c) 2011 Jeff Mitchell * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - -#include "Config.h" - -#include -#include -#include -#include - -Echonest::Config* Echonest::Config::s_instance = 0; - -QUrl Echonest::baseUrl() -{ - QUrl url; - url.setScheme( QLatin1String( "http" ) ); - url.setHost( QLatin1String( "developer.echonest.com" ) ); - return url; -} - - -QUrl Echonest::baseGetQuery(const QByteArray& type, const QByteArray& method) -{ - QUrl url = baseUrl(); - url.setPath( QString::fromLatin1( "/api/v4/%1/%2" ).arg( QLatin1String( type ) ).arg( QLatin1String( method ) ) ); - url.addEncodedQueryItem( "api_key", Echonest::Config::instance()->apiKey() ); - url.addEncodedQueryItem( "format", "xml" ); - return url; -} - -Echonest::ParseError::ParseError(Echonest::ErrorType error): exception() -{ - type = error; - whatData = createWhatData(); -} - -Echonest::ParseError::ParseError(Echonest::ErrorType error, const QString& text): exception() -{ - type = error; - extraText = text; - whatData = createWhatData(); -} - -QByteArray Echonest::ParseError::createWhatData() const throw() -{ - // If we have specific error text, use that first - if( !extraText.isEmpty() ) - return extraText.toLatin1(); - - switch( type ) - { - case UnknownError: - return "Unknown Echo Nest Error"; - case NoError: - return "No Error"; - case MissingAPIKey: - return "Missing Echo Nest API Key"; - case NotAllowed: - return "Method not allowed"; - case RateLimitExceeded: - return "Rate limit exceeded"; - case MissingParameter: - return "Missing parameter"; - case InvalidParameter: - return "Invalid parameter"; - case UnfinishedQuery: - return "Unfinished query object"; - case EmptyResult: - return "No results"; - case NetworkError: - return "Network Error"; - case UnknownParseError: - return "Unknown Parse Error"; - } - return QByteArray(); -} - - -Echonest::ParseError::~ParseError() throw() -{} - -Echonest::ErrorType Echonest::ParseError::errorType() const throw() -{ - return type; -} - -void Echonest::ParseError::setNetworkError( QNetworkReply::NetworkError error ) throw() -{ - nError = error; -} - -const char* Echonest::ParseError::what() const throw() -{ - return whatData.constData(); -} - - -QNetworkReply::NetworkError Echonest::ParseError::networkError() const throw() -{ - return nError; -} - - - -class Echonest::ConfigPrivate { -public: - ConfigPrivate() - { - threadNamHash[ QThread::currentThread() ] = new QNetworkAccessManager(); - } - - ~ConfigPrivate() - { - QThread *currThread = QThread::currentThread(); - if( threadNamHash.contains( currThread ) ) - { - if ( ourNamSet.contains( currThread ) ) - delete threadNamHash[ currThread ]; - threadNamHash.remove( currThread ); - ourNamSet.remove( currThread ); - } - } - - QMutex accessMutex; - QHash< QThread*, QNetworkAccessManager* > threadNamHash; - QSet< QThread* > ourNamSet; - QByteArray apikey; -}; - -Echonest::Config::Config() - : d( new Echonest::ConfigPrivate ) -{ - -} - -Echonest::Config::~Config() -{ - delete d; -} - -void Echonest::Config::setAPIKey(const QByteArray& apiKey) -{ - d->apikey = apiKey; -} - -QByteArray Echonest::Config::apiKey() const -{ - return d->apikey; -} - - -void Echonest::Config::setNetworkAccessManager(QNetworkAccessManager* nam) -{ - if( !nam ) - return; - - QMutexLocker l( &d->accessMutex ); - QThread* currThread = QThread::currentThread(); - QNetworkAccessManager* oldNam = 0; - if( d->threadNamHash.contains( currThread ) && d->ourNamSet.contains( currThread ) ) - oldNam = d->threadNamHash[ currThread ]; - - if( oldNam == nam ) - { - // If we're being passed back our own NAM, assume they want to - // ensure that we don't delete it out from under them - d->ourNamSet.remove( currThread ); - return; - } - - d->threadNamHash[ currThread ] = nam; - d->ourNamSet.remove( currThread ); - - if( oldNam ) - delete oldNam; -} - -QNetworkAccessManager* Echonest::Config::nam() const -{ - QMutexLocker l( &d->accessMutex ); - QThread* currThread = QThread::currentThread(); - if( !d->threadNamHash.contains( currThread ) ) - { - QNetworkAccessManager *newNam = new QNetworkAccessManager(); - d->threadNamHash[ currThread ] = newNam; - d->ourNamSet.insert( currThread ); - return newNam; - } - - return d->threadNamHash[ currThread ]; -} - -Echonest::Config* Echonest::Config::instance() { - if ( !s_instance ) { - s_instance = new Config; - } - - return s_instance; -} diff --git a/3rdparty/libechonest/Config.h b/3rdparty/libechonest/Config.h deleted file mode 100644 index 6bf23d781..000000000 --- a/3rdparty/libechonest/Config.h +++ /dev/null @@ -1,130 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - -#ifndef ECHONEST_CONFIG_H -#define ECHONEST_CONFIG_H - -#include "echonest_export.h" - -#include -#include - -#include -#include - -class QNetworkAccessManager; - -namespace Echonest{ - - /// Creates the base URL for all GET and POST requests - QUrl baseUrl(); - - /// Creates the base URL for GET requests. - QUrl baseGetQuery( const QByteArray& type, const QByteArray& method ); - - enum ErrorType { - /** - * Echo Nest API errors - */ - UnknownError = -1, - NoError = 0, - MissingAPIKey = 1, - NotAllowed = 2, - RateLimitExceeded = 3, - MissingParameter = 4, - InvalidParameter = 5, - - /// libechonest errors - UnfinishedQuery = 6, /// An unfinished QNetworkReply* was passed to the parse function - EmptyResult = 7, - UnknownParseError = 8, - - /// QNetworkReply errors - NetworkError = 9 - }; - - class ECHONEST_EXPORT ParseError : public std::exception - { - public: - explicit ParseError( ErrorType error ); - ParseError( ErrorType error, const QString& text ); - virtual ~ParseError() throw(); - - ErrorType errorType() const throw(); - - /** - * If the ErrorType is NetworkError, this value contains the QNetworkReply - * error code that was returned. - */ - void setNetworkError( QNetworkReply::NetworkError error ) throw(); - QNetworkReply::NetworkError networkError() const throw(); - - virtual const char* what() const throw (); - private: - QByteArray createWhatData() const throw(); - - ErrorType type; - QString extraText; - QNetworkReply::NetworkError nError; - QByteArray whatData; - }; - - class ConfigPrivate; - /** - * This singleton contains miscellaneous settings used to access The Echo Nest - */ - class ECHONEST_EXPORT Config { - public: - static Config* instance(); - - /** - * Set the API key to be used for all API requests. This MUST be set in order - * for any web service calls to work! - */ - void setAPIKey( const QByteArray& apiKey ); - QByteArray apiKey() const; - - /** - * Set the QNetworkAccessManager to use to make web service requests to - * The Echo Nest. - * - * This will register the given QNAM for the current thread. If you call this from - * the main thread and only make calls to libechonest from the main thread, you don't - * have to do any more work. However, if you are using multiple QNAMs in different threads, - * you must call this for each QNAM in each thread so that libechonest can use the proper - * thread-local QNAM. This function is thread-safe. - * - * Note that in all threads, if you do not set a QNAM, a default one is created and returned. - * In addition, if you set your own QNAM, you are responsible for deleting it. - * - * This will take over control of the object. - */ - void setNetworkAccessManager( QNetworkAccessManager* nam ); - QNetworkAccessManager* nam() const; - - - private: - Config(); - ~Config(); - - static Config* s_instance; - - ConfigPrivate* d; - }; - -} - -#endif diff --git a/3rdparty/libechonest/Generator.cpp b/3rdparty/libechonest/Generator.cpp deleted file mode 100644 index 878b90eba..000000000 --- a/3rdparty/libechonest/Generator.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - -#include "Generator_p.h" -#include "CatalogUpdateEntry.h" - -// QJSon -#include - -#include -#include -#include - -QByteArray Echonest::Generator::catalogEntriesToJson( const Echonest::CatalogUpdateEntries& items ) -{ - QJson::Serializer s; - - QVariant itms = catalogEntriesToVariant( items ); - QByteArray serialized = s.serialize( itms ); -// qDebug() << "Serialized:" << serialized; - return serialized; -} - -QByteArray Echonest::Generator::catalogEntryToJson( const Echonest::CatalogUpdateEntry& item ) -{ - QJson::Serializer s; - - QVariant itm = catalogEntryToVariant( item ); - QByteArray serialized = s.serialize( itm ); - // qDebug() << "Serialized:" << serialized; - return serialized; -} - - -QVariantList Echonest::Generator::catalogEntriesToVariant( const Echonest::CatalogUpdateEntries& items ) -{ - // copy the catalog item into a QVariant - QVariantList itemList; - foreach( const Echonest::CatalogUpdateEntry& item, items ) - itemList << catalogEntryToVariant( item ); - - qDebug() << "Generated " << itemList.size() << "entries to catalog variant!"; - return itemList; -} - -QVariant Echonest::Generator::catalogEntryToVariant( const Echonest::CatalogUpdateEntry& item ) -{ - QVariantMap itemMap; - QVariantMap itm; - - itemMap[ QLatin1String( "action" ) ] = Echonest::catalogUpdateActionToLiteral( item.action() ); - - if( item.itemId().isEmpty() ) - itm[ QLatin1String( "item_id" ) ] = QUuid::createUuid().toString().replace( QLatin1Char( '{' ), QString() ).replace( QLatin1Char( '}' ), QString() ); - else - itm[ QLatin1String( "item_id" ) ] = item.itemId(); - - if( !item.fingerprint().isEmpty() ) - itm[ QLatin1String( "fp_code" ) ] = item.fingerprint(); - - if( !item.songId().isEmpty() ) - itm[ QLatin1String( "song_id" ) ] = item.songId(); - - if( !item.songName().isEmpty() ) - itm[ QLatin1String( "song_name" ) ] = item.songName(); - - if( !item.artistId().isEmpty() ) - itm[ QLatin1String( "artist_id" ) ] = item.artistId(); - - if( !item.artistName().isEmpty() ) - itm[ QLatin1String( "artist_name" ) ] = item.artistName(); - - if( !item.release().isEmpty() ) - itm[ QLatin1String( "release" ) ] = item.release(); - - if( !item.genre().isEmpty() ) - itm[ QLatin1String( "genre" ) ] = item.genre(); - - if( item.trackNumber() > -1 ) - itm[ QLatin1String( "track_number" ) ] = item.trackNumber(); - - if( item.discNumber() > -1 ) - itm[ QLatin1String( "disc_number" ) ] = item.discNumber(); - - if( !item.url().isEmpty() ) - itm[ QLatin1String( "url" ) ] = item.url(); - - if( item.favoriteSet() ) - itm[ QLatin1String( "favorite" ) ] = item.favorite(); - - if( item.bannedSet() ) - itm[ QLatin1String( "banned" ) ] = item.banned(); - - if( item.playCount() > -1 ) - itm[ QLatin1String( "play_count" ) ] = item.playCount(); - - if( item.skipCount() > -1 ) - itm[ QLatin1String( "skip_count" ) ] = item.skipCount(); - - if( item.rating() > -1 ) - itm[ QLatin1String( "rating" ) ] = item.rating(); - - itemMap[ QLatin1String( "item" ) ] = itm; - - return itemMap; -} diff --git a/3rdparty/libechonest/Generator_p.h b/3rdparty/libechonest/Generator_p.h deleted file mode 100644 index 50555152a..000000000 --- a/3rdparty/libechonest/Generator_p.h +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ -#ifndef LIBECHONEST_GENERATOR_H -#define LIBECHONEST_GENERATOR_H -#include -#include "CatalogUpdateEntry.h" -#include - -namespace Echonest { - -namespace Generator { - -/** -* Miscellaneous functions for generating JSON to send to The Echo Nest -*/ - -QByteArray catalogEntriesToJson( const CatalogUpdateEntries& items ); -QByteArray catalogEntryToJson( const CatalogUpdateEntry& item ); - - -QVariantList catalogEntriesToVariant( const CatalogUpdateEntries& items ); -QVariant catalogEntryToVariant( const CatalogUpdateEntry& item ); - -} - -} -#endif diff --git a/3rdparty/libechonest/Parsing.cpp b/3rdparty/libechonest/Parsing.cpp deleted file mode 100644 index 9c47a80e6..000000000 --- a/3rdparty/libechonest/Parsing.cpp +++ /dev/null @@ -1,1214 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - -#include "Parsing_p.h" - -#include "Artist.h" -#include "CatalogItem_p.h" -#include "Util.h" - -// QJSon -#include - -#include -#include -#include - -void Echonest::Parser::checkForErrors( QNetworkReply* reply ) throw( Echonest::ParseError ) -{ - if( !reply ) - throw ParseError( Echonest::UnknownError ); - - // TODO sometimes this returns false when it shouldn't be? what's going on.. -// if( !reply->isFinished() ) -// throw ParseError( Echonest::UnfinishedQuery ); -// - if( reply->error() != QNetworkReply::NoError && reply->error() != QNetworkReply::UnknownContentError ) { // let UnknownContentError through so we parse it in readStatus with the proper error message - ParseError err( Echonest::NetworkError ); - err.setNetworkError( reply->error() ); - - throw err; - } -} - -void Echonest::Parser::readStatus( QXmlStreamReader& xml ) throw( Echonest::ParseError ) -{ - if( xml.readNextStartElement() ) { - // sanity checks - if( xml.atEnd() || xml.name() != QLatin1String( "response" ) ) - throw ParseError( UnknownParseError ); - - if( xml.readNextStartElement() ) { - if( xml.atEnd() || xml.name() != "status" ) - throw ParseError( UnknownParseError ); - - xml.readNextStartElement(); - double version = xml.readElementText().toDouble(); - // TODO use version for something? - Q_UNUSED(version); - xml.readNextStartElement(); - Echonest::ErrorType code = static_cast< Echonest::ErrorType >( xml.readElementText().toInt() ); - xml.readNextStartElement(); - QString msg = xml.readElementText(); - xml.readNextStartElement(); - - if( code != Echonest::NoError ) { - qDebug() << "Parse Error:" << code << msg; - throw ParseError( code, msg ); - } - - xml.readNext(); - } - - } else { - throw ParseError( UnknownParseError ); - } -} - -QVector< Echonest::Song > Echonest::Parser::parseSongList( QXmlStreamReader& xml ) throw( Echonest::ParseError ) -{ - QVector< Echonest::Song > songs; - - xml.readNext(); - while( !( xml.name() == "songs" && xml.tokenType() == QXmlStreamReader::EndElement ) ) { - // parse a song - songs.append( parseSong( xml ) ); - } - return songs; -} - -Echonest::Song Echonest::Parser::parseSong( QXmlStreamReader& xml ) throw( Echonest::ParseError ) -{ - if( xml.atEnd() || xml.name() != "song" ) - throw ParseError( Echonest::UnknownParseError ); - - Echonest::Song song; - while( !( xml.name() == "song" && xml.tokenType() == QXmlStreamReader::EndElement ) ) { - if( xml.name() == "id" && xml.isStartElement() ) - song.setId( xml.readElementText().toLatin1() ); - else if( xml.name() == "title" && xml.isStartElement() ) - song.setTitle( xml.readElementText() ); - else if( xml.name() == "artist_id" && xml.isStartElement() ) - song.setArtistId( xml.readElementText().toLatin1() ); - else if( xml.name() == "artist_name" && xml.isStartElement() ) - song.setArtistName( xml.readElementText() ); - else if( xml.name() == "release" && xml.isStartElement() ) - song.setRelease( xml.readElementText() ); - else if( xml.name() == "song_hotttnesss" && xml.isStartElement() ) - song.setHotttnesss( xml.readElementText().toDouble() ); - else if( xml.name() == "artist_hotttnesss" && xml.isStartElement() ) - song.setArtistHotttnesss( xml.readElementText().toDouble() ); - else if( xml.name() == "artist_familiarity" && xml.isStartElement() ) - song.setArtistFamiliarity( xml.readElementText().toDouble() ); - else if( xml.name() == "tracks" && xml.isStartElement() ) { - song.setTracks( parseSongTrackBucket( xml ) ); - } else if( xml.name() == "artist_location" && xml.isStartElement() ) { - song.setArtistLocation( parseSongArtistLocation( xml ) ); - } else if( xml.name() == "audio_summary" && xml.isStartElement() ) { - song.setAudioSummary( parseAudioSummary( xml ) ); - } - xml.readNext(); - } - xml.readNext(); // skip past the last - - return song; -} - - -Echonest::ArtistLocation Echonest::Parser::parseSongArtistLocation( QXmlStreamReader& xml ) throw( Echonest::ParseError ) -{ - if( xml.atEnd() || xml.name() != "artist_location" ) { - throw ParseError( Echonest::UnknownParseError ); - } - /** - * while( !( xml.name() == "location" && xml.tokenType() == QXmlStreamReader::EndElement ) ) { - x ml.readNex*tStartElement(); - if( xml.name() == "location" ) - song.setArtistLocation( xml.readElementText() ); -} -xml.readNext(); -**/ - Echonest::ArtistLocation location; - while( !( xml.name() == "artist_location" && xml.tokenType() == QXmlStreamReader::EndElement ) ) { - if( xml.name() == "latitude" && xml.isStartElement() ) { - location.latitude = xml.readElementText().toDouble(); - } else if( xml.name() == "longitude" && xml.isStartElement() ) { - location.longitude = xml.readElementText().toDouble(); - } else if( xml.name() == "location" && xml.isStartElement() ) { - location.location = xml.readElementText(); - } - xml.readNext(); - } - - return location; -} - -Echonest::Tracks Echonest::Parser::parseSongTrackBucket( QXmlStreamReader& xml ) throw( Echonest::ParseError ) -{ - if( xml.atEnd() || xml.name() != "tracks" ) { - throw ParseError( Echonest::UnknownParseError ); - } - - Echonest::Tracks tracks; - while( !( xml.name() == "tracks" && xml.tokenType() == QXmlStreamReader::EndElement ) && ( xml.name() != "track" || !xml.isEndElement() ) ) { - if( xml.name() == "track" && xml.isStartElement() ) { - Echonest::Track track = parseTrack( xml ); - tracks.append( track ); - } else - xml.readNext(); - } - - return tracks; -} - - -Echonest::Tracks Echonest::Parser::parseCatalogSongTracks( QXmlStreamReader& xml ) throw( Echonest::ParseError ) -{ - if( xml.atEnd() || xml.name() != "tracks" ) { - throw ParseError( Echonest::UnknownParseError ); - } - - Echonest::Tracks tracks; - while( !( xml.name() == "tracks" && xml.tokenType() == QXmlStreamReader::EndElement ) ) { - if( xml.name() == "track" && xml.isStartElement() ) { - tracks.append( Echonest::Track( xml.readElementText().toLatin1() ) ); - } - xml.readNext(); - } - - return tracks; -} - -Echonest::Track Echonest::Parser::parseTrack( QXmlStreamReader& xml ) throw( Echonest::ParseError ) -{ - if( xml.atEnd() || xml.name() != "track" ) { - throw ParseError( Echonest::UnknownParseError ); - } - Echonest::Track track; - while( !( xml.name() == "track" && xml.tokenType() == QXmlStreamReader::EndElement ) ) { - if( xml.name() == "id" && xml.isStartElement() ) - track.setId( xml.readElementText().toLatin1() ); - else if( xml.name() == "title" && xml.isStartElement() ) - track.setTitle( xml.readElementText() ); - else if( xml.name() == "artist" && xml.isStartElement() ) - track.setArtist( xml.readElementText() ); - else if( xml.name() == "status" && xml.isStartElement() ) - track.setStatus( Echonest::statusToEnum( xml.readElementText() ) ); - else if( xml.name() == "analyzer_version" && xml.isStartElement() ) - track.setAnalyzerVersion( xml.readElementText() ); - else if( xml.name() == "release" && xml.isStartElement() ) - track.setRelease( xml.readElementText() ); - else if( xml.name() == "song_id" && xml.isStartElement() ) - track.setSong( Echonest::Song( xml.readElementText().toLatin1() ) ); - else if( xml.name() == "audio_md5" && xml.isStartElement() ) - track.setAudioMD5( xml.readElementText().toLatin1() ); - else if( xml.name() == "bitrate" && xml.isStartElement() ) - track.setBitrate( xml.readElementText().toInt() ); - else if( xml.name() == "samplerate" && xml.isStartElement() ) - track.setSamplerate( xml.readElementText().toInt() ); - else if( xml.name() == "md5" && xml.isStartElement() ) - track.setMD5( xml.readElementText().toLatin1() ); - else if( xml.name() == "catalog" && xml.isStartElement() ) - track.setCatalog( xml.readElementText() ); - else if( xml.name() == "foreign_id" && xml.isStartElement() ) - track.setForeignId( xml.readElementText().toLatin1() ); - else if( xml.name() == "release_image" && xml.isStartElement() ) - track.setReleaseImage( QUrl( xml.readElementText(), QUrl::TolerantMode ) ); - else if( xml.name() == "preview_url" && xml.isStartElement() ) - track.setPreviewUrl( QUrl( xml.readElementText(), QUrl::TolerantMode ) ); - else if( xml.name() == "audio_summary" && xml.isStartElement() ) { - track.setAudioSummary( parseAudioSummary( xml ) ); - continue; - } - xml.readNext(); - } - xml.readNext(); // skip past the last - return track; -} - - -Echonest::AudioSummary Echonest::Parser::parseAudioSummary( QXmlStreamReader& xml ) throw( Echonest::ParseError ) -{ - if( xml.atEnd() || xml.name() != "audio_summary" ) { - throw ParseError( Echonest::UnknownParseError ); - } - - Echonest::AudioSummary summary; - while( !( xml.name() == "audio_summary" && xml.tokenType() == QXmlStreamReader::EndElement ) ) { - if( xml.name() == "key" && xml.isStartElement() ) - summary.setKey( xml.readElementText().toInt() ); - else if( xml.name() == "analysis_url" && xml.isStartElement() ) - summary.setAnalysisUrl( QUrl::fromEncoded( xml.readElementText().toUtf8(), QUrl::TolerantMode ) ); - else if( xml.name() == "tempo" && xml.isStartElement() ) - summary.setTempo( xml.readElementText().toDouble() ); - else if( xml.name() == "mode" && xml.isStartElement() ) - summary.setMode( xml.readElementText().toInt() ); - else if( xml.name() == "time_signature" && xml.isStartElement() ) - summary.setTimeSignature( xml.readElementText().toInt() ); - else if( xml.name() == "duration" && xml.isStartElement() ) - summary.setDuration( xml.readElementText().toDouble() ); - else if( xml.name() == "loudness" && xml.isStartElement() ) - summary.setLoudness( xml.readElementText().toDouble() ); - else if( xml.name() == "danceability" && xml.isStartElement() ) - summary.setDanceability( xml.readElementText().toDouble() ); - else if( xml.name() == "energy" && xml.isStartElement() ) - summary.setEnergy( xml.readElementText().toDouble() ); - - xml.readNext(); - } - - return summary; -} - -// extract confidence, duration, start out of a list of them. same code for bars, beats, sections, tatums -template< class T > -inline QVector< T > extractTripleTuple( const QVariantList& list ) { - QVector< T > tList; - tList.reserve( list.size() ); - for( QVariantList::const_iterator iter = list.constBegin(); iter != list.constEnd(); ++iter ) { - T t; - QVariantMap tMap = iter->toMap(); - t.confidence = tMap.value( QLatin1String( "confidence" ), -1 ).toReal(); - t.duration = tMap.value( QLatin1String( "duration" ), -1 ).toReal(); - t.start = tMap.value( QLatin1String( "start" ), -1 ).toReal(); - - tList.append( t ); - } -// qDebug() << "Parsed simple list:" << tList.size(); - return tList; -} - -void Echonest::Parser::parseDetailedAudioSummary( QNetworkReply* reply, Echonest::AudioSummary& summary ) throw( ParseError ) -{ - QJson::Parser parser; - bool ok; - QVariant data = parser.parse( reply, &ok ); - if( !ok ) { - qWarning() << "Failed to parse JSON data!" << parser.errorString(); - throw ParseError( Echonest::UnknownParseError ); - } - QVariantMap mainMap = data.toMap(); - if( mainMap.contains( QLatin1String( "meta" ) ) ) { - QVariantMap metaMap = mainMap.value( QLatin1String( "meta" ) ).toMap(); - summary.setAnalysisTime( metaMap.value( QLatin1String( "analysis_time" ), -1 ).toReal() ); - summary.setAnalysisStatus( metaMap.value( QLatin1String( "status_code" ) ).toInt() ); - summary.setDetailedStatus( metaMap.value( QLatin1String( "detailed_status" ) ).toString() ); - summary.setAnalyzerVersion( metaMap.value( QLatin1String( "analyzer_version" ) ).toString() ); - summary.setTimestamp( metaMap.value( QLatin1String( "analysis_time" ), -1 ).toReal() ); - } - if( mainMap.contains( QLatin1String( "bars" ) ) ) { - QVariantList barList = mainMap.value( QLatin1String( "bars" ) ).toList(); - summary.setBars( extractTripleTuple( barList ) ); - } - if( mainMap.contains( QLatin1String( "beats" ) ) ) { - QVariantList beatList = mainMap.value( QLatin1String( "beats" ) ).toList(); - summary.setBeats( extractTripleTuple( beatList ) ); - } - if( mainMap.contains( QLatin1String( "sections" ) ) ) { - QVariantList sectionList = mainMap.value( QLatin1String( "sections" ) ).toList(); - summary.setSections( extractTripleTuple( sectionList ) ); - } - if( mainMap.contains( QLatin1String( "segments" ) ) ) { - QVariantList segmentList = mainMap.value( QLatin1String( "segments" ) ).toList(); - Echonest::SegmentList segments; - segments.reserve( segmentList.size() ); - for( QVariantList::const_iterator iter = segmentList.constBegin(); iter != segmentList.constEnd(); ++iter ) { - Echonest::Segment segment; - QVariantMap segmentMap = iter->toMap(); - segment.confidence = segmentMap.value( QLatin1String( "confidence" ), -1 ).toReal(); - segment.duration = segmentMap.value( QLatin1String( "duration" ), -1 ).toReal(); - segment.loudness_max = segmentMap.value( QLatin1String( "loudness_max" ), -1 ).toReal(); - segment.loudness_max_time = segmentMap.value( QLatin1String( "loudness_max_time" ), -1 ).toReal(); - segment.loudness_start = segmentMap.value( QLatin1String( "loudness_start" ), -1 ).toReal(); - // pitches - QVariantList pitchesList = segmentMap.value( QLatin1String( "pitches" ) ).toList(); - QVector< qreal > pitches; - pitches.reserve( pitchesList.size() ); - for( QVariantList::const_iterator piter = pitchesList.constBegin(); piter != pitchesList.constEnd(); ++piter ) - pitches.append( piter->toReal() ); - segment.pitches = pitches; - segment.start = segmentMap.value( QLatin1String( "start" ), -1 ).toReal(); - // timbre - QVariantList timbreList = segmentMap.value( QLatin1String( "timbre" ) ).toList(); - QVector< qreal > timbres; - timbres.reserve( timbreList.size() ); - for( QVariantList::const_iterator titer = timbreList.constBegin(); titer != timbreList.constEnd(); ++titer ) - timbres.append( titer->toReal() ); - segment.timbre = timbres; - segments.append( segment ); - } - summary.setSegments( segments ); - } - if( mainMap.contains( QLatin1String( "tatums" ) ) ) { - QVariantList tatumList = mainMap.value( QLatin1String( "tatums" ) ).toList(); - summary.setTatums( extractTripleTuple( tatumList ) ); - } - if( mainMap.contains( QLatin1String( "track" ) ) ) { - QVariantMap trackMap = mainMap.value( QLatin1String( "track" ) ).toMap(); - summary.setSampleRate( trackMap.value( QLatin1String( "analysis_sample_rate" ), -1 ).toReal() ); - summary.setEndOfFadeIn( trackMap.value( QLatin1String( "end_of_fade_in" ), -1 ).toReal() ); - summary.setKeyConfidence( trackMap.value( QLatin1String( "key_confidence" ), -1 ).toReal() ); - summary.setModeConfidence( trackMap.value( QLatin1String( "mode_confidence" ), -1 ).toReal() ); - summary.setNumSamples( trackMap.value( QLatin1String( "num_samples" ), -1 ).toLongLong() ); - summary.setSampleMD5( trackMap.value( QLatin1String( "sample_md5" ) ).toString() ); - summary.setStartOfFadeOut( trackMap.value( QLatin1String( "start_of_fade_out" ), -1 ).toReal() ); - summary.setTempoConfidence( trackMap.value( QLatin1String( "tempo_confidence" ), -1 ).toReal() ); - summary.setTimeSignatureConfidence( trackMap.value( QLatin1String( "time_signature_confidence" ), -1 ).toReal() ); - } -} - - -Echonest::Artists Echonest::Parser::parseArtists( QXmlStreamReader& xml ) throw( Echonest::ParseError ) -{ - // we expect to be in an start element - if( xml.atEnd() || xml.name() != "artists" || !xml.isStartElement() ) - throw ParseError( Echonest::UnknownParseError ); - - xml.readNextStartElement(); - - Echonest::Artists artists; - while( !xml.atEnd() && ( xml.name() != "artists" || !xml.isEndElement() ) ) { - if( xml.atEnd() || xml.name() != "artist" || !xml.isStartElement() ) - throw Echonest::ParseError( Echonest::UnknownParseError ); - Echonest::Artist artist; - while( !xml.atEnd() && ( xml.name() != "artist" || !xml.isEndElement() ) ) { - parseArtistInfo( xml, artist ); - xml.readNextStartElement(); - } - artists.append( artist ); - - xml.readNext(); - } - return artists; -} - -int Echonest::Parser::parseArtistInfoOrProfile( QXmlStreamReader& xml , Echonest::Artist& artist ) throw( Echonest::ParseError ) -{ - if( xml.name() == "start" ) { // this is an individual info query, so lets read it - xml.readNextStartElement(); - xml.readNext(); - - int results = -1; - if( xml.name() == "total" ) { - results = xml.readElementText().toInt(); - xml.readNextStartElement(); - } - - parseArtistInfo( xml, artist ); - - return results; - } else if( xml.name() == "songs" ) { - parseArtistSong( xml, artist ); - } else if( xml.name() == "urls" ) { // urls also has no start/total - parseUrls( xml, artist ); - } else { // this is either a profile query, or a familiarity or hotttness query, so save all the data we find - while( !( xml.name() == "artist" && xml.tokenType() == QXmlStreamReader::EndElement ) ) { - parseArtistInfo( xml, artist ); - xml.readNextStartElement(); - } - } - - return 0; -} - -void Echonest::Parser::parseArtistInfo( QXmlStreamReader& xml, Echonest::Artist& artist ) throw( Echonest::ParseError ) -{ - // parse each sort of artist information - if( xml.name() == "audio" ) { - parseAudio( xml, artist ); - } else if( xml.name() == "biographies" ) { - parseBiographies( xml, artist ); - } else if( xml.name() == "familiarity" ) { - artist.setFamiliarity( xml.readElementText().toDouble() ); - } else if( xml.name() == "hotttnesss" ) { - artist.setHotttnesss( xml.readElementText().toDouble() ); - } else if( xml.name() == "images" ) { - parseImages( xml, artist ); - } else if( xml.name() == "news" && xml.isStartElement() ) { - parseNewsOrBlogs( xml, artist, true ); - } else if( xml.name() == "blogs" ) { - parseNewsOrBlogs( xml, artist, false ); - } else if( xml.name() == "reviews" ) { - parseReviews( xml, artist ); - } else if( xml.name() == "terms" ) { - parseTerms( xml, artist ); - } else if( xml.name() == "urls" ) { - parseTerms( xml, artist ); - } else if( xml.name() == "songs" ) { - parseArtistSong( xml, artist ); - } else if( xml.name() == "video" ) { - parseVideos( xml, artist ); - } else if( xml.name() == "foreign_ids" ) { - parseForeignArtistIds( xml, artist ); - } else if( xml.name() == "name" ) { - artist.setName( xml.readElementText() ); - } else if( xml.name() == "id" ) { - artist.setId( xml.readElementText().toLatin1() ); - } -} - - -// parse each type of artist attribute - -void Echonest::Parser::parseAudio( QXmlStreamReader& xml, Echonest::Artist& artist ) throw( Echonest::ParseError ) -{ - if( xml.atEnd() || xml.name() != "audio" || xml.tokenType() != QXmlStreamReader::StartElement ) - throw Echonest::ParseError( Echonest::UnknownParseError ); - - xml.readNextStartElement(); - Echonest::AudioList audioList; - while( !xml.atEnd() && ( xml.name() != "audio" || xml.tokenType() != QXmlStreamReader::EndElement ) ) { - Echonest::AudioFile audio; - do { - xml.readNext(); - if( xml.name() == "title" ) - audio.setTitle( xml.readElementText() ); - else if( xml.name() == "url" ) - audio.setUrl( QUrl( xml.readElementText() ) ); - else if( xml.name() == "artist" ) - audio.setArtist( xml.readElementText() ); - else if( xml.name() == "date" ) - audio.setDate( QDateTime::fromString( xml.readElementText(), Qt::ISODate ) ); - else if( xml.name() == "length" ) - audio.setLength( xml.readElementText().toDouble() ); - else if( xml.name() == "link" ) - audio.setLink( QUrl( xml.readElementText() ) ); - else if( xml.name() == "release" ) - audio.setRelease( xml.readElementText() ); - else if( xml.name() == "id" ) - audio.setId( xml.readElementText().toLatin1() ); - - } while( !xml.atEnd() && ( xml.name() != "audio" || xml.tokenType() != QXmlStreamReader::EndElement ) ); - audioList.append( audio ); - xml.readNext(); - } - artist.setAudio( audioList ); -} - -void Echonest::Parser::parseBiographies( QXmlStreamReader& xml, Echonest::Artist& artist ) throw( Echonest::ParseError ) -{ - if( xml.atEnd() || xml.name() != "biographies" || xml.tokenType() != QXmlStreamReader::StartElement ) - throw Echonest::ParseError( Echonest::UnknownParseError ); - - xml.readNextStartElement(); - Echonest::BiographyList bios; - while( !xml.atEnd() && ( xml.name() != "biographies" || xml.tokenType() != QXmlStreamReader::EndElement ) ) { - Echonest::Biography bio; - do { - xml.readNext(); - - if( xml.name() == "text" ) - bio.setText( xml.readElementText() ); - else if( xml.name() == "site" ) - bio.setSite( xml.readElementText() ); - else if( xml.name() == "url" ) - bio.setUrl( QUrl( xml.readElementText() ) ); - else if( xml.name() == "license" ) - bio.setLicense( parseLicense( xml) ); - - } while( !xml.atEnd() && ( xml.name() != "biography" || xml.tokenType() != QXmlStreamReader::EndElement ) ); - bios.append( bio ); - xml.readNext(); - } - artist.setBiographies( bios ); -} - - -void Echonest::Parser::parseImages( QXmlStreamReader& xml, Echonest::Artist& artist ) throw( Echonest::ParseError ) -{ - if( xml.atEnd() || xml.name() != "images" || xml.tokenType() != QXmlStreamReader::StartElement ) - throw Echonest::ParseError( Echonest::UnknownParseError ); - - xml.readNextStartElement(); - Echonest::ArtistImageList imgs; - while( !xml.atEnd() && ( xml.name() != "images" || xml.tokenType() != QXmlStreamReader::EndElement ) ) { - Echonest::ArtistImage img; - do { - xml.readNext(); - - if( xml.name() == "url" ) - img.setUrl( QUrl( xml.readElementText() ) ); - else if( xml.name() == "license" ) - img.setLicense( parseLicense( xml) ); - - } while( !xml.atEnd() && ( xml.name() != "image" || xml.tokenType() != QXmlStreamReader::EndElement ) ); - imgs.append( img ); - xml.readNext(); - } - artist.setImages( imgs ); -} - -void Echonest::Parser::parseNewsOrBlogs( QXmlStreamReader& xml, Echonest::Artist& artist, bool news ) throw( Echonest::ParseError ) -{ - if( news && ( xml.atEnd() || xml.name() != "news" || xml.tokenType() != QXmlStreamReader::StartElement ) ) - throw Echonest::ParseError( Echonest::UnknownParseError ); - else if( !news && ( xml.atEnd() || xml.name() != "blogs" || xml.tokenType() != QXmlStreamReader::StartElement ) ) - throw Echonest::ParseError( Echonest::UnknownParseError ); - - xml.readNextStartElement(); - Echonest::NewsList newsList; - while( !( ( xml.name() == "news" || xml.name() == "blogs" ) && xml.tokenType() == QXmlStreamReader::EndElement ) ) { - Echonest::NewsArticle news; - do { - xml.readNextStartElement(); - - if( xml.name() == "name" ) - news.setName( xml.readElementText() ); - else if( xml.name() == "url" ) - news.setUrl( QUrl( xml.readElementText() ) ); - else if( xml.name() == "summary" ) - news.setSummary( xml.readElementText() ); - else if( xml.name() == "date_found" ) - news.setDateFound( QDateTime::fromString( xml.readElementText(), Qt::ISODate ) ); - else if( xml.name() == "id" ) - news.setId( xml.readElementText().toLatin1() ); - else if( xml.name() == "date_posted" ) - news.setDatePosted( QDateTime::fromString( xml.readElementText(), Qt::ISODate ) ); - } while( !( ( xml.name() == "news" || xml.name() == "blog" ) && xml.tokenType() == QXmlStreamReader::EndElement ) ); - newsList.append( news ); - xml.readNext(); - } - if( news ) - artist.setNews( newsList ); - else - artist.setBlogs( newsList ); -} - -void Echonest::Parser::parseReviews( QXmlStreamReader& xml, Echonest::Artist& artist ) throw( Echonest::ParseError ) -{ - if( xml.atEnd() || xml.name() != "reviews" || xml.tokenType() != QXmlStreamReader::StartElement ) - throw Echonest::ParseError( Echonest::UnknownParseError ); - - xml.readNextStartElement(); - Echonest::ReviewList reviews; - while( !xml.atEnd() && ( xml.name() != "reviews" || xml.tokenType() != QXmlStreamReader::EndElement ) ) { - Echonest::Review review; - do { - xml.readNextStartElement(); - - if( xml.name() == "url" ) - review.setUrl( QUrl( xml.readElementText() ) ); - else if( xml.name() == "name" ) - review.setName( xml.readElementText() ); - else if( xml.name() == "summary" ) - review.setSummary( xml.readElementText() ); - else if( xml.name() == "date_found" ) - review.setDateFound( QDateTime::fromString( xml.readElementText(), Qt::ISODate ) ); - else if( xml.name() == "image" ) - review.setImageUrl( QUrl( xml.readElementText() ) ); - else if( xml.name() == "release" ) - review.setRelease( xml.readElementText() ); - else if( xml.name() == "id" ) - review.setId( xml.readElementText().toLatin1() ); - - } while( !xml.atEnd() && ( xml.name() != "review" || xml.tokenType() != QXmlStreamReader::EndElement ) ); - reviews.append( review ); - xml.readNext(); - } - artist.setReviews( reviews ); -} - -void Echonest::Parser::parseArtistSong( QXmlStreamReader& xml, Echonest::Artist& artist ) throw( Echonest::ParseError ) -{ - if( xml.atEnd() || xml.name() != "songs" || xml.tokenType() != QXmlStreamReader::StartElement ) - throw Echonest::ParseError( Echonest::UnknownParseError ); - - xml.readNextStartElement(); - Echonest::SongList songs; - while( !xml.atEnd() && ( xml.name() != "songs" || xml.tokenType() != QXmlStreamReader::EndElement ) ) { - if( xml.name() == "song" && xml.isStartElement() ) - { - Echonest::Song song; - while( !xml.atEnd() && ( xml.name() != "song" || !xml.isEndElement() ) ) { - if( xml.name() == "id" && xml.isStartElement() ) - song.setId( xml.readElementText().toLatin1() ); - else if( xml.name() == "title" && xml.isStartElement() ) - song.setTitle( xml.readElementText() ); - xml.readNextStartElement(); - } - songs.append( song ); - } - xml.readNext(); - } - artist.setSongs( songs ); -} - -void Echonest::Parser::parseTerms( QXmlStreamReader& xml, Echonest::Artist& artist ) throw( Echonest::ParseError ) -{ - if( xml.atEnd() || xml.name() != "terms" || xml.tokenType() != QXmlStreamReader::StartElement ) - throw Echonest::ParseError( Echonest::UnknownParseError ); - artist.setTerms( parseTopTermList( xml ) ); -} - -Echonest::Artists Echonest::Parser::parseArtistSuggestList( QXmlStreamReader& xml ) throw( ParseError ) -{ - if( xml.atEnd() || xml.name() != "artists" || xml.tokenType() != QXmlStreamReader::StartElement ) - throw Echonest::ParseError( Echonest::UnknownParseError ); - - Echonest::Artists artists; - - xml.readNextStartElement(); - while( xml.name() != "artists" || !xml.isEndElement() ) { - QString name; - QByteArray id; - while( xml.name() != "artist" || !xml.isEndElement() ) { - if( xml.name() == "name" && xml.isStartElement() ) - name = xml.readElementText(); - else if( xml.name() == "id" && xml.isStartElement() ) - id = xml.readElementText().toLatin1(); - xml.readNext(); - } - artists << Echonest::Artist( id, name ); - xml.readNext(); - } - return artists; -} - - -void Echonest::Parser::parseUrls( QXmlStreamReader& xml, Echonest::Artist& artist ) throw( Echonest::ParseError ) -{ - if( xml.atEnd() || xml.name() != "urls" || xml.tokenType() != QXmlStreamReader::StartElement ) - throw Echonest::ParseError( Echonest::UnknownParseError ); - xml.readNextStartElement(); -// xml.readNextStartElement(); - - while( !xml.atEnd() && ( xml.name() != "urls" || !xml.isEndElement() ) ) { - if( xml.name() == "lastfm_url" ) - artist.setLastFmUrl( QUrl( xml.readElementText() ) ); - else if( xml.name() == "aolmusic_url" ) - artist.setAolMusicUrl( QUrl( xml.readElementText() ) ); - else if( xml.name() == "myspace_url" ) - artist.setMyspaceUrl( QUrl( xml.readElementText() ) ); - else if( xml.name() == "amazon_url" ) - artist.setAmazonUrl( QUrl( xml.readElementText() ) ); - else if( xml.name() == "itunes_url" ) - artist.setItunesUrl( QUrl( xml.readElementText() ) ); - else if( xml.name() == "mb_url" ) - artist.setMusicbrainzUrl( QUrl( xml.readElementText() ) ); - - xml.readNextStartElement(); - } - xml.readNextStartElement(); -} - -void Echonest::Parser::parseVideos( QXmlStreamReader& xml, Echonest::Artist& artist ) throw( Echonest::ParseError ) -{ - if( xml.atEnd() || xml.name() != "video" || xml.tokenType() != QXmlStreamReader::StartElement ) - throw Echonest::ParseError( Echonest::UnknownParseError ); - - Echonest::VideoList videos; - while( xml.name() == "video" && xml.isStartElement() ) { - - Echonest::Video video; - - while( !xml.atEnd() && ( xml.name() != "video" || !xml.isEndElement() ) ) { - if( xml.name() == "title" ) - video.setTitle( xml.readElementText() ); - else if( xml.name() == "url" ) - video.setUrl( QUrl( xml.readElementText() ) ); - else if( xml.name() == "site" ) - video.setSite( xml.readElementText() ); - else if( xml.name() == "date_found" ) - video.setDateFound( QDateTime::fromString( xml.readElementText(), Qt::ISODate ) ); - else if( xml.name() == "image_url" ) - video.setImageUrl( QUrl( xml.readElementText() ) ); - else if( xml.name() == "id" ) - video.setId( xml.readElementText().toLatin1() ); - - xml.readNextStartElement(); - } - videos.append( video ); - - xml.readNextStartElement(); - } - artist.setVideos( videos ); -} - -Echonest::TermList Echonest::Parser::parseTopTermList( QXmlStreamReader& xml ) throw( Echonest::ParseError ) -{ - if( xml.atEnd() || xml.name() != "terms" || xml.tokenType() != QXmlStreamReader::StartElement ) - throw Echonest::ParseError( Echonest::UnknownParseError ); - - Echonest::TermList terms; - while( xml.name() == "terms" && xml.isStartElement() ) { - Echonest::Term term; -// qDebug() << "Parsing term outer item:" << xml.name() << xml.isStartElement(); - while( !xml.atEnd() && ( xml.name() != "terms" || !xml.isEndElement() ) ) { - if( xml.name() == "frequency" ) - term.setFrequency( xml.readElementText().toDouble() ); - else if( xml.name() == "name" ) - term.setName( xml.readElementText() ); - else if( xml.name() == "weight" ) - term.setWeight( xml.readElementText().toDouble() ); - - xml.readNextStartElement(); - } - terms.append( term ); -// qDebug() << "Parsing exernal term item:" << xml.name() << xml.isStartElement(); - - xml.readNext(); - } -// qDebug() << " done Parsing terms:" << xml.name() << xml.isStartElement(); - - return terms; -} - - -QVector< QString > Echonest::Parser::parseTermList( QXmlStreamReader& xml ) throw( Echonest::ParseError ) -{ - if( xml.atEnd() || xml.name() != "terms" || xml.tokenType() != QXmlStreamReader::StartElement ) - throw Echonest::ParseError( Echonest::UnknownParseError ); - - QVector< QString > terms; - while( xml.name() != "response" || !xml.isEndElement() ) { - if( xml.name() == "name" && xml.isStartElement() ) - terms.append( xml.readElementText() ); - xml.readNextStartElement(); - } - - return terms; -} - -void Echonest::Parser::parseForeignArtistIds( QXmlStreamReader& xml, Echonest::Artist& artist ) throw( Echonest::ParseError ) -{ - if( xml.atEnd() || xml.name() != "foreign_ids" || xml.tokenType() != QXmlStreamReader::StartElement ) - throw Echonest::ParseError( Echonest::UnknownParseError ); - - Echonest::ForeignIds ids; - while( xml.name() != "foreign_ids" || !xml.isEndElement() ) { - xml.readNext(); - xml.readNext(); // get past the enclosing , or else we'll think it's the internal one. - Echonest::ForeignId id; - while( xml.name() != "foreign_id" || !xml.isEndElement() ) { - if( xml.name() == "catalog" && xml.isStartElement() ) - id.catalog = xml.readElementText(); - else if( xml.name() == "foreign_id" && xml.isStartElement() ) - id.foreign_id = xml.readElementText(); - - xml.readNext(); - } - ids.append( id ); - xml.readNext(); - } - artist.setForeignIds( ids ); -} - -Echonest::License Echonest::Parser::parseLicense( QXmlStreamReader& xml ) throw( Echonest::ParseError ) -{ - if( xml.atEnd() || xml.name() != "license" || xml.tokenType() != QXmlStreamReader::StartElement ) - throw Echonest::ParseError( Echonest::UnknownParseError ); - - Echonest::License license; - while( !xml.atEnd() && ( xml.name() != "license" || xml.tokenType() != QXmlStreamReader::EndElement ) ) { - if( xml.name() == "type" ) - license.type = xml.readElementText(); - else if( xml.name() == "attribution" ) - license.attribution = xml.readElementText(); - else if( xml.name() == "url" ) - license.url = QUrl( xml.readElementText() ); - - xml.readNext(); - } - - xml.readNextStartElement(); - return license; -} - -QByteArray Echonest::Parser::parsePlaylistSessionId( QXmlStreamReader& xml ) throw( Echonest::ParseError ) -{ - if( xml.atEnd() || xml.name() != "session_id" || xml.tokenType() != QXmlStreamReader::StartElement ) - throw Echonest::ParseError( Echonest::UnknownParseError ); - - QByteArray sessionId = xml.readElementText().toLatin1(); - xml.readNext(); //read to next start element - return sessionId; -} - -// Catalogs parseCatalogList( QXmlStreamReader& xml ) throw( ParseError ); -Echonest::Catalogs Echonest::Parser::parseCatalogList( QXmlStreamReader& xml ) throw( Echonest::ParseError ) -{ - if( xml.atEnd() || xml.tokenType() != QXmlStreamReader::StartElement ) - throw Echonest::ParseError( Echonest::UnknownParseError ); - - int total = -1; - while( xml.name() != "response" && ( xml.name() != QLatin1String( "catalogs" ) || !xml.isStartElement() ) ) { - if( xml.name() == "total" && xml.isStartElement() ) - total = xml.readElementText().toInt(); - xml.readNextStartElement(); - } - - - Echonest::Catalogs catalogs; - - if( xml.name() != "catalogs" ) { // none - return catalogs; - } - - catalogs.reserve( total ); - // now we're pointing at the first catalog - while( xml.name() != "response" || !xml.isEndElement() ) - catalogs.append( Echonest::Parser::parseCatalog( xml ) ); - - return catalogs; -} - -Echonest::Catalog Echonest::Parser::parseCatalog( QXmlStreamReader& xml, bool justOne ) throw( Echonest::ParseError ) -{ - QString cName = justOne ? QLatin1String( "catalog" ) : QLatin1String( "catalogs" ); - if( xml.atEnd() || xml.name() != cName || !xml.isStartElement() ) - throw Echonest::ParseError( Echonest::UnknownParseError ); - xml.readNextStartElement(); - - Echonest::Catalog catalog; - while( xml.name() != cName || !xml.isEndElement() ) { - if( xml.name() == "total" && xml.isStartElement() ) - catalog.setTotal( xml.readElementText().toInt() ); - else if( xml.name() == "type" && xml.isStartElement() ) - catalog.setType( Echonest::literalToCatalogType( xml.readElementText().toLatin1() ) ); - else if( xml.name() == "id" && xml.isStartElement() ) - catalog.setId( xml.readElementText().toLatin1() ); - else if( xml.name() == "name" && xml.isStartElement() ) - catalog.setName( xml.readElementText() ); - else if( xml.name() == "items" && xml.isStartElement() ) { - QList items = parseCatalogItems( xml ); - if( items.isEmpty() ) { - xml.readNextStartElement(); - continue; - } - if( items[ 0 ]->type() == Echonest::CatalogTypes::Artist ) { - saveArtistList( catalog, items ); - } else if( items[ 0 ]->type() == Echonest::CatalogTypes::Song ) { - saveSongList( catalog, items ); - } - } - xml.readNextStartElement(); - } - xml.readNext(); - - return catalog; -} - -QList Echonest::Parser::parseCatalogItems( QXmlStreamReader& xml ) throw( Echonest::ParseError ) -{ - if( xml.atEnd() || xml.name() != "items" || xml.tokenType() != QXmlStreamReader::StartElement ) - throw Echonest::ParseError( Echonest::UnknownParseError ); - - QList items; - while( xml.name() == "items" && xml.isStartElement() ) { - // OK, the mixture of the crappy Catalog API and strongly typed c++ makes this ugly. We don't know if this is an artist or song until we reach the artist_id or song_id. - // so, we'll keep two copies till the end, where we throw away one. :( - Echonest::CatalogArtist* artist = new Echonest::CatalogArtist; - Echonest::CatalogSong* song = new CatalogSong; - while( xml.name() != "items" || !xml.isEndElement() ) { - // OK, we have to check for all possible song+artist types :'( - if( xml.name() == "rating" && xml.isStartElement() ) { /// mixed and artist items - artist->setRating( xml.readElementText().toInt() ); - song->setRating( artist->rating() ); - } else if( xml.name() == "request" && xml.isStartElement() ) { - parseCatalogRequestItem( xml, *artist, *song ); - } else if( xml.name() == "artist_name" && xml.isStartElement() ) { - artist->setName( xml.readElementText() ); - song->setArtistName( artist->name() ); - } else if( xml.name() == "reviews" && xml.isStartElement() ) { - parseReviews( xml, *artist ); - } else if( xml.name() == "terms" && xml.isStartElement() ) { - parseTerms( xml, *artist ); - continue; - } else if( xml.name() == "biographies" && xml.isStartElement() ) { - parseBiographies( xml, *artist ); - } else if( xml.name() == "familiarity" && xml.isStartElement() ) { - artist->setFamiliarity( xml.readElementText().toDouble() ); - song->setArtistFamiliarity( artist->familiarity() ); - } else if( xml.name() == "blogs" && xml.isStartElement() ) { - parseNewsOrBlogs( xml, *artist, false ); - } else if( xml.name() == "hotttnesss" && xml.isStartElement() ) { - artist->setHotttnesss( xml.readElementText().toDouble() ); - song->setArtistHotttnesss( artist->hotttnesss() ); - } else if( xml.name() == "video" && xml.isStartElement() ) { - parseVideos( xml, *artist ); - } else if( xml.name() == "urls" && xml.isStartElement() ) { - parseUrls( xml, *artist ); - } else if( xml.name() == "news" && xml.isStartElement() ) { - parseNewsOrBlogs( xml, *artist ); - } else if( xml.name() == "images" && xml.isStartElement() ) { - parseImages( xml, *artist ); - } else if( xml.name() == "date_added" && xml.isStartElement() ) { - artist->setDateAdded( QDateTime::fromString( xml.readElementText(), Qt::ISODate ) ); - song->setDateAdded( artist->dateAdded() ); - } else if( xml.name() == "artist_id" && xml.isStartElement() ) { - artist->setId( xml.readElementText().toLatin1() ); - song->setArtistId( artist->id() ); - } else if( xml.name() == "audio" && xml.isStartElement() ) { - parseAudio( xml, *artist ); - } else if( xml.name() == "foreign_id" && xml.isStartElement() ) { - artist->setForeignId( xml.readElementText().toLatin1() ); - song->setForeignId( artist->foreignId() ); - } else if( xml.name() == "song_id" && xml.isStartElement() ) { /// song-specific entries - song->setId( xml.readElementText().toLatin1() ); - } else if( xml.name() == "song_name" && xml.isStartElement() ) { - song->setTitle( xml.readElementText() ); - } else if( xml.name() == "tracks" && xml.isStartElement() ) { - song->setTracks( parseCatalogSongTracks( xml ) ); - } else if( xml.name() == "play_count" && xml.isStartElement() ) { - static_cast(song)->setPlayCount( xml.readElementText().toInt() ); - } else if( xml.name() == "artist_hotttnesss" && xml.isStartElement() ) { - song->setArtistHotttnesss( xml.readElementText().toDouble() ); - } else if( xml.name() == "artist_location" && xml.isStartElement() ) { - // TODO - } else if( xml.name() == "song_hotttnesss" && xml.isStartElement() ) { - song->setHotttnesss( xml.readElementText().toDouble() ); - } else if( xml.name() == "artist_familiarity" && xml.isStartElement() ) { - song->setArtistFamiliarity( xml.readElementText().toDouble() ); - } else if( xml.name() == "audio_summary" && xml.isStartElement() ) { - song->setAudioSummary( parseAudioSummary( xml ) ); - } - xml.readNextStartElement(); - } - if( !song->id().isEmpty() ) { // No song id, so it's an artist. -// qDebug() << "Adding a song"; - items << song; - delete artist; - } else if( !artist->id().isEmpty() ) { -// qDebug() << "Adding an artist"; - items << artist; - delete song; - } else { // dunno what this is really. lets use the song one for now -// qDebug() << "Adding an EMPTY"; - items << song; - delete artist; - } - xml.readNext(); - } - - return items; -} - -void Echonest::Parser::parseCatalogRequestItem( QXmlStreamReader& xml, Echonest::CatalogArtist& artist, Echonest::CatalogSong& song) throw( Echonest::ParseError ) -{ - if( xml.atEnd() || xml.name() != "request" || xml.tokenType() != QXmlStreamReader::StartElement ) - throw Echonest::ParseError( Echonest::UnknownParseError ); - - Echonest::CatalogUpdateEntry request; - while( xml.name() != "request" || !xml.isEndElement() ) { - if( xml.name() == "item_id" ) { - request.setItemId( xml.readElementText().toLatin1() ); - } else if( xml.name() == "artist_name" ) { - request.setArtistName( xml.readElementText() ); - } else if( xml.name() == "song_name" ) { - request.setSongName( xml.readElementText() ); - } else if( xml.name() == "fp_code" ) { - request.setFingerprint( xml.readElementText().toLatin1() ); - } else if( xml.name() == "song_id" ) { - request.setSongId( xml.readElementText().toLatin1() ); - } else if( xml.name() == "artist_id" ) { - request.setArtistId( xml.readElementText().toLatin1() ); - } else if( xml.name() == "release" ) { - request.setRelease( xml.readElementText() ); - } else if( xml.name() == "genre" ) { - request.setGenre( xml.readElementText() ); - } - xml.readNext(); - } - artist.setRequest( request ); - song.setRequest( request ); -} - -void Echonest::Parser::saveArtistList( Echonest::Catalog& catalog, QList& artists) -{ - // will copy artists into the catalog, and delete the origin - Echonest::CatalogArtists ca; - foreach( const Echonest::CatalogItem* item, artists ) { - ca.append( CatalogArtist( *static_cast( item ) ) ); - } - qDeleteAll( artists ); - catalog.setArtists( ca ); -} - -void Echonest::Parser::saveSongList( Echonest::Catalog& catalog, QList& songs) -{ - // will copy songs into the catalog, and delete the origin - Echonest::CatalogSongs ca; - foreach( const Echonest::CatalogItem* item, songs ) { - ca.append( CatalogSong( *static_cast( item ) ) ); - } - qDeleteAll( songs ); - catalog.setSongs( ca ); -} - - -Echonest::CatalogStatus Echonest::Parser::parseCatalogStatus( QXmlStreamReader& xml ) throw( Echonest::ParseError ) -{ - Echonest::CatalogStatus status; - - while( xml.name() != "response" || !xml.isEndElement() ) { - if( xml.name() == "ticket_status" && xml.isStartElement() ) - status.status = Echonest::literalToCatalogStatus( xml.readElementText().toLatin1() ); - else if( xml.name() == "details" && xml.isStartElement() ) - status.details = xml.readElementText(); - else if( xml.name() == "items_updated" && xml.isStartElement() ) - status.items_updated = xml.readElementText().toInt(); - else if( xml.name() == "update_info" && xml.isStartElement() ) - status.items = parseTicketUpdateInfo( xml ); -// else if( xml.name() == "percent_complete" && xml.isStartElement() ) -// status.percent_complete = xml.readElementText().toInt(); - - xml.readNext(); - } - - return status; -} - -Echonest::CatalogStatusItem Echonest::Parser::parseTicketUpdateInfo( QXmlStreamReader& xml ) throw( Echonest::ParseError ) -{ -// if( xml.atEnd() || xml.name() != "ticket_status" || xml.tokenType() != QXmlStreamReader::StartElement ) -// throw Echonest::ParseError( Echonest::UnknownParseError ); - // TODO - return Echonest::CatalogStatusItem(); -} - -QByteArray Echonest::Parser::parseCatalogTicket( QXmlStreamReader& xml ) throw( Echonest::ParseError ) -{ - if( xml.atEnd() || xml.name() != "ticket" || xml.tokenType() != QXmlStreamReader::StartElement ) - throw Echonest::ParseError( Echonest::UnknownParseError ); - - QByteArray ticket= xml.readElementText().toLatin1(); - return ticket; -} - -Echonest::Catalog Echonest::Parser::parseNewCatalog( QXmlStreamReader& xml ) throw( Echonest::ParseError ) -{ - if( xml.atEnd() || xml.tokenType() != QXmlStreamReader::StartElement ) - throw Echonest::ParseError( Echonest::UnknownParseError ); - - QString name; - QByteArray id; - Echonest::CatalogTypes::Type type = Echonest::CatalogTypes::Artist; - - qDebug() << "Parsing new catalog..."; - while( xml.name() != "response" || !xml.isEndElement() ) { - qDebug() << "Parsing at:" << xml.name().toString(); - if( xml.name() == "name" && xml.isStartElement() ) - name = xml.readElementText(); - else if( xml.name() == "id" && xml.isStartElement() ) - id = xml.readElementText().toLatin1(); - else if( xml.name() == "type" && xml.isStartElement() ) - type = Echonest::literalToCatalogType( xml.readElementText().toLatin1() ); - - xml.readNextStartElement(); - qDebug() << "Parsing next at:" << xml.name().toString(); - } - Echonest::Catalog c = Echonest::Catalog( id ); - c.setName( name ); - c.setType( type ); - - return c; -} - -Echonest::SessionInfo Echonest::Parser::parseSessionInfo( QXmlStreamReader& xml ) throw( Echonest::ParseError ) -{ - Echonest::SessionInfo info; - - while( xml.name() != "response" || !xml.isEndElement() ) { -// qDebug() << "Parsing part of session info:" << xml.name() << xml.isStartElement(); - if( xml.name() == "terms" && xml.isStartElement() ) { - info.terms = parseTopTermList( xml ); - continue; - } else if( xml.name() == "rules" && xml.isStartElement() ) { - info.rules = parseRulesList( xml ); - continue; - } else if( xml.name() == "session_id" && xml.isStartElement() ) - info.session_id = xml.readElementText().toLatin1(); - else if( xml.name() == "seeds" && xml.isStartElement() ) - info.seeds.append( Artist( xml.readElementText().toLatin1() ) ); - else if( xml.name() == "banned_artists" && xml.isStartElement() ) - info.banned_artists.append( Artist( xml.readElementText().toLatin1() ) ); - else if( xml.name() == "seed_songs" && xml.isStartElement() ) - info.seed_songs.append( Song( xml.readElementText().toLatin1() ) ); - else if( xml.name() == "seed_catalog" && xml.isStartElement() ) - info.seed_catalogs.append( Catalog( xml.readElementText().toLatin1() ) ); - else if( xml.name() == "playlist_type" && xml.isStartElement() ) - info.playlist_type = xml.readElementText(); - else if( xml.name() == "skipped_songs" && xml.isStartElement() ) { - info.skipped_songs = parseSessionSongItem( xml, QLatin1String( "skipped_songs" ) ); - continue; - } else if( xml.name() == "banned_songs" && xml.isStartElement() ) { - info.banned_songs = parseSessionSongItem( xml, QLatin1String( "banned_songs" ) ); - continue; - } else if( xml.name() == "rated_songs" && xml.isStartElement() ) { - info.rated_songs = parseSessionSongItem( xml, QLatin1String( "rated_songs" ) ); - continue; - } else if( xml.name() == "history" && xml.isStartElement() ) { - info.history = parseSessionSongItem( xml, QLatin1String( "history" ) ); - continue; - } - xml.readNext(); - } - return info; -} - - -QVector< QString > Echonest::Parser::parseRulesList( QXmlStreamReader& xml ) throw( Echonest::ParseError ) -{ - if( xml.atEnd() || xml.name() != "rules" || xml.tokenType() != QXmlStreamReader::StartElement ) - throw Echonest::ParseError( Echonest::UnknownParseError ); - - QVector< QString > rules; - while( xml.name() == "rules" && xml.isStartElement() ) { -// qDebug() << "Parsing start of rules:" << xml.name() << xml.isStartElement(); - xml.readNextStartElement(); - rules.append( xml.readElementText() ); - xml.readNext(); - xml.readNext(); -// qDebug() << "Parsing end of rules:" << xml.name() << xml.isStartElement(); - } - return rules; -} - -QVector< Echonest::SessionItem > Echonest::Parser::parseSessionSongItem( QXmlStreamReader& xml, const QString& type ) throw( Echonest::ParseError ) -{ - if( xml.atEnd() || xml.name() != type || xml.tokenType() != QXmlStreamReader::StartElement ) - throw Echonest::ParseError( Echonest::UnknownParseError ); - - QVector< Echonest::SessionItem > items; - while( xml.name() == type && xml.isStartElement() ) { -// qDebug() << "Parsing exernal item:" << xml.name() << xml.isStartElement(); - - Echonest::SessionItem item; - - while( !xml.atEnd() && ( xml.name() != type || !xml.isEndElement() ) ) { -// qDebug() << "Parsing internal item:" << xml.name() << xml.isStartElement(); - if( xml.name() == "served_time" ) - item.served_time = xml.readElementText().toDouble(); - else if( xml.name() == "artist_id" ) - item.artist_id = xml.readElementText().toLatin1(); - else if( xml.name() == "id" ) - item.id = xml.readElementText().toLatin1(); - else if( xml.name() == "artist_name" ) - item.artist_name= xml.readElementText(); - else if( xml.name() == "title" ) - item.title = xml.readElementText(); - else if( xml.name() == "rating" ) - item.rating = xml.readElementText().toInt(); - - xml.readNextStartElement(); - } - items.append( item ); - - xml.readNext(); - } - return items; -} - diff --git a/3rdparty/libechonest/Parsing_p.h b/3rdparty/libechonest/Parsing_p.h deleted file mode 100644 index 74f5e9419..000000000 --- a/3rdparty/libechonest/Parsing_p.h +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - -#ifndef ECHONEST_PARSING_P_H -#define ECHONEST_PARSING_P_H - -#include "Config.h" - -#include -#include "Song.h" -#include "Artist.h" -#include "Catalog.h" -#include "Playlist.h" - -class QNetworkReply; - -namespace Echonest -{ -namespace Parser -{ - /** - * Internal helper parsing functions for QXmlStreamParser - */ - - void checkForErrors( QNetworkReply* reply ) throw( ParseError ); - - // read the start element and then the status element, throwing - // if the result code is not Success - void readStatus( QXmlStreamReader& xml ) throw( ParseError ); - - // parses a block and turns them into a list of Song object - QVector< Song > parseSongList( QXmlStreamReader& xml ) throw( ParseError ); - - // parses a block - Song parseSong( QXmlStreamReader& xml ) throw( ParseError ); - - // parses a block - ArtistLocation parseSongArtistLocation( QXmlStreamReader& xml ) throw( ParseError ); - - // parses a block - Track parseTrack( QXmlStreamReader& xml ) throw( ParseError ); - - // parses a chunk when asking for a song with tracks bucket - Tracks parseSongTrackBucket( QXmlStreamReader& xml ) throw( ParseError ); - - // parses an chunk - AudioSummary parseAudioSummary( QXmlStreamReader& xml ) throw( ParseError ); - // parses the json of the detailed audio summary - void parseDetailedAudioSummary( QNetworkReply* reply, AudioSummary& summary ) throw( ParseError ); - - // parses a list of artists in an block - Echonest::Artists parseArtists( QXmlStreamReader& xml ) throw( ParseError ); - - // parses the contents of an artist fetch result, expects to be positioned after the readStatus() call - // it could be a profile query, in which case it has a bunch of different artist attributes - // or it could be a single fetch, in which case it starts with result number and offset. - // the results are saved back into the artist - int parseArtistInfoOrProfile( QXmlStreamReader&, Echonest::Artist& artist ) throw( ParseError ); - - // parse the individual artist attributes - void parseArtistInfo( QXmlStreamReader& xml, Echonest::Artist& artist ) throw( ParseError ); - - // parse each type of artist attribute - void parseAudio( QXmlStreamReader& xml, Echonest::Artist& artist ) throw( ParseError ); - void parseBiographies( QXmlStreamReader& xml, Echonest::Artist& artist ) throw( ParseError ); - void parseImages( QXmlStreamReader& xml, Echonest::Artist& artist ) throw( ParseError ); - void parseNewsOrBlogs( QXmlStreamReader& xml, Echonest::Artist& artist, bool news = true ) throw( ParseError ); - void parseReviews( QXmlStreamReader& xml, Echonest::Artist& artist ) throw( ParseError ); - void parseTerms( QXmlStreamReader& xml, Echonest::Artist& artist ) throw( ParseError ); - void parseUrls( QXmlStreamReader& xml, Echonest::Artist& artist ) throw( ParseError ); - void parseArtistSong( QXmlStreamReader& xml, Echonest::Artist& artist ) throw( ParseError ); - void parseVideos( QXmlStreamReader& xml, Echonest::Artist& artist ) throw( ParseError ); - void parseForeignArtistIds( QXmlStreamReader& xml, Echonest::Artist& artist ) throw( ParseError ); - - // parse a list of terms - TermList parseTopTermList( QXmlStreamReader& xml ) throw( ParseError ); - QVector< QString > parseTermList( QXmlStreamReader& xml ) throw( ParseError ); - - Artists parseArtistSuggestList( QXmlStreamReader& xml ) throw( ParseError ); - - License parseLicense( QXmlStreamReader& xml ) throw( ParseError ); - - QByteArray parsePlaylistSessionId( QXmlStreamReader& xml ) throw( ParseError ); - - // Catalog functions - Catalogs parseCatalogList( QXmlStreamReader& xml ) throw( ParseError ); - Catalog parseCatalog( QXmlStreamReader& xml, bool justOne = false /* the catalog API is ugly :( */ ) throw( ParseError ); - QList parseCatalogItems( QXmlStreamReader& xml ) throw( ParseError ); - void parseCatalogRequestItem( QXmlStreamReader& xml, Echonest::CatalogArtist&, Echonest::CatalogSong& ) throw( ParseError ); - void saveArtistList( Catalog& catalog, QList& ); - void saveSongList( Catalog& catalog, QList& ); - Echonest::CatalogStatus parseCatalogStatus( QXmlStreamReader& xml ) throw( ParseError ); - Echonest::CatalogStatusItem parseTicketUpdateInfo( QXmlStreamReader& xml ) throw( ParseError ); - QByteArray parseCatalogTicket( QXmlStreamReader& xml ) throw( ParseError ); - Catalog parseNewCatalog( QXmlStreamReader& xml ) throw( ParseError ); - - // parses a chunk when asking for a song with tracks bucket in a catalog.read call - Tracks parseCatalogSongTracks( QXmlStreamReader& xml ) throw( ParseError ); - - SessionInfo parseSessionInfo( QXmlStreamReader& xml ) throw( ParseError ); - QVector< QString > parseRulesList( QXmlStreamReader& xml ) throw( ParseError ); - QVector< SessionItem > parseSessionSongItem( QXmlStreamReader& xml, const QString& type ) throw( ParseError ); - -} -} - -#endif - diff --git a/3rdparty/libechonest/Playlist.cpp b/3rdparty/libechonest/Playlist.cpp deleted file mode 100644 index 2f1e1e2fc..000000000 --- a/3rdparty/libechonest/Playlist.cpp +++ /dev/null @@ -1,422 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - -#include "Playlist.h" -#include "Playlist_p.h" -#include "Parsing_p.h" -#include - -Echonest::DynamicPlaylist::DynamicPlaylist() - : d( new DynamicPlaylistData ) -{ - -} - -Echonest::DynamicPlaylist::DynamicPlaylist(const Echonest::DynamicPlaylist& other) - : d( other.d ) -{ - -} - -Echonest::DynamicPlaylist::~DynamicPlaylist() -{ - -} - - -Echonest::DynamicPlaylist& Echonest::DynamicPlaylist::operator=(const Echonest::DynamicPlaylist& playlist) -{ - d = playlist.d; - return *this; -} - -QNetworkReply* Echonest::DynamicPlaylist::start(const Echonest::DynamicPlaylist::PlaylistParams& params) const -{ - // params are the same, if user passes in format parsing will throw, but it should be expected.. - return generateInternal( params, "dynamic" ); -} - -Echonest::Song Echonest::DynamicPlaylist::parseStart(QNetworkReply* reply) throw( Echonest::ParseError ) -{ - Echonest::Parser::checkForErrors( reply ); - QByteArray data = reply->readAll(); -// qDebug() << data; - QXmlStreamReader xml( data ); - - Echonest::Parser::readStatus( xml ); - d->sessionId = Echonest::Parser::parsePlaylistSessionId( xml ); - Echonest::SongList songs = Echonest::Parser::parseSongList( xml ); - if( !songs.size() == 1 ) - throw Echonest::ParseError( UnknownParseError ); - - d->currentSong = songs.front(); - - reply->deleteLater(); - return d->currentSong; -} - -QByteArray Echonest::DynamicPlaylist::sessionId() const -{ - return d->sessionId; -} - -void Echonest::DynamicPlaylist::setSessionId(const QByteArray& id) -{ - d->sessionId = id; -} - -Echonest::Song Echonest::DynamicPlaylist::currentSong() const -{ - return d->currentSong; -} - -void Echonest::DynamicPlaylist::setCurrentSong(const Echonest::Song& song) -{ - d->currentSong = song; -} - -QNetworkReply* Echonest::DynamicPlaylist::fetchNextSong(int rating) const -{ - QUrl url = Echonest::baseGetQuery( "playlist", "dynamic" ); - url.addEncodedQueryItem( "session_id", d->sessionId ); - - if( rating > 0 ) - url.addEncodedQueryItem( "rating", QByteArray::number( rating ) ); - - return Echonest::Config::instance()->nam()->get( QNetworkRequest( url ) ); - -} - -QNetworkReply* Echonest::DynamicPlaylist::fetchNextSong(const DynamicControls& controls) const -{ - QUrl url = Echonest::baseGetQuery( "playlist", "dynamic" ); - url.addEncodedQueryItem( "session_id", d->sessionId ); - - DynamicControls::const_iterator iter = controls.begin(); - for( ; iter != controls.end(); ++iter ) { - QString value = iter->second; - url.addEncodedQueryItem( dynamicControlToString( iter->first ), Echonest::escapeSpacesAndPluses( value ) ); - } - - return Echonest::Config::instance()->nam()->get( QNetworkRequest( url ) ); -} - -QNetworkReply* Echonest::DynamicPlaylist::fetchSessionInfo() const -{ - QUrl url = Echonest::baseGetQuery( "playlist", "session_info" ); - url.addEncodedQueryItem( "session_id", d->sessionId ); - - return Echonest::Config::instance()->nam()->get( QNetworkRequest( url ) ); -} - - -Echonest::Song Echonest::DynamicPlaylist::parseNextSong(QNetworkReply* reply) -{ - return parseStart( reply ); -} - -Echonest::SessionInfo Echonest::DynamicPlaylist::parseSessionInfo(QNetworkReply* reply) throw( Echonest::ParseError ) -{ - Echonest::Parser::checkForErrors( reply ); - - QXmlStreamReader xml( reply->readAll() ); - - Echonest::Parser::readStatus( xml ); - - reply->deleteLater(); - return Echonest::Parser::parseSessionInfo( xml ); - -} - - -QNetworkReply* Echonest::DynamicPlaylist::staticPlaylist(const Echonest::DynamicPlaylist::PlaylistParams& params) -{ - return Echonest::DynamicPlaylist::generateInternal( params, "static" ); -} - -Echonest::SongList Echonest::DynamicPlaylist::parseStaticPlaylist(QNetworkReply* reply) throw( Echonest::ParseError ) -{ - Echonest::Parser::checkForErrors( reply ); - - QXmlStreamReader xml( reply->readAll() ); - - Echonest::Parser::readStatus( xml ); - - Echonest::SongList songs = Echonest::Parser::parseSongList( xml ); - reply->deleteLater(); - return songs; -} - -QByteArray Echonest::DynamicPlaylist::parseXSPFPlaylist(QNetworkReply* reply) throw( Echonest::ParseError ) -{ - QByteArray data = reply->readAll(); - Echonest::Parser::checkForErrors( reply ); - - reply->deleteLater(); - return data; -} - -QNetworkReply* Echonest::DynamicPlaylist::generateInternal(const Echonest::DynamicPlaylist::PlaylistParams& params, const QByteArray& type) -{ - QUrl url = Echonest::baseGetQuery( "playlist", type ); - - Echonest::DynamicPlaylist::PlaylistParams::const_iterator iter = params.constBegin(); - for( ; iter < params.constEnd(); ++iter ) { - if( iter->first == Format ) // If it's a format, we have to remove the xml format we automatically specify - url.removeEncodedQueryItem( "format" ); - - if( iter->first == Type ) { // convert type enum to string - switch( static_cast( iter->second.toInt() ) ) - { - case ArtistType: - url.addEncodedQueryItem( playlistParamToString( iter->first ), "artist" ); - break; - case ArtistRadioType: - url.addEncodedQueryItem( playlistParamToString( iter->first ), "artist-radio" ); - break; - case ArtistDescriptionType: - url.addEncodedQueryItem( playlistParamToString( iter->first ), "artist-description" ); - break; - case CatalogType: - url.addEncodedQueryItem( playlistParamToString( iter->first ), "catalog" ); - break; - case CatalogRadioType: - url.addEncodedQueryItem( playlistParamToString( iter->first ), "catalog-radio" ); - break; - case SongRadioType: - url.addEncodedQueryItem( playlistParamToString( iter->first ), "song-radio" ); - break; - } - - } else if( iter->first == Sort ) { - url.addEncodedQueryItem( playlistParamToString( iter->first ), playlistSortToString( static_cast( iter->second.toInt() ) ) ); - } else if( iter->first == Pick ) { - url.addEncodedQueryItem( playlistParamToString( iter->first ), playlistArtistPickToString( static_cast( iter->second.toInt() ) ) ); - } else if( iter->first == SongInformation ){ - Echonest::Song::addQueryInformation( url, Echonest::SongInformation( iter->second.value< Echonest::SongInformation >() ) ); - } else { - url.addEncodedQueryItem( playlistParamToString( iter->first ), Echonest::escapeSpacesAndPluses( iter->second.toString() ) ); - } - } - - qDebug() << "Creating playlist URL" << url; - return Echonest::Config::instance()->nam()->get( QNetworkRequest( url ) ); -} - - -QByteArray Echonest::DynamicPlaylist::playlistParamToString(Echonest::DynamicPlaylist::PlaylistParam param) -{ - switch( param ) - { - case Echonest::DynamicPlaylist::Type : - return "type"; - case Echonest::DynamicPlaylist::Format : - return "format"; - case Echonest::DynamicPlaylist::Pick: - return "artist_pick"; - case Echonest::DynamicPlaylist::Variety : - return "variety"; - case Echonest::DynamicPlaylist::ArtistId : - return "artist_id"; - case Echonest::DynamicPlaylist::Artist : - return "artist"; - case Echonest::DynamicPlaylist::ArtistSeedCatalog : - return "artist_seed_catalog"; - case Echonest::DynamicPlaylist::SourceCatalog : - return "seed_catalog"; - case Echonest::DynamicPlaylist::SongId : - return "song_id"; - case Echonest::DynamicPlaylist::Description : - return "description"; - case Echonest::DynamicPlaylist::Results : - return "results"; - case Echonest::DynamicPlaylist::MaxTempo : - return "max_tempo"; - case Echonest::DynamicPlaylist::MinTempo : - return "min_tempo"; - case Echonest::DynamicPlaylist::MaxDuration : - return "max_duration"; - case Echonest::DynamicPlaylist::MinDuration : - return "min_duration"; - case Echonest::DynamicPlaylist::MaxLoudness : - return "max_loudness"; - case Echonest::DynamicPlaylist::MinLoudness : - return "min_loudness"; - case Echonest::DynamicPlaylist::ArtistMaxFamiliarity : - return "artist_max_familiarity"; - case Echonest::DynamicPlaylist::ArtistMinFamiliarity : - return "artist_min_familiarity"; - case Echonest::DynamicPlaylist::MinDanceability : - return "min_danceability"; - case Echonest::DynamicPlaylist::MaxDanceability : - return "max_danceability"; - case Echonest::DynamicPlaylist::MinEnergy : - return "min_energy"; - case Echonest::DynamicPlaylist::MaxEnergy : - return "max_energy"; - case Echonest::DynamicPlaylist::ArtistMaxHotttnesss : - return "artist_max_hotttnesss"; - case Echonest::DynamicPlaylist::ArtistMinHotttnesss : - return "artist_min_hotttnesss"; - case Echonest::DynamicPlaylist::SongMaxHotttnesss : - return "song_max_hotttnesss"; - case Echonest::DynamicPlaylist::SongMinHotttnesss : - return "song_min_hotttnesss"; - case Echonest::DynamicPlaylist::ArtistMinLongitude : - return "min_longitude"; - case Echonest::DynamicPlaylist::ArtistMaxLongitude : - return "max_longitude"; - case Echonest::DynamicPlaylist::ArtistMinLatitude : - return "min_latitude"; - case Echonest::DynamicPlaylist::ArtistMaxLatitude : - return "max_latitude"; - case Echonest::DynamicPlaylist::Mode : - return "mode"; - case Echonest::DynamicPlaylist::Key : - return "key"; - case Echonest::DynamicPlaylist::SongInformation: - return "bucket"; - case Echonest::DynamicPlaylist::Sort : - return "sort"; - case Echonest::DynamicPlaylist::Limit : - return "limit"; - case Echonest::DynamicPlaylist::Audio : - return "audio"; - case Echonest::DynamicPlaylist::DMCA : - return "dmca"; - case Echonest::DynamicPlaylist::ChainXSPF : - return "chain_xspf"; - case Echonest::DynamicPlaylist::Mood : - return "mood"; - case Echonest::DynamicPlaylist::Style : - return "style"; - case Echonest::DynamicPlaylist::Adventurousness : - return "adventurousness"; - } - return QByteArray(); -} - -QByteArray Echonest::DynamicPlaylist::playlistArtistPickToString(Echonest::DynamicPlaylist::ArtistPick pick) -{ - switch( pick ) - { - case PickSongHotttnesssAscending: - return "song_hotttnesss-asc"; - case PickTempoAscending: - return "tempo-asc"; - case PickDurationAscending: - return "duration-asc"; - case PickLoudnessAscending: - return "loudness-asc"; - case PickModeAscending: - return "mode-asc"; - case PickKeyAscending: - return "key-asc"; - case PickSongHotttnesssDescending: - return "song_hotttnesss-desc"; - case PickTempoDescending: - return "tempo-desc"; - case PickDurationDescending: - return "duration-desc"; - case PickLoudnessDescending: - return "loudness-desc"; - case PickModeDescending: - return "mode-desc"; - case PickKeyDescending: - return "key-desc"; - } - return QByteArray(); -} - -QByteArray Echonest::DynamicPlaylist::playlistSortToString(Echonest::DynamicPlaylist::SortingType sorting) -{ - switch( sorting ) - { - case SortTempoAscending: - return "tempo-asc"; - case SortTempoDescending: - return "tempo-desc"; - case SortDurationAscending: - return "duration-asc"; - case SortDurationDescending: - return "duration-desc"; - case SortLoudnessAscending: - return "loudness-asc"; - case SortLoudnessDescending: - return "loudness-desc"; - case SortArtistFamiliarityAscending: - return "artist_familiarity-asc"; - case SortArtistFamiliarityDescending: - return "artist_familiarity-desc"; - case SortArtistHotttnessAscending: - return "artist_hotttnesss-asc"; - case SortArtistHotttnessDescending: - return "artist_hotttnesss-desc"; - case SortSongHotttnesssAscending: - return "song_hotttnesss-asc"; - case SortSongHotttnesssDescending: - return "song_hotttnesss-desc"; - case SortLatitudeAscending: - return "latitude-asc"; - case SortLatitudeDescending: - return "latitude-desc"; - case SortLongitudeAscending: - return "longitude-asc"; - case SortLongitudeDescending: - return "longitude-desc"; - case SortModeAscending: - return "mode-asc"; - case SortModeDescending: - return "mode-desc"; - case SortKeyAscending: - return "key-asc"; - case SortKeyDescending: - return "key-desc"; - case SortEnergyAscending: - return "energy-asc"; - case SortEnergyDescending: - return "energy-desc"; - case SortDanceabilityAscending: - return "danceability-asc"; - case SortDanceabilityDescending: - return "danceability-desc"; - } - return QByteArray(); -} - -QByteArray Echonest::DynamicPlaylist::dynamicControlToString(Echonest::DynamicPlaylist::DynamicControlItem control) -{ - switch( control ) - { - case Steer: - return "steer"; - case SteerDescription: - return "steer_description"; - case Rating: - return "rating"; - case Ban: - return "ban"; - default: - return ""; - } -} - - -QDebug Echonest::operator<<(QDebug d, const Echonest::DynamicPlaylist& playlist) -{ - d << QString::fromLatin1( "DynamicPlaylist(%1, %2)" ).arg( QLatin1String( playlist.sessionId() ), playlist.currentSong().toString() ); - return d.maybeSpace(); -} diff --git a/3rdparty/libechonest/Playlist.h b/3rdparty/libechonest/Playlist.h deleted file mode 100644 index a613cdb7e..000000000 --- a/3rdparty/libechonest/Playlist.h +++ /dev/null @@ -1,280 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - - -#ifndef ECHONEST_PLAYLIST_H -#define ECHONEST_PLAYLIST_H - -#include "echonest_export.h" -#include "Song.h" - -#include -#include -#include "Artist.h" -#include -#include "Catalog.h" - -class QNetworkReply; -class DynamicPlaylistData; - -namespace Echonest{ - - typedef struct { - qreal served_time; - QByteArray artist_id; - QByteArray id; - QString artist_name; - QString title; - int rating; - } SessionItem; - - typedef struct { - TermList terms; - SongList seed_songs; -// description .. what data is in here? - Artists banned_artists; - QVector< QString > rules; - QByteArray session_id; - Artists seeds; - QVector< SessionItem > skipped_songs; - QVector< SessionItem > banned_songs; - QString playlist_type; - Catalogs seed_catalogs; - QVector< SessionItem > rated_songs; - QVector< SessionItem > history; - } SessionInfo; - - /** - * This encapsulates an Echo Nest dynamic playlist. It contains a playlist ID and - * the current song, and can fetch the next song. - * - * See http://developer.echonest.com/docs/v4/playlist.html#dynamic - * for more information - */ - class ECHONEST_EXPORT DynamicPlaylist - { - public: - /** - * The types of playlist that can be generated. Artist plays songs for the given artist, - * ArtistRadio takes into account similar artists, and ArtistDescription plays songs matching - * the given description. - */ - enum ArtistTypeEnum { - ArtistType, - ArtistRadioType, - ArtistDescriptionType, - CatalogType, - CatalogRadioType, - SongRadioType - }; - - /** - * Different ways to sort a generated playlist - */ - enum SortingType { - SortTempoAscending, - SortTempoDescending, - SortDurationAscending, - SortDurationDescending, - SortArtistFamiliarityAscending, - SortArtistFamiliarityDescending, - SortArtistHotttnessAscending, - SortArtistHotttnessDescending, - SortSongHotttnesssAscending, - SortSongHotttnesssDescending, - SortLatitudeAscending, - SortLatitudeDescending, - SortLongitudeAscending, - SortLongitudeDescending, - SortModeAscending, - SortModeDescending, - SortKeyAscending, - SortKeyDescending, - SortLoudnessAscending, - SortLoudnessDescending, - SortEnergyAscending, - SortEnergyDescending, - SortDanceabilityAscending, - SortDanceabilityDescending - }; - - /** - * Different ways of picking artists in Artist radios. - */ - enum ArtistPick { - PickSongHotttnesssAscending, - PickTempoAscending, - PickDurationAscending, - PickLoudnessAscending, - PickModeAscending, - PickKeyAscending, - PickSongHotttnesssDescending, - PickTempoDescending, - PickDurationDescending, - PickLoudnessDescending, - PickModeDescending, - PickKeyDescending - }; - - /** - * The various parameters that can be passed to the playlist building - * functions. - */ - enum PlaylistParam { - Type, /// The type of playlist to generate. Value is the DynamicPlaylist::ArtistTypeEnum enum - Format, /// Either xml (default) or xspf. If the result is xspf, the raw xspf playlist is returned, else the xml is parsed and exposed programmatically. If using XSPF, you must specify a catalog, the tracks bucket, and limit = true - Pick, /// How the artists are picked for each artist in ArtistType playlists. Value is Playlist::ArtistPick enum value. - Variety, /// 0 < variety < 1 The maximum variety of artists to be represented in the playlist. A higher number will allow for more variety in the artists. - ArtistId, /// ID(s) of seed artist(s) for the playlist - Artist, /// Artist names of seeds for playlist - ArtistSeedCatalog, /// ID of seed artist catalog for the playlist - SourceCatalog, /// ID of catalog (artist or song) for catalog type playlists - SongId, /// IDs of seed songs for the playlist - Description, /// Textual description for sort of songs that can be included in the playlist - Results, /// 0-100, how many sonsg to include in the playlist, default 15 - MaxTempo, /// 0.0 < tempo < 500.0 (BPM) The maximum tempo for any included songs - MinTempo, /// 0.0 < tempo < 500.0 (BPM) the minimum tempo for any included songs - MaxDuration, /// 0.0 < duration < 3600.0 (seconds) the maximum duration of any song on the playlist - MinDuration, /// 0.0 < duration < 3600.0 (seconds) the minimum duration of any song on the playlist - MaxLoudness, /// -100.0 < loudness < 100.0 (dB) the maximum loudness of any song on the playlist - MinLoudness, /// -100.0 < loudness < 100.0 (dB) the minimum loudness of any song on the playlist - MinDanceability, /// 0 < danceability < 1 a measure of the minimum danceability of the song - MaxDanceability, /// 0 < danceability < 1 a measure of the maximum danceability of the song - MinEnergy, /// 0 < danceability < 1 a measure of the maximum energy of the song - MaxEnergy, /// 0 < danceability < 1 a measure of the maximum energy of the song - ArtistMaxFamiliarity, /// 0.0 < familiarity < 1.0 the maximum artist familiarity for songs in the playlist - ArtistMinFamiliarity, /// 0.0 < familiarity < 1.0 the minimum artist familiarity for songs in the playlist - ArtistMaxHotttnesss, /// 0.0 < hotttnesss < 1.0 the maximum hotttnesss for artists in the playlist - ArtistMinHotttnesss, /// 0.0 < hotttnesss < 1.0 the maximum hotttnesss for artists in the playlist - SongMaxHotttnesss, /// 0.0 < hotttnesss < 1.0 the maximum hotttnesss for songs in the playlist - SongMinHotttnesss, /// 0.0 < hotttnesss < 1.0 the maximum hotttnesss for songs in the playlist - ArtistMinLongitude, /// -180.0 < longitude < 180.0 the minimum longitude for the location of artists in the playlist - ArtistMaxLongitude, /// -180.0 < longitude < 180.0 the maximum longitude for the location of artists in the playlist - ArtistMinLatitude, /// -90.0 < latitude < 90.0 the minimum latitude for the location of artists in the playlist - ArtistMaxLatitude, /// -90.0 < latitude < 90.0 the maximum latitude for the location of artists in the playlist - Mode, /// (minor, major) 0, 1 the mode of songs in the playlist - Key, /// (c, c-sharp, d, e-flat, e, f, f-sharp, g, a-flat, a, b-flat, b) 0 - 11 the key of songs in the playlist - SongInformation, /// what sort of song information should be returned. Should be an Echonest::SongInformation object - Sort, /// SortingType enum, the type of sorting to use, - Limit, /// true, false if true songs will be limited to those that appear in the catalog specified by the id: bucket - Audio, /// true, false, if true songs will be limited to those that have associated audio - DMCA, /// true, false Only valid for dynamic playlists. Sets if playlist will follow DMCA rules (see web api doc for details) - ChainXSPF, /// true, false If true, returns an xspf for this dynamic playlist with 2 items. The second item will be a link to the API call for the next track in the chain. Please note that this sidesteps libechonest's handling of the tracks. - Mood, /// A mood to limit this playlist to, for example "happy" or "sad". Multiples of this param are okay. See the method Artist::listTerms for details on what moods are currently available - Style, /// A style to limit this playlist to, for example "happy" or "sad". Multiples of this param are okay. See the method Artist::listTerms for details on what styles are currently available - Adventurousness - }; - - typedef QPair< PlaylistParam, QVariant > PlaylistParamData; - typedef QVector< PlaylistParamData > PlaylistParams; - - /** - * The various controls for a dynamic playlist. - * - * Please see The Echo Nest API documentation for more information - */ - enum DynamicControlItem { - Steer = 0, - SteerDescription, - Rating, - Ban - }; - typedef QPair< DynamicControlItem, QString > DynamicControl; - typedef QVector< DynamicControl > DynamicControls; - - DynamicPlaylist(); - virtual ~DynamicPlaylist(); - DynamicPlaylist( const DynamicPlaylist& other ); - DynamicPlaylist& operator=( const DynamicPlaylist& playlist ); - - /** - * Start a dynamic playlist with the given parameters. - * Once the QNetworkReply has finished, pass it to parseStart() - * and the inital song will be populated and returned. The sessionId(), currentSong(), - * and fetchNextSong() methods will then be useful. - */ - QNetworkReply* start( const PlaylistParams& params ) const; - Song parseStart( QNetworkReply* ) throw( ParseError ); - - /** - * The session id of this dynamic playlist. If the playlist has ended, or has not been started, - * the result is empty. - * - */ - QByteArray sessionId() const; - void setSessionId( const QByteArray& id ); - - /** - * The current song of this dynamic playlist. Once this song has been played, - * or whenever is desired, call fetchNextSong() to get the next song. - */ - Song currentSong() const; - void setCurrentSong( const Song& song ); - - /** - * Queries The Echo Nest for the next playable song in this - * dynamic playlist. - * - * Once the query has emitted the finished() signal, pass it to parseNextSong(), which will - * return the new song to play. It will also set the current song to the newly parsed song. - * - * If the playlist has no more songs, the returned song object will be have no name nor id. - * - * @param rating The rating for the song that was just played. Ranges from 1 (lowest) to 5 (highest) - * @param controls The controls to apply when fetching the next track. - * - */ - QNetworkReply* fetchNextSong( int rating = -1 ) const; - QNetworkReply* fetchNextSong( const DynamicControls& controls ) const; - Song parseNextSong( QNetworkReply* reply ); - - /** - * Returns a description of this dynamic playlist session - */ - QNetworkReply* fetchSessionInfo() const; - SessionInfo parseSessionInfo( QNetworkReply* reply ) throw( ParseError ); - - /** - * Generate a static playlist, according to the desired criteria. Use parseXSPFPlaylist if - * you pass format=xspf to \c staticPlaylist(). - */ - static QNetworkReply* staticPlaylist( const PlaylistParams& params ); - static SongList parseStaticPlaylist( QNetworkReply* reply ) throw( ParseError ); - - /** - * Parse an xspf playlist. Returns the full xspf content with no modifications. - */ - static QByteArray parseXSPFPlaylist( QNetworkReply* reply ) throw( ParseError ); - - private: - static QByteArray playlistParamToString( PlaylistParam param ); - static QNetworkReply* generateInternal( const PlaylistParams& params, const QByteArray& type ); - static QByteArray playlistSortToString(SortingType sorting); - static QByteArray playlistArtistPickToString(ArtistPick pick); - static QByteArray dynamicControlToString(DynamicControlItem control); - - QSharedDataPointer d; - }; - - ECHONEST_EXPORT QDebug operator<<(QDebug d, const Echonest::DynamicPlaylist& playlist); - - -} // namespace - - -Q_DECLARE_METATYPE( Echonest::DynamicPlaylist ) - -#endif diff --git a/3rdparty/libechonest/Playlist_p.h b/3rdparty/libechonest/Playlist_p.h deleted file mode 100644 index 576b591c5..000000000 --- a/3rdparty/libechonest/Playlist_p.h +++ /dev/null @@ -1,34 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - -#include "Song.h" -#include -#include - -class DynamicPlaylistData : public QSharedData -{ -public: - DynamicPlaylistData() {} - DynamicPlaylistData(const DynamicPlaylistData& other) : QSharedData(other) - { - sessionId = other.sessionId; - currentSong = other.currentSong; - } - - QByteArray sessionId; - Echonest::Song currentSong; -}; - diff --git a/3rdparty/libechonest/Song.cpp b/3rdparty/libechonest/Song.cpp deleted file mode 100644 index 6f2f05b67..000000000 --- a/3rdparty/libechonest/Song.cpp +++ /dev/null @@ -1,432 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - -#include "Song.h" - -#include "Config.h" -#include "Song_p.h" -#include "AudioSummary.h" - -#include -#include - -#include -#include "Parsing_p.h" -#include -#include -#include - -Echonest::Song::Song() - : d( new SongData ) -{} - -Echonest::Song::Song(const QByteArray& id, const QString& title, const QByteArray& artistId, const QString& artistName) - :d( new SongData ) -{ - d->id = id; - d->title = title; - d->artistId = artistId; - d->artistName = artistName; -} - -Echonest::Song::Song(const QByteArray& id) -:d( new SongData ) -{ - d->id = id; -} - -Echonest::Song::Song(const Echonest::Song& other) - : d( other.d ) -{ - -} - - -Echonest::Song::~Song() -{ - -} - -Echonest::Song& Echonest::Song::operator=(const Echonest::Song& song) -{ - d = song.d; - return *this; -} - - - -QByteArray Echonest::Song::id() const -{ - return d->id; -} - -void Echonest::Song::setId(const QByteArray& id) -{ - d->id = id; -} - - -QString Echonest::Song::title() const -{ - return d->title; -} - -void Echonest::Song::setTitle(const QString& title) -{ - d->title = title; -} - -QByteArray Echonest::Song::artistId() const -{ - return d->artistId; -} - -void Echonest::Song::setArtistId(const QByteArray& artistId) -{ - d->artistId = artistId; -} - -QString Echonest::Song::artistName() const -{ - return d->artistName; -} - -void Echonest::Song::setArtistName(const QString& artistName) -{ - d->artistName = artistName; -} - -QString Echonest::Song::release() const -{ - return d->release; -} - -void Echonest::Song::setRelease(const QString& release) -{ - d->release = release; -} - - -QVector< Echonest::Track > Echonest::Song::tracks() const -{ - return d->tracks; -} - -void Echonest::Song::setTracks(const QVector< Echonest::Track >& tracks) -{ - d->tracks = tracks; -} - -qreal Echonest::Song::hotttnesss() const -{ - return d->hotttnesss; -} - -void Echonest::Song::setHotttnesss(qreal hotttnesss) -{ - d->hotttnesss = hotttnesss; -} - -qreal Echonest::Song::artistHotttnesss() const -{ - return d->artistHotttnesss; -} - -void Echonest::Song::setArtistHotttnesss(qreal artistHotttnesss) -{ - d->artistHotttnesss = artistHotttnesss; -} - -Echonest::AudioSummary Echonest::Song::audioSummary() const -{ - return d->audioSummary; -} - -void Echonest::Song::setAudioSummary(const Echonest::AudioSummary& summary) -{ - d->audioSummary = summary; -} - -qreal Echonest::Song::artistFamiliarity() const -{ - return d->artistFamiliarity; -} - -void Echonest::Song::setArtistFamiliarity(qreal artistFamiliarity) -{ - d->artistFamiliarity = artistFamiliarity; -} - -Echonest::ArtistLocation Echonest::Song::artistLocation() const -{ - return d->artistLocation; -} - -void Echonest::Song::setArtistLocation(const Echonest::ArtistLocation& artistLocation) -{ - d->artistLocation = artistLocation; -} - -QNetworkReply* Echonest::Song::fetchInformation( Echonest::SongInformation information ) const -{ - QUrl url = Echonest::baseGetQuery( "song", "profile" ); - url.addEncodedQueryItem( "id", d->id ); - addQueryInformation( url, information ); - - qDebug() << "Creating fetchInformation URL" << url; - return Echonest::Config::instance()->nam()->get( QNetworkRequest( url ) ); -} - -QNetworkReply* Echonest::Song::search( const Echonest::Song::SearchParams& params, Echonest::SongInformation information ) -{ - QUrl url = Echonest::baseGetQuery( "song", "search" ); - addQueryInformation( url, information ); - - SearchParams::const_iterator iter = params.constBegin(); - for( ; iter < params.constEnd(); ++iter ) - url.addEncodedQueryItem( searchParamToString( iter->first ), Echonest::escapeSpacesAndPluses( iter->second.toString() ) ); - - qDebug() << "Creating search URL" << url; - return Echonest::Config::instance()->nam()->get( QNetworkRequest( url ) ); -} - -QNetworkReply* Echonest::Song::identify( const Echonest::Song::IdentifyParams& params, const Echonest::SongInformation& information ) -{ - QVariantMap query; - QVariantMap metadata; - IdentifyParams::const_iterator iter = params.constBegin(); - for( ; iter < params.constEnd(); ++iter ) { - if( iter->first == Code ) - query[ QLatin1String( identifyParamToString( iter->first ) ) ] = iter->second; - else - metadata[ QLatin1String( identifyParamToString( iter->first ) ) ] = iter->second.toString(); - } - metadata[ QLatin1String( "version" ) ] = QLatin1String( "4.12" ); - query[ QLatin1String( "metadata" ) ] = metadata; - QJson::Serializer s; - QByteArray data = s.serialize( query ); - - QUrl url = Echonest::baseGetQuery( "song", "identify" ); - addQueryInformation( url, information ); - - qDebug() << "Creating identify URL" << url; - QNetworkRequest request( url ); - - request.setHeader( QNetworkRequest::ContentTypeHeader, QLatin1String( "application/octet-stream" ) ); - // qDebug() << "Uploading local file to" << url; - return Echonest::Config::instance()->nam()->post( request, data ); -} - -Echonest::SongList Echonest::Song::parseIdentify( QNetworkReply* reply ) throw( ParseError ) -{ - Echonest::Parser::checkForErrors( reply ); - - QByteArray data = reply->readAll(); - QJson::Parser p; - QVariantMap res = p.parse( data ).toMap(); -// qDebug() << "Got data from identify call:" << data << res; - - - qDebug() << res[ QLatin1String( "response" ) ].toMap()[ QLatin1String( "songs" ) ].toList(); - if( !res.contains( QLatin1String( "response" ) ) || !res[ QLatin1String( "response" ) ].toMap().contains( QLatin1String( "songs" ) ) ) { - qDebug() << "No response or songs elemnt in json..."; - throw ParseError( UnknownParseError, QLatin1String( "Invalid json response" ) ); - } - - SongList songs; - QVariantList songsV = res[ QLatin1String( "response" ) ].toMap()[ QLatin1String( "songs" ) ].toList(); - - foreach( const QVariant& s, songsV ) { - QVariantMap sM = s.toMap(); - Echonest::Song song; - - if( sM.contains( QLatin1String( "title" ) ) ) - song.setTitle( sM[ QLatin1String( "title" ) ].toString() ); - if( sM.contains( QLatin1String( "artist_id" ) ) ) - song.setArtistId( sM[ QLatin1String( "artist_id" ) ].toByteArray() ); - if( sM.contains( QLatin1String( "artist_name" ) ) ) - song.setArtistName( sM[ QLatin1String( "artist_name" ) ].toString() ); - if( sM.contains( QLatin1String( "id" ) ) ) - song.setId( sM[ QLatin1String( "id" ) ].toByteArray() ); - - songs.append( song ); - } - - reply->deleteLater(); - return songs; -} - - - -void Echonest::Song::parseInformation( QNetworkReply* reply ) throw( ParseError ) -{ - Echonest::Parser::checkForErrors( reply ); - - QXmlStreamReader xml( reply->readAll() ); - - Echonest::Parser::readStatus( xml ); - // we'll just take the new data. it is given as a list even though it can only have 1 song as we specify the song id - QVector< Echonest::Song > songs = Echonest::Parser::parseSongList( xml ); - if( !songs.size() == 1 ) { // no data for this song. returned empty. - return; - } - // copy any non-default values - Echonest::Song newSong = songs.at( 0 ); - if( newSong.hotttnesss() >= 0 ) - setHotttnesss( newSong.hotttnesss() ); - if( newSong.artistHotttnesss() >= 0 ) - setArtistHotttnesss( newSong.artistHotttnesss() ); - if( newSong.artistFamiliarity() >= 0 ) - setArtistFamiliarity( newSong.artistFamiliarity() ); - if( !newSong.artistLocation().location.isEmpty() ) - setArtistLocation( newSong.artistLocation() ); - reply->deleteLater(); - -} - -QVector< Echonest::Song > Echonest::Song::parseSearch( QNetworkReply* reply ) throw( ParseError ) -{ - Echonest::Parser::checkForErrors( reply ); - - QXmlStreamReader xml( reply->readAll() ); - - Echonest::Parser::readStatus( xml ); - QVector songs = Echonest::Parser::parseSongList( xml ); - - reply->deleteLater(); - return songs; - -} - -QByteArray Echonest::Song::searchParamToString( Echonest::Song::SearchParam param ) -{ - switch( param ) - { - case Echonest::Song::Title: - return "title"; - case Echonest::Song::Artist: - return "artist"; - case Echonest::Song::Combined: - return "combined"; - case Echonest::Song::Description: - return "description"; - case Echonest::Song::ArtistId: - return "artist_id"; - case Echonest::Song::Start: - return "start"; - case Echonest::Song::Results: - return "results"; - case Echonest::Song::MaxTempo: - return "max_tempo"; - case Echonest::Song::MinTempo: - return "min_tempo"; - case Echonest::Song::MaxDanceability: - return "max_danceability"; - case Echonest::Song::MinDanceability: - return "min_danceability"; - case Echonest::Song::MaxComplexity: - return "max_complexity"; - case Echonest::Song::MinComplexity: - return "min_complexity"; - case Echonest::Song::MaxDuration: - return "max_duration"; - case Echonest::Song::MinDuration: - return "min_duration"; - case Echonest::Song::MaxLoudness: - return "max_loudness"; - case Echonest::Song::MinLoudness: - return "min_loudness"; - case Echonest::Song::MaxFamiliarity: - return "max_familiarity"; - case Echonest::Song::MinFamiliarity: - return "min_familiarity"; - case Echonest::Song::MaxHotttnesss: - return "max_hotttnesss"; - case Echonest::Song::MinHotttnesss: - return "min_hotttnesss"; - case Echonest::Song::MaxLongitude: - return "max_longitude"; - case Echonest::Song::MinLongitude: - return "min_longitude"; - case Echonest::Song::MinEnergy: - return "min_energy"; - case Echonest::Song::MaxEnergy: - return "max_energy"; - case Echonest::Song::Mode: - return "mode"; - case Echonest::Song::Key: - return "key"; - case Echonest::Song::Sort: - return "sort"; - } - return QByteArray(); -} - - -QByteArray Echonest::Song::identifyParamToString( Echonest::Song::IdentifyParam param ) -{ - switch( param ) - { - case Echonest::Song::Code: - return "code"; - case Echonest::Song::IdentifyArtist: - return "artist"; - case Echonest::Song::IdentifyDuration: - return "duration"; - case Echonest::Song::IdentifyGenre: - return "genre"; - case Echonest::Song::IdentifyRelease: - return "release"; - case Echonest::Song::IdentifyTitle: - return "title"; - } - return QByteArray(); -} - -void Echonest::Song::addQueryInformation(QUrl& url, Echonest::SongInformation information) -{ - if( information.flags().testFlag( Echonest::SongInformation::AudioSummaryInformation ) ) - url.addEncodedQueryItem( "bucket", "audio_summary" ); - if( information.flags().testFlag( Echonest::SongInformation::Tracks ) ) - url.addEncodedQueryItem( "bucket", "tracks" ); - if( information.flags().testFlag( Echonest::SongInformation::Hotttnesss ) ) - url.addEncodedQueryItem( "bucket", "song_hotttnesss" ); - if( information.flags().testFlag( Echonest::SongInformation::ArtistHotttnesss ) ) - url.addEncodedQueryItem( "bucket", "artist_hotttnesss" ); - if( information.flags().testFlag( Echonest::SongInformation::ArtistFamiliarity ) ) - url.addEncodedQueryItem( "bucket", "artist_familiarity" ); - if( information.flags().testFlag( Echonest::SongInformation::ArtistLocation ) ) - url.addEncodedQueryItem( "bucket", "artist_location" ); - - if( !information.idSpaces().isEmpty() ) { - foreach( const QString& idSpace, information.idSpaces() ) - url.addEncodedQueryItem( "bucket", "id:" + idSpace.toUtf8() ); - } -} - - -QString Echonest::Song::toString() const -{ - return QString::fromLatin1( "Song(%1, %2, %3, %4)" ).arg( title() ).arg( artistName() ).arg( QString::fromLatin1( id() ) ).arg( QString::fromLatin1( artistId() ) ); -} - - -QDebug Echonest::operator<<(QDebug d, const Echonest::Song& song) -{ - d << song.toString(); - return d.maybeSpace(); -} - diff --git a/3rdparty/libechonest/Song.h b/3rdparty/libechonest/Song.h deleted file mode 100644 index 1747a7b66..000000000 --- a/3rdparty/libechonest/Song.h +++ /dev/null @@ -1,243 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - - -#ifndef ECHONEST_SONG_H -#define ECHONEST_SONG_H - -#include "echonest_export.h" -#include "Track.h" -#include "TypeInformation.h" - -#include -#include -#include -#include -#include -#include "Config.h" - -class QNetworkReply; -class SongData; - -namespace Echonest{ - -class DynamicPlaylist; // forward declare for friend declaration -class Catalog; -class AudioSummary; - -/** - * This encapsulates an Echo Nest song---use it if you wish to get information about a song, - * search for a song, etc. - * - * This class is implicitly shared. - */ -class ECHONEST_EXPORT Song -{ - -public: - - enum SearchParam { - Title, - Artist, - Combined, - Description, - ArtistId, - Start, - Results, - MaxTempo, - MinTempo, - MaxDanceability, - MinDanceability, - MaxComplexity, - MinComplexity, - MaxDuration, - MinDuration, - MaxLoudness, - MinLoudness, - MaxFamiliarity, - MinFamiliarity, - MaxHotttnesss, - MinHotttnesss, - MaxLongitude, - MinLongitude, - MaxEnergy, - MinEnergy, - Mode, - Key, - Sort - }; - typedef QPair< Echonest::Song::SearchParam, QVariant > SearchParamData; - typedef QVector< SearchParamData > SearchParams; - - enum IdentifyParam { - Code, - IdentifyArtist, - IdentifyTitle, - IdentifyRelease, - IdentifyDuration, - IdentifyGenre - }; - typedef QPair< Echonest::Song::IdentifyParam, QVariant > IdentifyParamData; - typedef QVector< IdentifyParamData > IdentifyParams; - - Song(); - Song( const QByteArray& id, const QString& title, const QByteArray& artistId, const QString& artistName ); - Song( const QByteArray& id ); - Song( const Song& other ); - Song& operator=(const Song& song); - virtual ~Song(); - - /** - * The following pieces of data are present in all Song objects, and do not require - * on-demand fetching. - */ - QByteArray id() const; - void setId( const QByteArray& id ); - - QString title() const; - void setTitle( const QString& title ); - - QString artistName() const; - void setArtistName( const QString& artistName ); - - QByteArray artistId() const; - void setArtistId( const QByteArray& artistId ); - - QString release() const; - void setRelease( const QString& release ); - - /** - * The following require fetching from The Echo Nest, so call - * fetchInformation() with the type of data you want first. - * - * If you ask for this information before calling parseInformation() - * with the respective data, the result is undefined. - */ - - /** - * The full audio summary and analysis of this song. - * - * NOTE: This will return a copy of the AudioSummary object, which - * is implicitly shared. If you make modifications to the returned - * summary, for example by calling parseFullAnalysis(), it will detach - * and you will have to call setAudioSummary() to save the changes back - * to this Song object. - */ - AudioSummary audioSummary() const; - void setAudioSummary( const AudioSummary& summary ); - - /** - * The associated Track objects with acoustic track information - */ - QVector< Track > tracks() const; - void setTracks( const QVector< Track >& tracks ); - - /** - * The "hotttnesss" metric of this song. - */ - qreal hotttnesss() const; - void setHotttnesss( qreal hotttnesss ); - - /** - * The "hotttnesss" metric of this song's artist. - */ - qreal artistHotttnesss() const; - void setArtistHotttnesss( qreal artistHotttnesss ); - - /** - * The familiarity metric of this song's artist. - */ - qreal artistFamiliarity() const; - void setArtistFamiliarity( qreal artistFamiliarity ); - - /** - * The location of this artist. - */ - ArtistLocation artistLocation() const; - void setArtistLocation( const ArtistLocation& artistLocation ); - - /** - * This fetches the data from The Echo Nest for the requested data, so it - * returns a QNetworkReply*. When the finished() signal is emitted - * from the QNetworkReply object call parseInformation() to save the - * data back to this Song object. - * - */ - QNetworkReply* fetchInformation( SongInformation information = SongInformation() ) const; - - /** - * Search for a song from The Echo Nest with the given search parameters. See - * http://developer.echonest.com/docs/v4/song.html#search for a description of the - * parameters and data types. - * - * The result will contain the requested information from the SongInformation flags, and - * can be extracted in the parseSearch() function. - * - */ - static QNetworkReply* search( const SearchParams& params, SongInformation information = SongInformation() ); - - /** - * Identify a song from a given Echo Nest fingerprint hash code. - * NOTE: SongInformation is currently not parsed yet. - * - */ - static QNetworkReply* identify( const IdentifyParams& params, const SongInformation& information = SongInformation() ); - - /** - * Identify a song from the Echoprint hash code, this time using the output of the 'echoprint-codegen' command-line - * tool - */ -// static QNetworkReply* identify( const QByteArray& jsonData ); - - /** - * Parses the reply of the identify call and returns a list of songs found. - * - */ - static QVector< Song > parseIdentify( QNetworkReply* ) throw( ParseError ); - - /** - * Parse the result of the fetchInformation() call. - * For each requested SongInformationFlag in the original request, the respective - * data will be saved to this Song object. - */ - void parseInformation( QNetworkReply* reply ) throw( ParseError ); - - /** - * Parse the result of the search() call. - */ - static QVector parseSearch( QNetworkReply* reply ) throw( ParseError ); - - QString toString() const; - - friend class DynamicPlaylist; - friend class Catalog; // for access to searchParamToString -private: - static QByteArray searchParamToString( SearchParam param ); - static QByteArray identifyParamToString( IdentifyParam param ); - static void addQueryInformation( QUrl& url, SongInformation information ); - - QSharedDataPointer d; -}; - -typedef QVector< Song > SongList; - -ECHONEST_EXPORT QDebug operator<<(QDebug d, const Song &song); - -} // namespace - -Q_DECLARE_METATYPE( Echonest::Song ) - -#endif diff --git a/3rdparty/libechonest/Song_p.h b/3rdparty/libechonest/Song_p.h deleted file mode 100644 index 0a27897a3..000000000 --- a/3rdparty/libechonest/Song_p.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - -#ifndef ECHONEST_SONG_P_H -#define ECHONEST_SONG_P_H - -#include "Track.h" -#include "AudioSummary.h" - -#include -#include -#include - - -class SongData : public QSharedData -{ -public: - SongData() : hotttnesss( -1 ), artistHotttnesss( -1 ), artistFamiliarity( -1 ) { artistLocation.latitude = -1; artistLocation.longitude = -1; } - - SongData(const SongData& other) : QSharedData( other ) - { - id = other.id; - title = other.title; - artistName = other.artistName; - artistId = other.artistId; - - audioSummary = other.audioSummary; - tracks = other.tracks; - hotttnesss = other.hotttnesss; - artistHotttnesss = other.artistHotttnesss; - artistFamiliarity = other.artistFamiliarity; - artistLocation = other.artistLocation; - } - - ~SongData() {} - - QByteArray id; - QString title; - QString artistName; - QByteArray artistId; - QString release; - - // The rest are optional that require manual fetching to populate - Echonest::AudioSummary audioSummary; - QVector tracks; - qreal hotttnesss; - qreal artistHotttnesss; - qreal artistFamiliarity; - Echonest::ArtistLocation artistLocation; - - -}; - -#endif diff --git a/3rdparty/libechonest/Track.cpp b/3rdparty/libechonest/Track.cpp deleted file mode 100644 index 1db58f3ed..000000000 --- a/3rdparty/libechonest/Track.cpp +++ /dev/null @@ -1,310 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - -#include "Track.h" - -#include "Track_p.h" -#include -#include "Config.h" -#include "Song.h" -#include -#include "Parsing_p.h" - -Echonest::Track::Track() - : d( new TrackData ) -{ -} - -Echonest::Track::Track(const Echonest::Track& other) - : d( other.d ) -{} - -Echonest::Track::Track(const QByteArray& id) -: d( new TrackData ) -{ - d->id = id; -} - - -Echonest::Track::~Track() -{ -} - - -Echonest::Track& Echonest::Track::operator=(const Echonest::Track& track) -{ - d = track.d; - return *this; -} - - -QString Echonest::Track::artist() const -{ - return d->artist; -} - -void Echonest::Track::setArtist(const QString& artist) -{ - d->artist = artist; -} - - -QString Echonest::Track::title() const -{ - return d->title; -} - -void Echonest::Track::setTitle(const QString& title) -{ - d->title = title; -} - -QByteArray Echonest::Track::id() const -{ - return d->id; -} - -void Echonest::Track::setId(const QByteArray& id) -{ - d->id = id; -} - -QByteArray Echonest::Track::md5() const -{ - return d->md5; -} - -void Echonest::Track::setMD5(const QByteArray& md5) -{ - d->md5 = md5; -} - - -QString Echonest::Track::release() const -{ - return d->release; -} - -void Echonest::Track::setRelease(const QString& release) -{ - d->release = release; -} - -QString Echonest::Track::analyzerVersion() const -{ - return d->analyzer_version; -} - -void Echonest::Track::setAnalyzerVersion(const QString& analyzerVersion) -{ - d->analyzer_version = analyzerVersion; -} - -int Echonest::Track::bitrate() const -{ - return d->bitrate; -} - -void Echonest::Track::setBitrate(int bitrate) -{ - d->bitrate = bitrate; -} - -int Echonest::Track::samplerate() const -{ - return d->samplerate; -} - -void Echonest::Track::setSamplerate(int samplerate) -{ - d->samplerate = samplerate; -} - -QByteArray Echonest::Track::audioMD5() const -{ - return d->audio_md5; -} - -void Echonest::Track::setAudioMD5(const QByteArray& md5) -{ - d->audio_md5 = md5; -} - -Echonest::Analysis::AnalysisStatus Echonest::Track::status() const -{ - return Echonest::statusToEnum( d->status ); -} - -void Echonest::Track::setStatus( Echonest::Analysis::AnalysisStatus status ) -{ - d->status = Echonest::statusToString( status ); -} - -Echonest::AudioSummary Echonest::Track::audioSummary() const -{ - return d->audio_summary; -} - -void Echonest::Track::setAudioSummary( const Echonest::AudioSummary& summary ) -{ - d->audio_summary = summary; -} - -QString Echonest::Track::catalog() const -{ - return d->catalog; -} - -void Echonest::Track::setCatalog(const QString& catalog) -{ - d->catalog = catalog; -} - -QByteArray Echonest::Track::foreignId() const -{ - return d->foreign_id; -} - -void Echonest::Track::setForeignId(const QByteArray& id) -{ - d->foreign_id = id; -} - -QUrl Echonest::Track::previewUrl() const -{ - return d->preview_url; -} - -void Echonest::Track::setPreviewUrl(const QUrl& preview) -{ - d->preview_url = preview; -} - -QUrl Echonest::Track::releaseImage() const -{ - return d->release_image; -} - -void Echonest::Track::setReleaseImage(const QUrl& imgUrl) -{ - d->release_image = imgUrl; -} - -Echonest::Song Echonest::Track::song() const -{ - return d->song; -} - -void Echonest::Track::setSong(const Echonest::Song& song) -{ - d->song = song; -} - -QNetworkReply* Echonest::Track::profileFromTrackId( const QByteArray& id ) -{ - QUrl url = Echonest::baseGetQuery( "track", "profile" ); - url.addEncodedQueryItem( "id", id ); - url.addEncodedQueryItem( "bucket", "audio_summary" ); - - - qDebug() << "Creating profileFromTrackId URL" << url; - return Echonest::Config::instance()->nam()->get( QNetworkRequest( url ) ); -} - -QNetworkReply* Echonest::Track::profileFromMD5( const QByteArray& md5 ) -{ - QUrl url = Echonest::baseGetQuery( "track", "profile" ); - url.addEncodedQueryItem( "md5", md5 ); - url.addEncodedQueryItem( "bucket", "audio_summary" ); - - qDebug() << "Creating profileFromMD5 URL" << url; - return Echonest::Config::instance()->nam()->get( QNetworkRequest( url ) ); -} - -QNetworkReply* Echonest::Track::uploadLocalFile( const QUrl& localFile, const QByteArray& data, bool waitForResult ) -{ - QUrl url = Echonest::baseGetQuery( "track", "upload" ); - QFileInfo info( localFile.path() ); - url.addQueryItem( QLatin1String( "filetype" ), info.suffix() ); - url.addEncodedQueryItem( "bucket", "audio_summary" ); - url.addEncodedQueryItem( "wait", ( waitForResult ? "true" : "false" ) ); - QNetworkRequest request( url ); - - request.setHeader( QNetworkRequest::ContentTypeHeader, QLatin1String( "application/octet-stream" ) ); -// qDebug() << "Uploading local file to" << url; - return Echonest::Config::instance()->nam()->post( request, data ); -} - -QNetworkReply* Echonest::Track::uploadURL( const QUrl& remoteURL, bool waitForResult ) -{ - QUrl url = Echonest::baseGetQuery( "track", "upload" ); - url.addEncodedQueryItem( "url", remoteURL.toEncoded() ); - url.addEncodedQueryItem( "bucket", "audio_summary" ); - url.addEncodedQueryItem( "wait", ( waitForResult ? "true" : "false" ) ); - - qDebug() << "Uploading URL:" << url; - QNetworkRequest req( url ); - req.setHeader( QNetworkRequest::ContentTypeHeader, QLatin1String( "application/x-www-form-urlencoded" ) ); - return Echonest::Config::instance()->nam()->post( req, QByteArray() ); -} - -QNetworkReply* Echonest::Track::analyzeTrackId( const QByteArray& id, bool wait ) -{ - QUrl url = Echonest::baseGetQuery( "track", "analyze" ); - url.addEncodedQueryItem( "id", id ); - url.addEncodedQueryItem( "bucket", "audio_summary" ); - url.addEncodedQueryItem( "wait", ( wait ? "true" : "false" ) ); - - qDebug() << "Creating analyzeTrackId URL" << url; - return Echonest::doPost( url ); -// return Echonest::Config::instance()->nam()->post( QNetworkRequest( url ), QByteArray() ); -} - -QNetworkReply* Echonest::Track::analyzeTrackMD5( const QByteArray& md5, bool wait ) -{ - QUrl url = Echonest::baseGetQuery( "track", "analyze" ); - url.addEncodedQueryItem( "md5", md5 ); - url.addEncodedQueryItem( "bucket", "audio_summary" ); - url.addEncodedQueryItem( "wait", ( wait ? "true" : "false" ) ); - - qDebug() << "Creating analyzeTrackMD5 URL" << url; - return Echonest::doPost( url ); -// return Echonest::Config::instance()->nam()->post( QNetworkRequest( url ), QByteArray() ); -} - -Echonest::Track Echonest::Track::parseProfile( QNetworkReply* finishedReply ) throw( Echonest::ParseError ) -{ - QByteArray data = finishedReply->readAll(); - qDebug() << data; - Echonest::Parser::checkForErrors( finishedReply ); - - QXmlStreamReader xml( data ); - - Echonest::Parser::readStatus( xml ); - Echonest::Track track = Echonest::Parser::parseTrack( xml ); - - finishedReply->deleteLater(); - return track; -} - - - -QDebug Echonest::operator<<(QDebug d, const Echonest::Track& track) -{ - d << QString::fromLatin1( "Track(%1, %2, %3, %4)" ).arg( QLatin1String( track.id() ) ).arg( track.title() ).arg( track.artist() ).arg( track.release() ); - return d.maybeSpace(); -} - diff --git a/3rdparty/libechonest/Track.h b/3rdparty/libechonest/Track.h deleted file mode 100644 index 4f49d45e9..000000000 --- a/3rdparty/libechonest/Track.h +++ /dev/null @@ -1,229 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - - -#ifndef ECHONEST_TRACK_H -#define ECHONEST_TRACK_H - -#include "AudioSummary.h" -#include "echonest_export.h" -#include "Util.h" - -#include -#include -#include -#include -#include -#include "Config.h" - -class QNetworkReply; -class TrackData; - -namespace Echonest -{ - -class Song; -/** - * Upload-based Echo Nest Track API. If you want to search The Echo Nest for songs, use the Song API. - * If you want to upload your own files and retrieve the acoustic information about them, use this Track - * class. You can also fetch acoustic information from a track if you have the Track ID or MD5 of the file. - * - * A Track encapsulates the audio analysis from The Echo Nest. - * - * This class is implicitly shared. - * - */ -class ECHONEST_EXPORT Track -{ -public: - - Track(); - explicit Track( const QByteArray& id ); - Track( const Track& other ); - Track& operator=( const Track& track ); - ~Track(); - - /** - * The track's artist. - */ - QString artist() const; - void setArtist( const QString& artist ); - - /** - * The track's title. - */ - QString title() const; - void setTitle( const QString& title ); - - /** - * The Echo Nest artist ID for this track. - */ - QByteArray id() const; - void setId( const QByteArray& id ); - - /** - * The MD5 hash of the track. - */ - QByteArray md5() const; - void setMD5( const QByteArray& md5 ); - - /** - * The album name of this track. - */ - QString release() const; - void setRelease( const QString& release ); - - /** - * The MD5 hashsum of the audio data. - */ - QByteArray audioMD5() const; - void setAudioMD5( const QByteArray& md5 ); - - /** - * The analyzer version that was used in this track's analysis. - */ - QString analyzerVersion() const; - void setAnalyzerVersion( const QString& analyzerVersion ); - - /** - * The samplerate of the track - */ - int samplerate() const; - void setSamplerate( int samplerate ); - - /** - * The bitrate of the track - */ - int bitrate() const; - void setBitrate( int ); - - /** - * If this track is fetched from a tracks bucket of a song search, the following information - * will be populated for some id spaces. - */ - - /** - * The catalog this track is from, if not a native Echo Nest track - */ - QString catalog() const; - void setCatalog( const QString& catalog ); - - /** - * The foreign id of this track, that is in the \c catalog catalog. - */ - QByteArray foreignId() const; - void setForeignId( const QByteArray& id ); - - /** - * The release image associated with this track - */ - QUrl releaseImage() const; - void setReleaseImage( const QUrl& imgUrl ); - - /** - * The preview url for this track, if it exists - */ - QUrl previewUrl() const; - void setPreviewUrl( const QUrl& preview ); - - /** - * The Echo Nest song associated with this track, if it exists - */ - Song song() const; - void setSong( const Song& song ); - - /** - * The analysis status - */ - Analysis::AnalysisStatus status() const; - void setStatus( Analysis::AnalysisStatus ); - - /** - * The full audio summary of the track. This contains information about the track's bars, - * beats, sections, and detailed segment information as well as more metadata about the song's - * acoustic properties. - * - * Information about how to interpret the results of the audio summary can be found here: - * http://developer.echonest.com/docs/v4/_static/AnalyzeDocumentation_2.2.pdf - * - * NOTE: This will return a copy of the AudioSummary object, which - * is implicitly shared. If you make modifications to the returned - * summary, for example by calling parseFullAnalysis(), it will detach - * and you will have to call setAudioSummary() to save the changes back - * to this Song object. - */ - AudioSummary audioSummary() const; - void setAudioSummary( const AudioSummary& summary ); - - /** - * Get a track object from the md5 hash of a song's contents. - * - * Call parseProfile() to get the track itself once the - * QNetworkReply() emits the finished() signal. - */ - static QNetworkReply* profileFromMD5( const QByteArray& md5 ); - - /** - * Get a track object from an Echo Nest track id. - * - * Call parseProfile() to get the track itself once the - * QNetworkReply() emits the finished() signal. - */ - static QNetworkReply* profileFromTrackId( const QByteArray& id ); - - /** - * Upload a track to The Echo Nest for analysis. The file can either be - * a local filetype and include the file data as a parameter, or a url to a file on the internet. - * - * When the QNetworkReply emits its finished() signal, you can call parseProfile() - * to get the resulting Track object. Be sure to check the status of the new track, - * as it might be 'pending', which means it is still being analyzed and must be asked - * for again later. - * - * Note that in the case of uploading a local file, the data QByteArray must stay in scope for the - * whole completion of the upload operation. - */ - static QNetworkReply* uploadLocalFile( const QUrl& localFile, const QByteArray& data, bool waitForResult = true ); - static QNetworkReply* uploadURL( const QUrl& remoteURL, bool waitForResult = true ); - - /** - * Analyze a previously uploaded track with the current version of the analyzer. - * It can be referenced by either track ID or file md5. - */ - static QNetworkReply* analyzeTrackId( const QByteArray& id, bool wait = true ); - static QNetworkReply* analyzeTrackMD5( const QByteArray& id, bool wait = true ); - - /** - * Parse the result of a track request, and turn it into a - * Track object. - * - * Call this function after the QNetworkReply* object returned - * from the parse*, upload*, and analyze* emits its finished() signal - */ - static Track parseProfile( QNetworkReply* ) throw( ParseError ); - -private: - - QSharedDataPointer d; -}; - -typedef QVector Tracks; -ECHONEST_EXPORT QDebug operator<<(QDebug d, const Echonest::Track& track); - - -} // namespace - -#endif diff --git a/3rdparty/libechonest/Track_p.h b/3rdparty/libechonest/Track_p.h deleted file mode 100644 index 563e93517..000000000 --- a/3rdparty/libechonest/Track_p.h +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - -#ifndef ECHONEST_TRACK_P_H -#define ECHONEST_TRACK_P_H - -#include "AudioSummary.h" -#include "Config.h" -#include "Song.h" - - -#include -#include -#include - -namespace Echonest { - inline QNetworkReply* doPost(const QUrl& url) - { - // UGLY :( Build url, then extract the encded query items, put them in the POST body, and send that to the url minus the encoded params. - // The final data - QByteArray data; - int size = url.encodedQueryItems().size(); - for( int i = 0; i < size; i++ ) { - const QPair< QByteArray, QByteArray > item = url.encodedQueryItems().at( i ); - data.append( item.first + "=" + item.second + "&" ); - } - data.truncate( data.size() - 1 ); // remove extra & - //qDebug() << "Sending data:" << data << "for method:" << url.path(); - // strip the extras - QUrl url2( url.toString().mid( 0, url.toString().indexOf( QLatin1Char( '?' ) ) ) ); - QNetworkRequest request = QNetworkRequest( url2 ); - request.setHeader( QNetworkRequest::ContentTypeHeader, QLatin1String( "application/x-www-form-urlencoded" ) ); - return Echonest::Config::instance()->nam()->post( request, data ); - } -} - -class TrackData : public QSharedData -{ -public: - TrackData() {} - - TrackData(const TrackData& other) : QSharedData( other ) - { - analyzer_version = other.analyzer_version; - artist = other.artist; - bitrate = other.bitrate; - id = other.id; - md5 = other.md5; - release = other.release; - samplerate = other.samplerate; - status = other.status; - title = other.title; - catalog = other.catalog; - foreign_id = other.foreign_id; - release_image = other.release_image; - preview_url = other.preview_url; - - } - - QString artist; - QString analyzer_version; - int bitrate; - QByteArray id; - QByteArray md5; - QString release; - QByteArray audio_md5; - int samplerate; - QString status; - QString title; - // used when fetched as a foreign id in a tracks bucket - QString catalog; - QByteArray foreign_id; - QUrl release_image; - QUrl preview_url; - - // song tracks have an associated song - Echonest::Song song; - - Echonest::AudioSummary audio_summary; - -}; - -#endif diff --git a/3rdparty/libechonest/TypeInformation.cpp b/3rdparty/libechonest/TypeInformation.cpp deleted file mode 100644 index a69780f13..000000000 --- a/3rdparty/libechonest/TypeInformation.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - -#include "TypeInformation.h" - -#include - -namespace Echonest { - -class ArtistInformationPrivate -{ -public: - - ArtistInformationPrivate() : flags( ArtistInformation::NoInformation ) - {} - - Echonest::ArtistInformation::ArtistInformationFlags flags; - QStringList idSpaces; -}; - -class SongInformationPrivate -{ -public: - - SongInformationPrivate() : flags( SongInformation::NoInformation ) - {} - - SongInformation::SongInformationFlags flags; - QStringList idSpaces; -}; - -} // namespace -Echonest::ArtistInformation::ArtistInformation() - : d_ptr( new Echonest::ArtistInformationPrivate ) -{ - Q_D( ArtistInformation ); - d->flags = Echonest::ArtistInformation::NoInformation; -} - - -Echonest::ArtistInformation::ArtistInformation( ArtistInformationFlags flags ) -: d_ptr( new Echonest::ArtistInformationPrivate ) -{ - Q_D( ArtistInformation ); - d->flags = flags; -} - -Echonest::ArtistInformation::ArtistInformation( ArtistInformation::ArtistInformationFlags flags, const QStringList& idSpaces ) - : d_ptr( new Echonest::ArtistInformationPrivate ) -{ - Q_D( Echonest::ArtistInformation ); - d->flags = flags; - d->idSpaces = idSpaces; -} - -Echonest::ArtistInformation::ArtistInformation( const Echonest::ArtistInformation& other ) - : d_ptr( new Echonest::ArtistInformationPrivate( *other.d_ptr ) ) -{ -} - -Echonest::ArtistInformation::~ArtistInformation() -{ - delete d_ptr; -} -Echonest::ArtistInformation& Echonest::ArtistInformation::operator=( const Echonest::ArtistInformation& typeInfo ) -{ - d_ptr = new Echonest::ArtistInformationPrivate( *typeInfo.d_ptr ); - return *this; -} - -Echonest::ArtistInformation::ArtistInformationFlags Echonest::ArtistInformation::flags() const -{ - Q_D( const Echonest::ArtistInformation ); - - return d->flags; -} - -void Echonest::ArtistInformation::setArtistInformationFlags( ArtistInformationFlags flags) -{ - Q_D( Echonest::ArtistInformation ); - - d->flags = flags; -} - -QStringList Echonest::ArtistInformation::idSpaces() const -{ - Q_D( const Echonest::ArtistInformation ); - - return d->idSpaces; -} - -void Echonest::ArtistInformation::setIdSpaces(const QStringList& idspaces) -{ - Q_D( Echonest::ArtistInformation ); - - d->idSpaces = idspaces; -} - -Echonest::SongInformation::SongInformation() - : d_ptr( new Echonest::SongInformationPrivate ) -{ - Q_D( Echonest::SongInformation ); - - d->flags = Echonest::SongInformation::NoInformation; -} - -Echonest::SongInformation::SongInformation( SongInformationFlags flags ) - : d_ptr( new Echonest::SongInformationPrivate ) -{ - Q_D( SongInformation ); - - d->flags = flags; -} - -Echonest::SongInformation::SongInformation( SongInformation::SongInformationFlags flags, const QStringList& idSpaces ) - : d_ptr( new Echonest::SongInformationPrivate ) -{ - Q_D( Echonest::SongInformation ); - - d->flags = flags; - d->idSpaces = idSpaces; -} - -Echonest::SongInformation::SongInformation( const Echonest::SongInformation& other ) - : d_ptr( new Echonest::SongInformationPrivate( *other.d_ptr ) ) -{ - -} - -Echonest::SongInformation::~SongInformation() -{ - delete d_ptr; -} - -Echonest::SongInformation& Echonest::SongInformation::operator=( const Echonest::SongInformation& info ) -{ - d_ptr = new Echonest::SongInformationPrivate( *info.d_ptr ); - - return *this; -} - - -Echonest::SongInformation::SongInformationFlags Echonest::SongInformation::flags() const -{ - Q_D( const Echonest::SongInformation ); - - return d->flags; -} - -void Echonest::SongInformation::setSongInformationFlags( SongInformationFlags flags ) -{ - Q_D( Echonest::SongInformation ); - - d->flags = flags; -} - -QStringList Echonest::SongInformation::idSpaces() const -{ - Q_D( const Echonest::SongInformation ); - - return d->idSpaces; -} - -void Echonest::SongInformation::setIdSpaces(const QStringList& idspaces) -{ - Q_D( Echonest::SongInformation ); - - d->idSpaces = idspaces; -} - diff --git a/3rdparty/libechonest/TypeInformation.h b/3rdparty/libechonest/TypeInformation.h deleted file mode 100644 index 2fef60a30..000000000 --- a/3rdparty/libechonest/TypeInformation.h +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - - -#ifndef ECHONEST_TYPEINFORMATION_H -#define ECHONEST_TYPEINFORMATION_H - -#include "echonest_export.h" - -#include -#include -#include - -namespace Echonest { - class ArtistInformationPrivate; - class SongInformationPrivate; - - /** - * This class describes what artist information to return with a query. - * - * The default behaviour is NoInformation. - */ - class ECHONEST_EXPORT ArtistInformation - { - public: - enum ArtistInformationFlag { - NoInformation = 0x0000, - Audio = 0x0001, - Biographies = 0x0002, - Blogs = 0x0004, - Familiarity = 0x0008, - Hotttnesss = 0x0010, - Images = 0x0020, - News = 0x0040, - Reviews = 0x0080, - Terms = 0x0100, - Urls = 0x200, - Videos = 0x0400 - }; - Q_DECLARE_FLAGS( ArtistInformationFlags, ArtistInformationFlag ) - - ArtistInformation(); - ArtistInformation( ArtistInformationFlags flags ); - ArtistInformation( ArtistInformationFlags flags, const QStringList& idSpaces ); - ArtistInformation( const ArtistInformation& other ); - ~ArtistInformation(); - ArtistInformation& operator=( const ArtistInformation& typeInfo ); - - /** - * The individual pieces of information to fetch for this artist. - * - * Use \c setIdSpaces to set an id space for this query. - */ - ArtistInformationFlags flags() const; - void setArtistInformationFlags( ArtistInformationFlags flags ); - - /** - * The id spaces to limit this to. Do not include the "id:" prefix. - */ - QStringList idSpaces() const; - void setIdSpaces( const QStringList& idspaces ); - - private: - ArtistInformationPrivate* d_ptr; - Q_DECLARE_PRIVATE( ArtistInformation ) - }; - - Q_DECLARE_OPERATORS_FOR_FLAGS( ArtistInformation::ArtistInformationFlags ) - - /** - * This class describes what song information to return with a query. - * - * The default behaviour is NoInformation. - */ - class ECHONEST_EXPORT SongInformation - { - public: - enum SongInformationFlag { - AudioSummaryInformation = 0x001, - Tracks = 0x002, - Hotttnesss = 0x04, - ArtistHotttnesss = 0x008, - ArtistFamiliarity = 0x010, - ArtistLocation = 0x020, - - NoInformation = 0x800 - }; - Q_DECLARE_FLAGS( SongInformationFlags, SongInformationFlag ) - - SongInformation(); - SongInformation( SongInformationFlags flags ); - SongInformation( SongInformationFlags flags, const QStringList& idSpaces ); - SongInformation( const SongInformation& other ); - ~SongInformation(); - SongInformation& operator=( const SongInformation& info ); - - /** - * The individual pieces of information to fetch for this song. - * If id spaces are desired,see \c setIdSpaces for more information. - */ - SongInformationFlags flags() const; - void setSongInformationFlags( SongInformationFlags flags ); - - /** - * The id spaces to limit this to. Do not include the "id:" prefix. - */ - QStringList idSpaces() const; - void setIdSpaces( const QStringList& idspaces ); - - private: - SongInformationPrivate* d_ptr; - Q_DECLARE_PRIVATE( SongInformation ) - - }; - - Q_DECLARE_OPERATORS_FOR_FLAGS(SongInformation::SongInformationFlags) -} - -Q_DECLARE_METATYPE( Echonest::ArtistInformation ) -Q_DECLARE_METATYPE( Echonest::SongInformation ) - -#endif diff --git a/3rdparty/libechonest/Util.cpp b/3rdparty/libechonest/Util.cpp deleted file mode 100644 index 8b03c2eb4..000000000 --- a/3rdparty/libechonest/Util.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - -#include "Util.h" - -#include - -QByteArray Echonest::escapeSpacesAndPluses(const QString& in) -{ - // Echonest wants " " treated as "+", so we force QUrl to encode spaces as +es rather than %20 - QByteArray escaped = QUrl::toPercentEncoding( in, " " ); - escaped.replace( " ", "+" ); - return escaped; -} - - -Echonest::Analysis::AnalysisStatus Echonest::statusToEnum(const QString& status) -{ - if( status == QLatin1String("unknown") ) { - return Echonest::Analysis::Unknown; - } else if( status == QLatin1String("pending") ) { - return Echonest::Analysis::Pending; - } else if( status == QLatin1String("complete") ) { - return Echonest::Analysis::Complete; - } else if( status == QLatin1String("error" )) { - return Echonest::Analysis::Error; - } - return Echonest::Analysis::Unknown; -} - -QString Echonest::statusToString(Echonest::Analysis::AnalysisStatus status) -{ - switch( status ) - { - case Echonest::Analysis::Unknown: - return QLatin1String( "unknown" ); - case Echonest::Analysis::Pending: - return QLatin1String( "pending" ); - case Echonest::Analysis::Complete: - return QLatin1String( "complete" ); - case Echonest::Analysis::Error: - return QLatin1String( "error" ); - } - return QString(); -} - -QByteArray Echonest::catalogTypeToLiteral(Echonest::CatalogTypes::Type type) -{ - switch( type ) - { - case Echonest::CatalogTypes::Artist: - return "artist"; - case Echonest::CatalogTypes::Song: - return "song"; - default: - return ""; - } -} - -Echonest::CatalogTypes::Type Echonest::literalToCatalogType( const QByteArray& type ) -{ - if( type == "artist" ) - return Echonest::CatalogTypes::Artist; - else if( type == "song" ) - return Echonest::CatalogTypes::Song; - else - return Echonest::CatalogTypes::Artist; -} - - -QByteArray Echonest::catalogStatusToLiteral(Echonest::CatalogTypes::TicketStatus status) -{ - return statusToString( static_cast( status ) ).toLatin1(); -} - -Echonest::CatalogTypes::TicketStatus Echonest::literalToCatalogStatus(const QByteArray& type) -{ - return static_cast( statusToEnum( QLatin1String( type ) ) ); -} - -/** - * Delete, - U pda*te, - Play, - Skip */ - -QByteArray Echonest::catalogUpdateActionToLiteral(Echonest::CatalogTypes::Action action) -{ - switch( action ) - { - case Echonest::CatalogTypes::Delete: - return "delete"; - case Echonest::CatalogTypes::Play: - return "play"; - case Echonest::CatalogTypes::Update: - return "update"; - case Echonest::CatalogTypes::Skip: - return "skip"; - default: - return ""; - } -} - -Echonest::CatalogTypes::Action Echonest::literalToCatalogUpdateAction(const QByteArray& type) -{ - if( type == "delete" ) - return Echonest::CatalogTypes::Delete; - else if( type == "play" ) - return Echonest::CatalogTypes::Play; - else if( type == "update" ) - return Echonest::CatalogTypes::Update; - else if( type == "skip" ) - return Echonest::CatalogTypes::Skip; - - return Echonest::CatalogTypes::Update; -} - -QDebug Echonest::operator<<(QDebug d, const Echonest::ForeignId& id) -{ - return d.maybeSpace() << QString::fromLatin1( "Foreign Id(%1, %2)" ).arg( id.catalog ).arg( id.foreign_id ); -} - -QDebug Echonest::operator<<(QDebug d, const Echonest::ArtistLocation& loc) -{ - return d.maybeSpace() << QString::fromLatin1( "Artist Location(%1, %2, %3)" ).arg( loc.location ).arg( loc.latitude ).arg( loc.longitude ); -} diff --git a/3rdparty/libechonest/Util.h b/3rdparty/libechonest/Util.h deleted file mode 100644 index 36c3a5205..000000000 --- a/3rdparty/libechonest/Util.h +++ /dev/null @@ -1,132 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - -#ifndef ECHONEST_UTIL_H -#define ECHONEST_UTIL_H - -#include "echonest_export.h" - -#include -#include -#include - -/** - * Some shared declarations - */ - -namespace Echonest -{ - namespace Analysis - { - enum AnalysisStatus { - Unknown = 0, - Pending = 1, - Complete = 2, - Error = 4 - }; - } - - namespace CatalogTypes - { - enum Type { - Artist = 0, - Song = 1 - }; - - enum Action { - Delete, - Update, - Play, - Skip - }; - - enum TicketStatus { - Unknown = 0, - Pending = 1, - Complete = 2, - Error = 4 - }; - } - - typedef struct - { - qreal confidence; - qreal duration; - qreal start; - } AudioChunk; - - typedef AudioChunk Bar; - typedef AudioChunk Beat; - typedef AudioChunk Section; - typedef AudioChunk Tatum; - - typedef struct - { - qreal confidence; - qreal duration; - qreal loudness_max; - qreal loudness_max_time; - qreal loudness_start; - QVector< qreal > pitches; - qreal start; - QVector< qreal > timbre; - } Segment; - - - typedef QVector< Bar > BarList; - typedef QVector< Beat > BeatList; - typedef QVector< Section > SectionList; - typedef QVector< Tatum > TatumList; - typedef QVector< Segment > SegmentList; - - typedef struct { - QUrl url; - QString attribution; - QString type; - } License; - - typedef struct { - QString catalog; - QString foreign_id; - } ForeignId; - - typedef struct { - qreal latitude; - qreal longitude; - QString location; - } ArtistLocation; - - typedef QVector< ForeignId > ForeignIds; - - QByteArray escapeSpacesAndPluses( const QString& in ); - - Analysis::AnalysisStatus statusToEnum( const QString& status ); - QString statusToString( Analysis::AnalysisStatus status ); - - QByteArray catalogTypeToLiteral( CatalogTypes::Type ); - CatalogTypes::Type literalToCatalogType( const QByteArray& type ); - - QByteArray catalogStatusToLiteral( CatalogTypes::TicketStatus ); - CatalogTypes::TicketStatus literalToCatalogStatus( const QByteArray& type ); - - QByteArray catalogUpdateActionToLiteral( CatalogTypes::Action ); - CatalogTypes::Action literalToCatalogUpdateAction( const QByteArray& type ); - - ECHONEST_EXPORT QDebug operator<<(QDebug d, const ForeignId& id); - ECHONEST_EXPORT QDebug operator<<(QDebug d, const ArtistLocation& id); -} - -#endif diff --git a/3rdparty/libechonest/echonest_export.h b/3rdparty/libechonest/echonest_export.h deleted file mode 100644 index 1eafa56e7..000000000 --- a/3rdparty/libechonest/echonest_export.h +++ /dev/null @@ -1,28 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Leo Franchi * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * 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, see . * - ****************************************************************************************/ - -#ifndef ECHONEST_EXPORT_H -#define ECHONEST_EXPORT_H - -#ifdef _WIN32 - #define ECHONEST_EXPORT __declspec(dllexport) -#elif __GNUC__ >= 4 - #define ECHONEST_EXPORT __attribute__ ((visibility("default"))) -#else - #define ECHONEST_EXPORT -#endif - -#endif diff --git a/CMakeLists.txt b/CMakeLists.txt index bafef3e0d..dafc92332 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -358,14 +358,8 @@ else (USE_SYSTEM_QXT) endif (NOT APPLE) endif (USE_SYSTEM_QXT) -# Use system libechonest if it's available find_path(ECHONEST_INCLUDE_DIRS echonest/echonest_export.h) find_library(ECHONEST_LIBRARIES echonest) -if(NOT ECHONEST_INCLUDE_DIRS OR NOT ECHONEST_LIBRARIES) - add_subdirectory(3rdparty/libechonest) - set(ECHONEST_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/3rdparty/libechonest) - set(ECHONEST_LIBRARIES echonest) -endif(NOT ECHONEST_INCLUDE_DIRS OR NOT ECHONEST_LIBRARIES) # Use system gmock if it's available # We need to look for both gmock and gtest diff --git a/debian/control b/debian/control index 28de22a1a..b79595c33 100644 --- a/debian/control +++ b/debian/control @@ -15,6 +15,7 @@ Build-Depends: debhelper (>= 7), libboost-serialization-dev, libcdio-cdda1, libchromaprint-dev, + libechonest-dev, libglew1.5-dev | libglew-dev, libqt4-dev, diff --git a/dist/clementine.spec.in b/dist/clementine.spec.in index abb75df1a..2a0b66944 100644 --- a/dist/clementine.spec.in +++ b/dist/clementine.spec.in @@ -14,7 +14,7 @@ BuildRequires: qt4-devel boost-devel gcc-c++ glew-devel libgpod-devel BuildRequires: cmake gstreamer1-devel gstreamer1-plugins-base-devel BuildRequires: libmtp-devel protobuf-devel protobuf-compiler libcdio-devel BuildRequires: qjson-devel qca2-devel fftw-devel sparsehash-devel -BuildRequires: sqlite-devel pulseaudio-libs-devel +BuildRequires: sqlite-devel pulseaudio-libs-devel libechonest-devel Requires: libgpod protobuf-lite libcdio qjson qca-ossl sqlite