Includes, comments and bugfixes
- Fix includes - Use common regex (Song::kCoverRemoveDisc) for removing Disc/CD from album - Remove Disc/CD from album when creating hash - Make imobiledevice support compile - Fix setting device on windows
This commit is contained in:
@@ -20,19 +20,29 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QNetworkReply>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
#include <QByteArray>
|
||||
#include <QPair>
|
||||
#include <QVariant>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QUrl>
|
||||
#include <QUrlQuery>
|
||||
#include <QtAlgorithms>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkReply>
|
||||
#include <QJsonParseError>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonValue>
|
||||
|
||||
#include "acoustidclient.h"
|
||||
|
||||
#include "core/closure.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/network.h"
|
||||
#include "core/timeconstants.h"
|
||||
|
||||
@@ -47,7 +57,7 @@ AcoustidClient::AcoustidClient(QObject *parent)
|
||||
|
||||
void AcoustidClient::SetTimeout(int msec) { timeouts_->SetTimeout(msec); }
|
||||
|
||||
void AcoustidClient::Start(int id, const QString& fingerprint, int duration_msec) {
|
||||
void AcoustidClient::Start(int id, const QString &fingerprint, int duration_msec) {
|
||||
|
||||
typedef QPair<QString, QString> Param;
|
||||
|
||||
|
||||
@@ -23,25 +23,24 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QMap>
|
||||
#include <QObject>
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
|
||||
class NetworkTimeouts;
|
||||
|
||||
class QNetworkAccessManager;
|
||||
class QNetworkReply;
|
||||
|
||||
class AcoustidClient : public QObject {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
// Gets a MBID from a Chromaprint fingerprint.
|
||||
// A fingerprint identifies one particular encoding of a song and is created
|
||||
// by Fingerprinter. An MBID identifies the actual song and can be passed to
|
||||
// Musicbrainz to get metadata.
|
||||
// A fingerprint identifies one particular encoding of a song and is created by Fingerprinter.
|
||||
// An MBID identifies the actual song and can be passed to Musicbrainz to get metadata.
|
||||
// You can create one AcoustidClient and make multiple requests using it.
|
||||
// IDs are provided by the caller when a request is started and included in
|
||||
// the Finished signal - they have no meaning to AcoustidClient.
|
||||
// IDs are provided by the caller when a request is started and included in the Finished signal - they have no meaning to AcoustidClient.
|
||||
|
||||
public:
|
||||
AcoustidClient(QObject *parent = nullptr);
|
||||
@@ -49,16 +48,13 @@ class AcoustidClient : public QObject {
|
||||
// Network requests will be aborted after this interval.
|
||||
void SetTimeout(int msec);
|
||||
|
||||
// Starts a request and returns immediately. Finished() will be emitted
|
||||
// later with the same ID.
|
||||
void Start(int id, const QString& fingerprint, int duration_msec);
|
||||
// Starts a request and returns immediately. Finished() will be emitted later with the same ID.
|
||||
void Start(int id, const QString &fingerprint, int duration_msec);
|
||||
|
||||
// Cancels the request with the given ID. Finished() will never be emitted
|
||||
// for that ID. Does nothing if there is no request with the given ID.
|
||||
// Cancels the request with the given ID. Finished() will never be emitted for that ID. Does nothing if there is no request with the given ID.
|
||||
void Cancel(int id);
|
||||
|
||||
// Cancels all requests. Finished() will never be emitted for any pending
|
||||
// requests.
|
||||
// Cancels all requests. Finished() will never be emitted for any pending requests.
|
||||
void CancelAll();
|
||||
|
||||
signals:
|
||||
|
||||
@@ -20,17 +20,26 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "chromaprinter.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
#include <QEventLoop>
|
||||
#include <QThread>
|
||||
#include <QtDebug>
|
||||
#include <QTime>
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <chromaprint.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QCoreApplication>
|
||||
#include <QThread>
|
||||
#include <QIODevice>
|
||||
#include <QBuffer>
|
||||
#include <QByteArray>
|
||||
#include <QDateTime>
|
||||
#include <QString>
|
||||
#include <QTime>
|
||||
#include <QtDebug>
|
||||
|
||||
#include "chromaprinter.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/signalchecker.h"
|
||||
|
||||
@@ -95,8 +104,7 @@ QString Chromaprinter::CreateFingerprint() {
|
||||
GstAppSinkCallbacks callbacks;
|
||||
memset(&callbacks, 0, sizeof(callbacks));
|
||||
callbacks.new_sample = NewBufferCallback;
|
||||
gst_app_sink_set_callbacks(reinterpret_cast<GstAppSink*>(sink), &callbacks,
|
||||
this, nullptr);
|
||||
gst_app_sink_set_callbacks(reinterpret_cast<GstAppSink*>(sink), &callbacks, this, nullptr);
|
||||
g_object_set(G_OBJECT(sink), "sync", FALSE, nullptr);
|
||||
g_object_set(G_OBJECT(sink), "emit-signals", TRUE, nullptr);
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include <gst/gst.h>
|
||||
#include <gst/app/gstappsink.h>
|
||||
|
||||
@@ -31,19 +32,18 @@
|
||||
|
||||
class Chromaprinter {
|
||||
// Creates a Chromaprint fingerprint from a song.
|
||||
// Uses GStreamer to open and decode the file as PCM data and passes this
|
||||
// to Chromaprint's code generator. The generated code can be used to identify
|
||||
// a song via Acoustid.
|
||||
// Uses GStreamer to open and decode the file as PCM data and passes this to Chromaprint's code generator.
|
||||
// The generated code can be used to identify a song via Acoustid.
|
||||
// You should create one Chromaprinter for each file you want to fingerprint.
|
||||
// This class works well with QtConcurrentMap.
|
||||
|
||||
public:
|
||||
Chromaprinter(const QString& filename);
|
||||
Chromaprinter(const QString &filename);
|
||||
~Chromaprinter();
|
||||
|
||||
// Creates a fingerprint from the song. This method is blocking, so you want
|
||||
// to call it in another thread. Returns an empty string if no fingerprint
|
||||
// could be created.
|
||||
// Creates a fingerprint from the song.
|
||||
// This method is blocking, so you want to call it in another thread.
|
||||
// Returns an empty string if no fingerprint could be created.
|
||||
QString CreateFingerprint();
|
||||
|
||||
private:
|
||||
|
||||
@@ -20,18 +20,29 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "musicbrainzclient.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QNetworkReply>
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
#include <QPair>
|
||||
#include <QSet>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QVariant>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QStringBuilder>
|
||||
#include <QRegExp>
|
||||
#include <QUrl>
|
||||
#include <QUrlQuery>
|
||||
#include <QtAlgorithms>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkReply>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QtDebug>
|
||||
|
||||
#include "core/closure.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/network.h"
|
||||
#include "core/utilities.h"
|
||||
#include "musicbrainzclient.h"
|
||||
|
||||
const char *MusicBrainzClient::kTrackUrl = "http://musicbrainz.org/ws/2/recording/";
|
||||
const char *MusicBrainzClient::kDiscUrl = "http://musicbrainz.org/ws/2/discid/";
|
||||
@@ -327,8 +338,7 @@ MusicBrainzClient::ResultList MusicBrainzClient::ParseTrack(QXmlStreamReader *re
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Parse the artist. Multiple artists are joined together with the
|
||||
// joinphrase from musicbrainz.
|
||||
// Parse the artist. Multiple artists are joined together with the joinphrase from musicbrainz.
|
||||
void MusicBrainzClient::ParseArtist(QXmlStreamReader *reader, QString *artist) {
|
||||
|
||||
QString join_phrase;
|
||||
@@ -394,10 +404,8 @@ MusicBrainzClient::ResultList MusicBrainzClient::UniqueResults(const ResultList&
|
||||
qSort(ret);
|
||||
}
|
||||
else { // KeepOriginalOrder
|
||||
// Qt doesn't provide a ordered set (QSet "stores values in an unspecified
|
||||
// order" according to Qt documentation).
|
||||
// We might use std::set instead, but it's probably faster to use ResultList
|
||||
// directly to avoid converting from one structure to another.
|
||||
// Qt doesn't provide a ordered set (QSet "stores values in an unspecified order" according to Qt documentation).
|
||||
// We might use std::set instead, but it's probably faster to use ResultList directly to avoid converting from one structure to another.
|
||||
for (const Result& res : results) {
|
||||
if (!ret.contains(res)) {
|
||||
ret << res;
|
||||
|
||||
@@ -23,31 +23,36 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QHash>
|
||||
#include <QMultiMap>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
#include <QHash>
|
||||
#include <QMap>
|
||||
#include <QMultiMap>
|
||||
#include <QSet>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QVector>
|
||||
|
||||
class NetworkTimeouts;
|
||||
|
||||
class QNetworkAccessManager;
|
||||
class QNetworkReply;
|
||||
|
||||
class MusicBrainzClient : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
// Gets metadata for a particular MBID.
|
||||
// An MBID is created from a fingerprint using MusicDnsClient.
|
||||
// You can create one MusicBrainzClient and make multiple requests using it.
|
||||
// IDs are provided by the caller when a request is started and included in
|
||||
// the Finished signal - they have no meaning to MusicBrainzClient.
|
||||
// IDs are provided by the caller when a request is started and included in the Finished signal - they have no meaning to MusicBrainzClient.
|
||||
|
||||
public:
|
||||
// The second argument allows for specifying a custom network access
|
||||
// manager. It is used in tests. The ownership of network
|
||||
// is not transferred.
|
||||
MusicBrainzClient(QObject* parent = nullptr,
|
||||
QNetworkAccessManager* network = nullptr);
|
||||
// The second argument allows for specifying a custom network access manager.
|
||||
// It is used in tests. The ownership of network is not transferred.
|
||||
MusicBrainzClient(QObject *parent = nullptr, QNetworkAccessManager *network = nullptr);
|
||||
|
||||
struct Result {
|
||||
Result() : duration_msec_(0), track_(0), year_(-1) {}
|
||||
@@ -85,29 +90,24 @@ class MusicBrainzClient : public QObject {
|
||||
};
|
||||
typedef QList<Result> ResultList;
|
||||
|
||||
// Starts a request and returns immediately. Finished() will be emitted
|
||||
// later with the same ID.
|
||||
void Start(int id, const QStringList& mbid);
|
||||
void StartDiscIdRequest(const QString& discid);
|
||||
// Starts a request and returns immediately. Finished() will be emitted later with the same ID.
|
||||
void Start(int id, const QStringList &mbid);
|
||||
void StartDiscIdRequest(const QString &discid);
|
||||
|
||||
// Cancels the request with the given ID. Finished() will never be emitted
|
||||
// for that ID. Does nothing if there is no request with the given ID.
|
||||
// Cancels the request with the given ID. Finished() will never be emitted for that ID. Does nothing if there is no request with the given ID.
|
||||
void Cancel(int id);
|
||||
|
||||
// Cancels all requests. Finished() will never be emitted for any pending
|
||||
// requests.
|
||||
// Cancels all requests. Finished() will never be emitted for any pending requests.
|
||||
void CancelAll();
|
||||
|
||||
signals:
|
||||
// Finished signal emitted when fechting songs tags
|
||||
void Finished(int id, const MusicBrainzClient::ResultList& result);
|
||||
// Finished signal emitted when fechting album's songs tags using DiscId
|
||||
void Finished(const QString& artist, const QString album,
|
||||
const MusicBrainzClient::ResultList& result);
|
||||
void Finished(const QString& artist, const QString album, const MusicBrainzClient::ResultList& result);
|
||||
|
||||
private slots:
|
||||
// id identifies the track, and request_number means it's the
|
||||
// 'request_number'th request for this track
|
||||
// id identifies the track, and request_number means it's the 'request_number'th request for this track
|
||||
void RequestFinished(QNetworkReply* reply, int id, int request_number);
|
||||
void DiscIdRequestFinished(const QString& discid, QNetworkReply* reply);
|
||||
|
||||
@@ -157,8 +157,7 @@ signals:
|
||||
}
|
||||
|
||||
bool operator<(const Release& other) const {
|
||||
// Compare status so that "best" status (e.g. Official) will be first
|
||||
// when sorting a list of releases.
|
||||
// Compare status so that "best" status (e.g. Official) will be first when sorting a list of releases.
|
||||
return status_ > other.status_;
|
||||
}
|
||||
|
||||
@@ -203,8 +202,7 @@ signals:
|
||||
};
|
||||
|
||||
inline uint qHash(const MusicBrainzClient::Result& result) {
|
||||
return qHash(result.album_) ^ qHash(result.artist_) ^ result.duration_msec_ ^
|
||||
qHash(result.title_) ^ result.track_ ^ result.year_;
|
||||
return qHash(result.album_) ^ qHash(result.artist_) ^ result.duration_msec_ ^ qHash(result.title_) ^ result.track_ ^ result.year_;
|
||||
}
|
||||
|
||||
#endif // MUSICBRAINZCLIENT_H
|
||||
|
||||
@@ -20,19 +20,20 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "tagfetcher.h"
|
||||
#include <QObject>
|
||||
#include <QtConcurrentMap>
|
||||
#include <QFuture>
|
||||
#include <QFutureWatcher>
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
|
||||
#include "core/timeconstants.h"
|
||||
#include "acoustidclient.h"
|
||||
#include "chromaprinter.h"
|
||||
#include "musicbrainzclient.h"
|
||||
#include "core/timeconstants.h"
|
||||
#include "tagfetcher.h"
|
||||
|
||||
#include <QFuture>
|
||||
#include <QFutureWatcher>
|
||||
#include <QUrl>
|
||||
#include <QtConcurrentMap>
|
||||
|
||||
TagFetcher::TagFetcher(QObject* parent)
|
||||
TagFetcher::TagFetcher(QObject *parent)
|
||||
: QObject(parent),
|
||||
fingerprint_watcher_(nullptr),
|
||||
acoustid_client_(new AcoustidClient(this)),
|
||||
|
||||
@@ -23,19 +23,20 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "musicbrainzclient.h"
|
||||
#include "core/song.h"
|
||||
|
||||
#include <QFutureWatcher>
|
||||
#include <QObject>
|
||||
#include <QFutureWatcher>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include "core/song.h"
|
||||
#include "musicbrainzclient.h"
|
||||
|
||||
class AcoustidClient;
|
||||
|
||||
class TagFetcher : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
// High level interface to Fingerprinter, AcoustidClient and
|
||||
// MusicBrainzClient.
|
||||
// High level interface to Fingerprinter, AcoustidClient and MusicBrainzClient.
|
||||
|
||||
public:
|
||||
TagFetcher(QObject *parent = nullptr);
|
||||
|
||||
Reference in New Issue
Block a user