~ubuntu-branches/ubuntu/saucy/clementine/saucy

« back to all changes in this revision

Viewing changes to src/musicbrainz/tagfetcher.cpp

  • Committer: Package Import Robot
  • Author(s): Thomas PIERSON
  • Date: 2012-01-01 20:43:39 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120101204339-lsb6nndwhfy05sde
Tags: 1.0.1+dfsg-1
New upstream release. (Closes: #653926, #651611, #657391)

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
   along with Clementine.  If not, see <http://www.gnu.org/licenses/>.
16
16
*/
17
17
 
18
 
#include "fingerprinter.h"
 
18
#include "tagfetcher.h"
 
19
 
 
20
#include "acoustidclient.h"
 
21
#include "chromaprinter.h"
19
22
#include "musicbrainzclient.h"
20
 
#include "musicdnsclient.h"
21
 
#include "tagfetcher.h"
 
23
#include "core/timeconstants.h"
22
24
 
23
25
#include <QFuture>
24
26
#include <QFutureWatcher>
 
27
#include <QUrl>
25
28
#include <QtConcurrentMap>
26
29
 
27
30
TagFetcher::TagFetcher(QObject* parent)
28
31
  : QObject(parent),
29
32
    fingerprint_watcher_(NULL),
30
 
    musicdns_client_(new MusicDnsClient(this)),
 
33
    acoustid_client_(new AcoustidClient(this)),
31
34
    musicbrainz_client_(new MusicBrainzClient(this))
32
35
{
33
 
  connect(musicdns_client_, SIGNAL(Finished(int,QString)), SLOT(PuidFound(int,QString)));
 
36
  connect(acoustid_client_, SIGNAL(Finished(int,QString)), SLOT(PuidFound(int,QString)));
34
37
  connect(musicbrainz_client_, SIGNAL(Finished(int,MusicBrainzClient::ResultList)), SLOT(TagsFetched(int,MusicBrainzClient::ResultList)));
35
38
}
36
39
 
37
40
QString TagFetcher::GetFingerprint(const Song& song) {
38
 
  return Fingerprinter(song.filename()).CreateFingerprint();
 
41
  return Chromaprinter(song.url().toLocalFile()).CreateFingerprint();
39
42
}
40
43
 
41
44
void TagFetcher::StartFetch(const SongList& songs) {
61
64
    fingerprint_watcher_ = NULL;
62
65
  }
63
66
 
64
 
  musicdns_client_->CancelAll();
 
67
  acoustid_client_->CancelAll();
65
68
  musicbrainz_client_->CancelAll();
66
69
  songs_.clear();
67
70
}
81
84
  }
82
85
 
83
86
  emit Progress(song, tr("Identifying song"));
84
 
  musicdns_client_->Start(index, fingerprint, song.length_nanosec() / kNsecPerMsec);
 
87
  acoustid_client_->Start(index, fingerprint, song.length_nanosec() / kNsecPerMsec);
85
88
}
86
89
 
87
90
void TagFetcher::PuidFound(int index, const QString& puid) {
113
116
    song.Init(result.title_, result.artist_, result.album_,
114
117
              result.duration_msec_ * kNsecPerMsec);
115
118
    song.set_track(result.track_);
 
119
    song.set_year(result.year_);
116
120
    songs_guessed << song;
117
121
  }
118
122