1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-16 11:19:18 +01:00
Clementine-audio-player-Mac.../3rdparty/libechonest/Track_p.h

97 lines
3.6 KiB
C
Raw Normal View History

/****************************************************************************************
* Copyright (c) 2010 Leo Franchi <lfranchi@kde.org> *
* *
* 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 <http://www.gnu.org/licenses/>. *
****************************************************************************************/
#ifndef ECHONEST_TRACK_P_H
#define ECHONEST_TRACK_P_H
#include "AudioSummary.h"
2011-10-26 16:45:20 +02:00
#include "Config.h"
#include "Song.h"
#include <QSharedData>
#include <QString>
2011-10-26 16:45:20 +02:00
#include <QNetworkReply>
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 );
}
2011-11-23 16:10:33 +01:00
}
class TrackData : public QSharedData
{
public:
TrackData() {}
2011-10-26 16:45:20 +02:00
2011-11-23 16:10:33 +01:00
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;
2011-10-26 16:45:20 +02:00
catalog = other.catalog;
foreign_id = other.foreign_id;
release_image = other.release_image;
preview_url = other.preview_url;
}
2011-10-26 16:45:20 +02:00
QString artist;
QString analyzer_version;
int bitrate;
QByteArray id;
QByteArray md5;
QString release;
QByteArray audio_md5;
int samplerate;
QString status;
QString title;
2011-10-26 16:45:20 +02:00
// 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;
2011-10-26 16:45:20 +02:00
};
#endif