| Playlist.h | | Playlist.h | |
| | | | |
| skipping to change at line 25 | | skipping to change at line 25 | |
| **************************************************************************
**************/ | | **************************************************************************
**************/ | |
| | | | |
| #ifndef ECHONEST_PLAYLIST_H | | #ifndef ECHONEST_PLAYLIST_H | |
| #define ECHONEST_PLAYLIST_H | | #define ECHONEST_PLAYLIST_H | |
| | | | |
| #include "echonest_export.h" | | #include "echonest_export.h" | |
| #include "Song.h" | | #include "Song.h" | |
| | | | |
| #include <QSharedData> | | #include <QSharedData> | |
| #include <QDebug> | | #include <QDebug> | |
|
| | | #include "Artist.h" | |
| | | #include <QtCore/QString> | |
| | | #include "Catalog.h" | |
| | | | |
| class QNetworkReply; | | class QNetworkReply; | |
| class DynamicPlaylistData; | | class DynamicPlaylistData; | |
| | | | |
| namespace Echonest{ | | 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 playl
ist ID and | | * This encapsulates an Echo Nest dynamic playlist. It contains a playl
ist ID and | |
| * the current song, and can fetch the next song. | | * the current song, and can fetch the next song. | |
| * | | * | |
| * See http://developer.echonest.com/docs/v4/playlist.html#dynamic | | * See http://developer.echonest.com/docs/v4/playlist.html#dynamic | |
| * for more information | | * for more information | |
| */ | | */ | |
| class ECHONEST_EXPORT DynamicPlaylist | | class ECHONEST_EXPORT DynamicPlaylist | |
| { | | { | |
| public: | | public: | |
| /** | | /** | |
| * The types of playlist that can be generated. Artist plays songs
for the given artist, | | * The types of playlist that can be generated. Artist plays songs
for the given artist, | |
| * ArtistRadio takes into account similar artists, adn ArtistDescr
iption plays songs matching | | * ArtistRadio takes into account similar artists, adn ArtistDescr
iption plays songs matching | |
| * the given description. | | * the given description. | |
| */ | | */ | |
| enum ArtistTypeEnum { | | enum ArtistTypeEnum { | |
| ArtistType, | | ArtistType, | |
| ArtistRadioType, | | ArtistRadioType, | |
|
| ArtistDescriptionType | | ArtistDescriptionType, | |
| | | CatalogType, | |
| | | CatalogRadioType, | |
| | | SongRadioType | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * Different ways to sort a generated playlist | | * Different ways to sort a generated playlist | |
| */ | | */ | |
| enum SortingType { | | enum SortingType { | |
| SortTempoAscending, | | SortTempoAscending, | |
| SortTempoDescending, | | SortTempoDescending, | |
| SortDurationAscending, | | SortDurationAscending, | |
| SortDurationDescending, | | SortDurationDescending, | |
| | | | |
| skipping to change at line 106 | | skipping to change at line 137 | |
| * functions. | | * functions. | |
| */ | | */ | |
| enum PlaylistParam { | | enum PlaylistParam { | |
| Type, /// The type of playlist to generate. Value is the Dynami
cPlaylist::ArtistTypeEnum enum | | Type, /// The type of playlist to generate. Value is the Dynami
cPlaylist::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 pro
grammatically. If using XSPF, you must specify a catalog, the tracks bucket
, and limit = true | | Format, /// Either xml (default) or xspf. If the result is xspf
, the raw xspf playlist is returned, else the xml is parsed and exposed pro
grammatically. If using XSPF, you must specify a catalog, the tracks bucket
, and limit = true | |
| Pick, /// How the artists are picked for each artist in Artis
tType playlists. Value is Playlist::ArtistPick enum value. | | Pick, /// How the artists are picked for each artist in Artis
tType playlists. Value is Playlist::ArtistPick enum value. | |
| Variety, /// 0 < variety < 1 The maximum variety of arti
sts to be represented in the playlist. A higher number will allow for more
variety in the artists. | | Variety, /// 0 < variety < 1 The maximum variety of arti
sts 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 | | ArtistId, /// ID(s) of seed artist(s) for the playlist | |
| Artist, /// Artist names of seeds for playlist | | Artist, /// Artist names of seeds for playlist | |
| ArtistSeedCatalog, /// ID of seed artist catalog for the playli
st | | ArtistSeedCatalog, /// ID of seed artist catalog for the playli
st | |
|
| | | SourceCatalog, /// ID of catalog (artist or song) for catalog t
ype playlists | |
| SongId, /// IDs of seed songs for the playlist | | SongId, /// IDs of seed songs for the playlist | |
| Description, /// Textual description for sort of songs that can
be included in 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 | | 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 | | 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 | | MinTempo, /// 0.0 < tempo < 500.0 (BPM) the minimum tempo
for any included songs | |
| MaxDuration, /// 0.0 < duration < 3600.0 (seconds) the ma
ximum duration of any song on the playlist | | MaxDuration, /// 0.0 < duration < 3600.0 (seconds) the ma
ximum duration of any song on the playlist | |
| MinDuration, /// 0.0 < duration < 3600.0 (seconds) the mi
nimum duration of any song on the playlist | | MinDuration, /// 0.0 < duration < 3600.0 (seconds) the mi
nimum duration of any song on the playlist | |
| MaxLoudness, /// -100.0 < loudness < 100.0 (dB) the maximum lo
udness of any song on the playlist | | MaxLoudness, /// -100.0 < loudness < 100.0 (dB) the maximum lo
udness of any song on the playlist | |
| MinLoudness, /// -100.0 < loudness < 100.0 (dB) the minimum lo
udness of any song on the playlist | | MinLoudness, /// -100.0 < loudness < 100.0 (dB) the minimum lo
udness of any song on the playlist | |
| MinDanceability, /// 0 < danceability < 1 a measure of the min
imum danceability of the song | | MinDanceability, /// 0 < danceability < 1 a measure of the min
imum danceability of the song | |
| | | | |
| skipping to change at line 142 | | skipping to change at line 174 | |
| Sort, /// SortingType enum, the type of sorting to use, | | Sort, /// SortingType enum, the type of sorting to use, | |
| Limit, /// true, false if true songs will be limited to thos
e that appear in the catalog specified by the id: bucket | | Limit, /// true, false if true songs will be limited to thos
e 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 | | 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) | | 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 ca
ll for the next track in the chain. Please note that this sidesteps libecho
nest's handling of the tracks. | | 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 ca
ll for the next track in the chain. Please note that this sidesteps libecho
nest's handling of the tracks. | |
| }; | | }; | |
| | | | |
| typedef QPair< PlaylistParam, QVariant > PlaylistParamData; | | typedef QPair< PlaylistParam, QVariant > PlaylistParamData; | |
| typedef QVector< PlaylistParamData > PlaylistParams; | | 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(); | | DynamicPlaylist(); | |
| virtual ~DynamicPlaylist(); | | virtual ~DynamicPlaylist(); | |
| DynamicPlaylist( const DynamicPlaylist& other ); | | DynamicPlaylist( const DynamicPlaylist& other ); | |
| DynamicPlaylist& operator=( const DynamicPlaylist& playlist ); | | DynamicPlaylist& operator=( const DynamicPlaylist& playlist ); | |
| | | | |
| /** | | /** | |
| * Start a dynamic playlist with the given parameters. | | * Start a dynamic playlist with the given parameters. | |
| * Once the QNetworkReply has finished, pass it to parseStart() | | * Once the QNetworkReply has finished, pass it to parseStart() | |
| * and the inital song will be populated and returned. The session
Id(), currentSong(), | | * and the inital song will be populated and returned. The session
Id(), currentSong(), | |
| * and fetchNextSong() methods will then be useful. | | * and fetchNextSong() methods will then be useful. | |
| */ | | */ | |
|
| QNetworkReply* start( const PlaylistParams& params ); | | QNetworkReply* start( const PlaylistParams& params ) const; | |
| Song parseStart( QNetworkReply* ) throw( ParseError ); | | Song parseStart( QNetworkReply* ) throw( ParseError ); | |
| | | | |
| /** | | /** | |
| * The session id of this dynamic playlist. If the playlist has end
ed, or has not been started, | | * The session id of this dynamic playlist. If the playlist has end
ed, or has not been started, | |
| * the result is empty. | | * the result is empty. | |
| * | | * | |
| */ | | */ | |
| QByteArray sessionId() const; | | QByteArray sessionId() const; | |
| void setSessionId( const QByteArray& id ); | | void setSessionId( const QByteArray& id ); | |
| | | | |
| | | | |
| skipping to change at line 181 | | skipping to change at line 227 | |
| /** | | /** | |
| * Queries The Echo Nest for the next playable song in this | | * Queries The Echo Nest for the next playable song in this | |
| * dynamic playlist. | | * dynamic playlist. | |
| * | | * | |
| * Once the query has emitted the finished() signal, pass it to par
seNextSong(), which will | | * Once the query has emitted the finished() signal, pass it to par
seNextSong(), which will | |
| * return the new song to play. It will also set the current song
to the newly parsed song. | | * 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. | | * 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. Rang
es from 1 (lowest) to 5 (highest) | | * @param rating The rating for the song that was just played. Rang
es from 1 (lowest) to 5 (highest) | |
|
| | | * @param controls The controls to apply when fetching the next tra
ck. | |
| * | | * | |
| */ | | */ | |
|
| QNetworkReply* fetchNextSong( int rating = -1); | | QNetworkReply* fetchNextSong( int rating = -1 ) const; | |
| | | QNetworkReply* fetchNextSong( const DynamicControls& controls ) con | |
| | | st; | |
| Song parseNextSong( QNetworkReply* reply ); | | Song parseNextSong( QNetworkReply* reply ); | |
| | | | |
| /** | | /** | |
|
| | | * Returns a description of this dynamic playlist session | |
| | | */ | |
| | | QNetworkReply* fetchSessionInfo() const; | |
| | | SessionInfo parseSessionInfo( QNetworkReply* reply ) throw( ParseEr | |
| | | ror );; | |
| | | | |
| | | /** | |
| * Generate a static playlist, according to the desired criteria. U
se parseXSPFPlaylist if | | * Generate a static playlist, according to the desired criteria. U
se parseXSPFPlaylist if | |
| * you pass format=xspf to \c staticPlaylist(). | | * you pass format=xspf to \c staticPlaylist(). | |
| */ | | */ | |
| static QNetworkReply* staticPlaylist( const PlaylistParams& params
); | | static QNetworkReply* staticPlaylist( const PlaylistParams& params
); | |
| static SongList parseStaticPlaylist( QNetworkReply* reply ) throw(
ParseError ); | | static SongList parseStaticPlaylist( QNetworkReply* reply ) throw(
ParseError ); | |
| | | | |
| /** | | /** | |
| * Parse an xspf playlist. Returns the full xspf content with no mo
difications. | | * Parse an xspf playlist. Returns the full xspf content with no mo
difications. | |
| */ | | */ | |
| static QByteArray parseXSPFPlaylist( QNetworkReply* reply ) throw(
ParseError ); | | static QByteArray parseXSPFPlaylist( QNetworkReply* reply ) throw(
ParseError ); | |
| | | | |
| private: | | private: | |
| static QByteArray playlistParamToString( PlaylistParam param ); | | static QByteArray playlistParamToString( PlaylistParam param ); | |
| static QNetworkReply* generateInternal( const PlaylistParams& param
s, const QByteArray& type ); | | static QNetworkReply* generateInternal( const PlaylistParams& param
s, const QByteArray& type ); | |
| static QByteArray playlistSortToString(SortingType sorting); | | static QByteArray playlistSortToString(SortingType sorting); | |
| static QByteArray playlistArtistPickToString(ArtistPick pick); | | static QByteArray playlistArtistPickToString(ArtistPick pick); | |
|
| | | static QByteArray dynamicControlToString(DynamicControlItem control
); | |
| | | | |
| QSharedDataPointer<DynamicPlaylistData> d; | | QSharedDataPointer<DynamicPlaylistData> d; | |
| }; | | }; | |
| | | | |
| ECHONEST_EXPORT QDebug operator<<(QDebug d, const Echonest::DynamicPlay
list& playlist); | | ECHONEST_EXPORT QDebug operator<<(QDebug d, const Echonest::DynamicPlay
list& playlist); | |
| | | | |
| }; // namespace | | }; // namespace | |
| | | | |
| Q_DECLARE_METATYPE( Echonest::DynamicPlaylist ) | | Q_DECLARE_METATYPE( Echonest::DynamicPlaylist ) | |
| | | | |
| | | | |
End of changes. 10 change blocks. |
| 3 lines changed or deleted | | 60 lines changed or added | |
|