Gentoo Archives: gentoo-commits

From: Lars Wendler <polynomial-c@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: media-sound/clementine/files/, media-sound/clementine/
Date: Mon, 26 Dec 2016 23:39:07
Message-Id: 1482795538.435d5fdb52747acb507a0cbc1fec3778110e0a37.polynomial-c@gentoo
1 commit: 435d5fdb52747acb507a0cbc1fec3778110e0a37
2 Author: Alexander Golubev <fatzer2 <AT> gmail <DOT> com>
3 AuthorDate: Mon Dec 26 22:23:30 2016 +0000
4 Commit: Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
5 CommitDate: Mon Dec 26 23:38:58 2016 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=435d5fdb
7
8 media-sound/clementine-1.3.1: drop echonest support
9
10 Gentoo Bug: 573712
11 Thanks for the patch to Lars Wendler.
12
13 Also rename the recently added patch 'clementine-chromaprint14' to meet
14 gentoo patch naming suggestions.
15 Closes: https://github.com/gentoo/gentoo/pull/3246
16
17 ...-1.3.1-r4.ebuild => clementine-1.3.1-r5.ebuild} | 4 +-
18 ....patch => clementine-1.3.1-chromaprint14.patch} | 0
19 .../clementine-1.3.1-libechonest_removal.patch | 701 +++++++++++++++++++++
20 3 files changed, 703 insertions(+), 2 deletions(-)
21
22 diff --git a/media-sound/clementine/clementine-1.3.1-r4.ebuild b/media-sound/clementine/clementine-1.3.1-r5.ebuild
23 similarity index 98%
24 rename from media-sound/clementine/clementine-1.3.1-r4.ebuild
25 rename to media-sound/clementine/clementine-1.3.1-r5.ebuild
26 index a61c2fe..4d23bb0 100644
27 --- a/media-sound/clementine/clementine-1.3.1-r4.ebuild
28 +++ b/media-sound/clementine/clementine-1.3.1-r5.ebuild
29 @@ -41,7 +41,6 @@ COMMON_DEPEND="
30 >=media-libs/chromaprint-0.6
31 media-libs/gstreamer:1.0
32 media-libs/gst-plugins-base:1.0
33 - media-libs/libechonest:=[qt4(+)]
34 >=media-libs/libmygpo-qt-1.0.9[qt4(+)]
35 >=media-libs/taglib-1.8[mp4(+)]
36 sys-libs/zlib
37 @@ -95,7 +94,8 @@ S="${WORKDIR}/${MY_P^}"
38 PATCHES=(
39 "${FILESDIR}"/${PN}-1.3-fix-tokenizer.patch
40 "${FILESDIR}"/${P}-fix-desktop-file.patch
41 - "${FILESDIR}"/${PN}-chromaprint14.patch #603662
42 + "${FILESDIR}"/${P}-chromaprint14.patch #603662
43 + "${FILESDIR}"/${P}-libechonest_removal.patch
44 )
45
46 src_prepare() {
47
48 diff --git a/media-sound/clementine/files/clementine-chromaprint14.patch b/media-sound/clementine/files/clementine-1.3.1-chromaprint14.patch
49 similarity index 100%
50 rename from media-sound/clementine/files/clementine-chromaprint14.patch
51 rename to media-sound/clementine/files/clementine-1.3.1-chromaprint14.patch
52
53 diff --git a/media-sound/clementine/files/clementine-1.3.1-libechonest_removal.patch b/media-sound/clementine/files/clementine-1.3.1-libechonest_removal.patch
54 new file mode 100644
55 index 00000000..63eb096
56 --- /dev/null
57 +++ b/media-sound/clementine/files/clementine-1.3.1-libechonest_removal.patch
58 @@ -0,0 +1,701 @@
59 +Remove depend upon media-libs/libechonest and its support from clementine due to echonest service
60 +was shutdown and this functionality is useless now and results in nothing but a slight security
61 +and privacy risk.
62 +See Gentoo bug #573712.
63 +Based upon patch extracted from upstream git; original patch info:
64 +commit a8a0f2e4fdd3d4b2fd23b8628a3abc27c290d01d
65 +Author: John Maguire <john.maguire@×××××.com>
66 +Date: Mon Jun 27 14:45:40 2016 +0100
67 +
68 + Remove echonest and update songkick concert fetcher.
69 +--- Clementine-1.3.1/CMakeLists.txt
70 ++++ Clementine-1.3.1/CMakeLists.txt
71 +@@ -365,9 +365,6 @@
72 + endif (NOT APPLE)
73 + endif (USE_SYSTEM_QXT)
74 +
75 +-find_path(ECHONEST_INCLUDE_DIRS echonest/echonest_export.h)
76 +-find_library(ECHONEST_LIBRARIES echonest)
77 +-
78 + # Use system gmock if it's available
79 + # We need to look for both gmock and gtest
80 + find_path(GMOCK_INCLUDE_DIRS gmock/gmock.h)
81 +--- Clementine-1.3.1/src/CMakeLists.txt
82 ++++ Clementine-1.3.1/src/CMakeLists.txt
83 +@@ -35,7 +35,6 @@
84 + include_directories(${QTSINGLEAPPLICATION_INCLUDE_DIRS})
85 + include_directories(${QTIOCOMPRESSOR_INCLUDE_DIRS})
86 + include_directories(${QXT_INCLUDE_DIRS})
87 +-include_directories(${ECHONEST_INCLUDE_DIRS})
88 + include_directories(${SHA2_INCLUDE_DIRS})
89 + include_directories(${CHROMAPRINT_INCLUDE_DIRS})
90 + include_directories(${MYGPOQT_INCLUDE_DIRS})
91 +@@ -297,8 +296,6 @@
92 + songinfo/artistinfoview.cpp
93 + songinfo/collapsibleinfoheader.cpp
94 + songinfo/collapsibleinfopane.cpp
95 +- songinfo/echonestbiographies.cpp
96 +- songinfo/echonestimages.cpp
97 + songinfo/songinfobase.cpp
98 + songinfo/songinfofetcher.cpp
99 + songinfo/songinfoprovider.cpp
100 +@@ -586,8 +583,6 @@
101 + songinfo/artistinfoview.h
102 + songinfo/collapsibleinfoheader.h
103 + songinfo/collapsibleinfopane.h
104 +- songinfo/echonestbiographies.h
105 +- songinfo/echonestimages.h
106 + songinfo/songinfobase.h
107 + songinfo/songinfofetcher.h
108 + songinfo/songinfoprovider.h
109 +@@ -822,16 +817,12 @@
110 + internet/lastfm/lastfmcompat.cpp
111 + internet/lastfm/lastfmservice.cpp
112 + internet/lastfm/lastfmsettingspage.cpp
113 +- songinfo/echonestsimilarartists.cpp
114 +- songinfo/echonesttags.cpp
115 + songinfo/lastfmtrackinfoprovider.cpp
116 + songinfo/tagwidget.cpp
117 + HEADERS
118 + covers/lastfmcoverprovider.h
119 + internet/lastfm/lastfmservice.h
120 + internet/lastfm/lastfmsettingspage.h
121 +- songinfo/echonestsimilarartists.h
122 +- songinfo/echonesttags.h
123 + songinfo/lastfmtrackinfoprovider.h
124 + songinfo/tagwidget.h
125 + UI
126 +@@ -1241,7 +1232,6 @@
127 + ${TAGLIB_LIBRARIES}
128 + ${MYGPOQT_LIBRARIES}
129 + ${CHROMAPRINT_LIBRARIES}
130 +- ${ECHONEST_LIBRARIES}
131 + ${GOBJECT_LIBRARIES}
132 + ${GLIB_LIBRARIES}
133 + ${GIO_LIBRARIES}
134 +--- Clementine-1.3.1/src/main.cpp
135 ++++ Clementine-1.3.1/src/main.cpp
136 +@@ -76,8 +76,6 @@
137 + #include <glib.h>
138 + #include <gst/gst.h>
139 +
140 +-#include <echonest/Config.h>
141 +-
142 + #ifdef Q_OS_DARWIN
143 + #include <sys/resource.h>
144 + #include <sys/sysctl.h>
145 +@@ -401,8 +399,8 @@
146 + // Add root CA cert for SoundCloud, whose certificate is missing on OS X.
147 + QSslSocket::addDefaultCaCertificates(
148 + QSslCertificate::fromPath(":/soundcloud-ca.pem", QSsl::Pem));
149 +- QSslSocket::addDefaultCaCertificates(
150 +- QSslCertificate::fromPath(":/Equifax_Secure_Certificate_Authority.pem", QSsl::Pem));
151 ++ QSslSocket::addDefaultCaCertificates(QSslCertificate::fromPath(
152 ++ ":/Equifax_Secure_Certificate_Authority.pem", QSsl::Pem));
153 +
154 + // Has the user forced a different language?
155 + QString override_language = options.language();
156 +@@ -440,10 +438,6 @@
157 + Application app;
158 + app.set_language_name(language);
159 +
160 +- Echonest::Config::instance()->setAPIKey("DFLFLJBUF4EGTXHIG");
161 +- Echonest::Config::instance()->setNetworkAccessManager(
162 +- new NetworkAccessManager);
163 +-
164 + // Network proxy
165 + QNetworkProxyFactory::setApplicationProxyFactory(
166 + NetworkProxyFactory::Instance());
167 +--- Clementine-1.3.1/src/songinfo/artistinfoview.cpp
168 ++++ Clementine-1.3.1/src/songinfo/artistinfoview.cpp
169 +@@ -16,25 +16,12 @@
170 + */
171 +
172 + #include "artistinfoview.h"
173 +-#include "echonestbiographies.h"
174 +-#include "echonestimages.h"
175 + #include "songinfofetcher.h"
176 + #include "songkickconcerts.h"
177 + #include "widgets/prettyimageview.h"
178 +
179 +-#ifdef HAVE_LIBLASTFM
180 +-#include "echonestsimilarartists.h"
181 +-#include "echonesttags.h"
182 +-#endif
183 +-
184 + ArtistInfoView::ArtistInfoView(QWidget* parent) : SongInfoBase(parent) {
185 +- fetcher_->AddProvider(new EchoNestBiographies);
186 +- fetcher_->AddProvider(new EchoNestImages);
187 + fetcher_->AddProvider(new SongkickConcerts);
188 +-#ifdef HAVE_LIBLASTFM
189 +- fetcher_->AddProvider(new EchoNestSimilarArtists);
190 +- fetcher_->AddProvider(new EchoNestTags);
191 +-#endif
192 + }
193 +
194 + ArtistInfoView::~ArtistInfoView() {}
195 +--- Clementine-1.3.1/src/songinfo/echonestbiographies.cpp
196 ++++ Clementine-1.3.1/src/songinfo/echonestbiographies.cpp
197 +@@ -1,123 +0,0 @@
198 +-/* This file is part of Clementine.
199 +- Copyright 2010, David Sansome <me@××××××××××××.com>
200 +-
201 +- Clementine is free software: you can redistribute it and/or modify
202 +- it under the terms of the GNU General Public License as published by
203 +- the Free Software Foundation, either version 3 of the License, or
204 +- (at your option) any later version.
205 +-
206 +- Clementine is distributed in the hope that it will be useful,
207 +- but WITHOUT ANY WARRANTY; without even the implied warranty of
208 +- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
209 +- GNU General Public License for more details.
210 +-
211 +- You should have received a copy of the GNU General Public License
212 +- along with Clementine. If not, see <http://www.gnu.org/licenses/>.
213 +-*/
214 +-
215 +-#include "echonestbiographies.h"
216 +-
217 +-#include <memory>
218 +-
219 +-#include <echonest/Artist.h>
220 +-
221 +-#include "songinfotextview.h"
222 +-#include "core/logging.h"
223 +-#include "ui/iconloader.h"
224 +-
225 +-struct EchoNestBiographies::Request {
226 +- Request(int id) : id_(id), artist_(new Echonest::Artist) {}
227 +-
228 +- int id_;
229 +- std::unique_ptr<Echonest::Artist> artist_;
230 +-};
231 +-
232 +-EchoNestBiographies::EchoNestBiographies() {
233 +- site_relevance_["wikipedia"] = 100;
234 +- site_relevance_["lastfm"] = 60;
235 +- site_relevance_["amazon"] = 30;
236 +-
237 +- site_icons_["amazon"] = IconLoader::Load("amazon", IconLoader::Provider);
238 +- site_icons_["aol"] = IconLoader::Load("aol", IconLoader::Provider);
239 +- site_icons_["cdbaby"] = IconLoader::Load("cdbaby", IconLoader::Provider);
240 +- site_icons_["lastfm"] = IconLoader::Load("as", IconLoader::Lastfm);
241 +- site_icons_["mog"] = IconLoader::Load("mog", IconLoader::Provider);
242 +- site_icons_["mtvmusic"] = IconLoader::Load("mtvmusic", IconLoader::Provider);
243 +- site_icons_["myspace"] = IconLoader::Load("myspace", IconLoader::Provider);
244 +- site_icons_["wikipedia"] = IconLoader::Load("wikipedia", IconLoader::Provider);
245 +-}
246 +-
247 +-void EchoNestBiographies::FetchInfo(int id, const Song& metadata) {
248 +- std::shared_ptr<Request> request(new Request(id));
249 +- request->artist_->setName(metadata.artist());
250 +-
251 +- QNetworkReply* reply = request->artist_->fetchBiographies();
252 +- connect(reply, SIGNAL(finished()), SLOT(RequestFinished()));
253 +- requests_[reply] = request;
254 +-}
255 +-
256 +-void EchoNestBiographies::RequestFinished() {
257 +- QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
258 +- if (!reply || !requests_.contains(reply)) return;
259 +- reply->deleteLater();
260 +-
261 +- RequestPtr request = requests_.take(reply);
262 +-
263 +- try {
264 +- request->artist_->parseProfile(reply);
265 +- }
266 +- catch (Echonest::ParseError e) {
267 +- qLog(Warning) << "Error parsing echonest reply:" << e.errorType()
268 +- << e.what();
269 +- }
270 +-
271 +- QSet<QString> already_seen;
272 +-
273 +- for (const Echonest::Biography& bio : request->artist_->biographies()) {
274 +- QString canonical_site = bio.site().toLower();
275 +- canonical_site.replace(QRegExp("[^a-z]"), "");
276 +-
277 +- if (already_seen.contains(canonical_site)) continue;
278 +- already_seen.insert(canonical_site);
279 +-
280 +- CollapsibleInfoPane::Data data;
281 +- data.id_ = "echonest/bio/" + bio.site();
282 +- data.title_ = tr("Biography from %1").arg(bio.site());
283 +- data.type_ = CollapsibleInfoPane::Data::Type_Biography;
284 +-
285 +- if (site_relevance_.contains(canonical_site))
286 +- data.relevance_ = site_relevance_[canonical_site];
287 +- if (site_icons_.contains(canonical_site))
288 +- data.icon_ = site_icons_[canonical_site];
289 +-
290 +- SongInfoTextView* editor = new SongInfoTextView;
291 +- QString text;
292 +- // Add a link to the bio webpage at the top if we have one
293 +- if (!bio.url().isEmpty()) {
294 +- QString bio_url = bio.url().toEncoded();
295 +- if (bio.site() == "facebook") {
296 +- bio_url.replace("graph.facebook.com", "www.facebook.com");
297 +- }
298 +- text += "<p><a href=\"" + bio_url + "\">" +
299 +- tr("Open in your browser") + "</a></p>";
300 +- }
301 +-
302 +- text += bio.text();
303 +- if (bio.site() == "last.fm") {
304 +- // Echonest lost formatting and it seems there is currently no plans on
305 +- // Echonest side for changing this.
306 +- // But with last.fm, we can guess newlines: " " corresponds to a newline
307 +- // (this seems to be because on last.fm' website, extra blank is inserted
308 +- // before <br /> tag, and this blank is kept).
309 +- // This is tricky, but this make the display nicer for last.fm
310 +- // biographies.
311 +- text.replace(" ", "<p>");
312 +- }
313 +- editor->SetHtml(text);
314 +- data.contents_ = editor;
315 +-
316 +- emit InfoReady(request->id_, data);
317 +- }
318 +-
319 +- emit Finished(request->id_);
320 +-}
321 +--- Clementine-1.3.1/src/songinfo/echonestbiographies.h
322 ++++ Clementine-1.3.1/src/songinfo/echonestbiographies.h
323 +@@ -1,48 +0,0 @@
324 +-/* This file is part of Clementine.
325 +- Copyright 2010, David Sansome <me@××××××××××××.com>
326 +-
327 +- Clementine is free software: you can redistribute it and/or modify
328 +- it under the terms of the GNU General Public License as published by
329 +- the Free Software Foundation, either version 3 of the License, or
330 +- (at your option) any later version.
331 +-
332 +- Clementine is distributed in the hope that it will be useful,
333 +- but WITHOUT ANY WARRANTY; without even the implied warranty of
334 +- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
335 +- GNU General Public License for more details.
336 +-
337 +- You should have received a copy of the GNU General Public License
338 +- along with Clementine. If not, see <http://www.gnu.org/licenses/>.
339 +-*/
340 +-
341 +-#ifndef ECHONESTBIOGRAPHIES_H
342 +-#define ECHONESTBIOGRAPHIES_H
343 +-
344 +-#include <memory>
345 +-
346 +-#include "songinfoprovider.h"
347 +-
348 +-class QNetworkReply;
349 +-
350 +-class EchoNestBiographies : public SongInfoProvider {
351 +- Q_OBJECT
352 +-
353 +- public:
354 +- EchoNestBiographies();
355 +-
356 +- void FetchInfo(int id, const Song& metadata);
357 +-
358 +- private slots:
359 +- void RequestFinished();
360 +-
361 +- private:
362 +- QMap<QString, int> site_relevance_;
363 +- QMap<QString, QIcon> site_icons_;
364 +-
365 +- struct Request;
366 +- typedef std::shared_ptr<Request> RequestPtr;
367 +-
368 +- QMap<QNetworkReply*, RequestPtr> requests_;
369 +-};
370 +-
371 +-#endif // ECHONESTBIOGRAPHIES_H
372 +--- Clementine-1.3.1/src/songinfo/echonestsimilarartists.cpp
373 ++++ Clementine-1.3.1/src/songinfo/echonestsimilarartists.cpp
374 +@@ -1,76 +0,0 @@
375 +-/* This file is part of Clementine.
376 +- Copyright 2010, David Sansome <me@××××××××××××.com>
377 +-
378 +- Clementine is free software: you can redistribute it and/or modify
379 +- it under the terms of the GNU General Public License as published by
380 +- the Free Software Foundation, either version 3 of the License, or
381 +- (at your option) any later version.
382 +-
383 +- Clementine is distributed in the hope that it will be useful,
384 +- but WITHOUT ANY WARRANTY; without even the implied warranty of
385 +- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
386 +- GNU General Public License for more details.
387 +-
388 +- You should have received a copy of the GNU General Public License
389 +- along with Clementine. If not, see <http://www.gnu.org/licenses/>.
390 +-*/
391 +-
392 +-#include "echonestsimilarartists.h"
393 +-#include "tagwidget.h"
394 +-#include "core/logging.h"
395 +-#include "ui/iconloader.h"
396 +-
397 +-#include <echonest/Artist.h>
398 +-
399 +-Q_DECLARE_METATYPE(QVector<QString>);
400 +-
401 +-void EchoNestSimilarArtists::FetchInfo(int id, const Song& metadata) {
402 +- using Echonest::Artist;
403 +-
404 +- Artist::SearchParams params;
405 +- params << Artist::SearchParamEntry(Artist::Name, metadata.artist());
406 +- params << Artist::SearchParamEntry(Artist::MinHotttnesss, 0.5);
407 +-
408 +- QNetworkReply* reply = Echonest::Artist::fetchSimilar(params);
409 +- connect(reply, SIGNAL(finished()), SLOT(RequestFinished()));
410 +- requests_[reply] = id;
411 +-}
412 +-
413 +-void EchoNestSimilarArtists::RequestFinished() {
414 +- QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
415 +- if (!reply || !requests_.contains(reply)) return;
416 +- reply->deleteLater();
417 +-
418 +- int id = requests_.take(reply);
419 +-
420 +- Echonest::Artists artists;
421 +- try {
422 +- artists = Echonest::Artist::parseSimilar(reply);
423 +- }
424 +- catch (Echonest::ParseError e) {
425 +- qLog(Warning) << "Error parsing echonest reply:" << e.errorType()
426 +- << e.what();
427 +- }
428 +-
429 +- if (!artists.isEmpty()) {
430 +- CollapsibleInfoPane::Data data;
431 +- data.id_ = "echonest/similarartists";
432 +- data.title_ = tr("Similar artists");
433 +- data.type_ = CollapsibleInfoPane::Data::Type_Similar;
434 +- data.icon_ = IconLoader::Load("echonest", IconLoader::Provider);
435 +-
436 +- TagWidget* widget = new TagWidget(TagWidget::Type_Artists);
437 +- data.contents_ = widget;
438 +-
439 +- widget->SetIcon(IconLoader::Load("x-clementine-artist", IconLoader::Base));
440 +-
441 +- for (const Echonest::Artist& artist : artists) {
442 +- widget->AddTag(artist.name());
443 +- if (widget->count() >= 10) break;
444 +- }
445 +-
446 +- emit InfoReady(id, data);
447 +- }
448 +-
449 +- emit Finished(id);
450 +-}
451 +--- Clementine-1.3.1/src/songinfo/echonestsimilarartists.h
452 ++++ Clementine-1.3.1/src/songinfo/echonestsimilarartists.h
453 +@@ -1,38 +0,0 @@
454 +-/* This file is part of Clementine.
455 +- Copyright 2010, David Sansome <me@××××××××××××.com>
456 +-
457 +- Clementine is free software: you can redistribute it and/or modify
458 +- it under the terms of the GNU General Public License as published by
459 +- the Free Software Foundation, either version 3 of the License, or
460 +- (at your option) any later version.
461 +-
462 +- Clementine is distributed in the hope that it will be useful,
463 +- but WITHOUT ANY WARRANTY; without even the implied warranty of
464 +- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
465 +- GNU General Public License for more details.
466 +-
467 +- You should have received a copy of the GNU General Public License
468 +- along with Clementine. If not, see <http://www.gnu.org/licenses/>.
469 +-*/
470 +-
471 +-#ifndef ECHONESTSIMILARARTISTS_H
472 +-#define ECHONESTSIMILARARTISTS_H
473 +-
474 +-#include "songinfoprovider.h"
475 +-
476 +-class QNetworkReply;
477 +-
478 +-class EchoNestSimilarArtists : public SongInfoProvider {
479 +- Q_OBJECT
480 +-
481 +- public:
482 +- void FetchInfo(int id, const Song& metadata);
483 +-
484 +- private slots:
485 +- void RequestFinished();
486 +-
487 +- private:
488 +- QMap<QNetworkReply*, int> requests_;
489 +-};
490 +-
491 +-#endif // ECHONESTSIMILARARTISTS_H
492 +--- Clementine-1.3.1/src/songinfo/echonesttags.cpp
493 ++++ Clementine-1.3.1/src/songinfo/echonesttags.cpp
494 +@@ -1,80 +0,0 @@
495 +-/* This file is part of Clementine.
496 +- Copyright 2010, David Sansome <me@××××××××××××.com>
497 +-
498 +- Clementine is free software: you can redistribute it and/or modify
499 +- it under the terms of the GNU General Public License as published by
500 +- the Free Software Foundation, either version 3 of the License, or
501 +- (at your option) any later version.
502 +-
503 +- Clementine is distributed in the hope that it will be useful,
504 +- but WITHOUT ANY WARRANTY; without even the implied warranty of
505 +- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
506 +- GNU General Public License for more details.
507 +-
508 +- You should have received a copy of the GNU General Public License
509 +- along with Clementine. If not, see <http://www.gnu.org/licenses/>.
510 +-*/
511 +-
512 +-#include "echonesttags.h"
513 +-
514 +-#include <memory>
515 +-
516 +-#include <echonest/Artist.h>
517 +-
518 +-#include "tagwidget.h"
519 +-#include "core/logging.h"
520 +-#include "ui/iconloader.h"
521 +-
522 +-struct EchoNestTags::Request {
523 +- Request(int id) : id_(id), artist_(new Echonest::Artist) {}
524 +-
525 +- int id_;
526 +- std::unique_ptr<Echonest::Artist> artist_;
527 +-};
528 +-
529 +-void EchoNestTags::FetchInfo(int id, const Song& metadata) {
530 +- std::shared_ptr<Request> request(new Request(id));
531 +- request->artist_->setName(metadata.artist());
532 +-
533 +- QNetworkReply* reply = request->artist_->fetchTerms();
534 +- connect(reply, SIGNAL(finished()), SLOT(RequestFinished()));
535 +- requests_[reply] = request;
536 +-}
537 +-
538 +-void EchoNestTags::RequestFinished() {
539 +- QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
540 +- if (!reply || !requests_.contains(reply)) return;
541 +- reply->deleteLater();
542 +-
543 +- RequestPtr request = requests_.take(reply);
544 +-
545 +- try {
546 +- request->artist_->parseProfile(reply);
547 +- }
548 +- catch (Echonest::ParseError e) {
549 +- qLog(Warning) << "Error parsing echonest reply:" << e.errorType()
550 +- << e.what();
551 +- }
552 +-
553 +- if (!request->artist_->terms().isEmpty()) {
554 +- CollapsibleInfoPane::Data data;
555 +- data.id_ = "echonest/artisttags";
556 +- data.title_ = tr("Artist tags");
557 +- data.type_ = CollapsibleInfoPane::Data::Type_Tags;
558 +- data.icon_ = IconLoader::Load("icon_tag", IconLoader::Lastfm);
559 +-
560 +- TagWidget* widget = new TagWidget(TagWidget::Type_Tags);
561 +- data.contents_ = widget;
562 +-
563 +- widget->SetIcon(data.icon_);
564 +-
565 +- for (const Echonest::Term& term : request->artist_->terms()) {
566 +- widget->AddTag(term.name());
567 +- if (widget->count() >= 10) break;
568 +- }
569 +-
570 +- emit InfoReady(request->id_, data);
571 +- }
572 +-
573 +- emit Finished(request->id_);
574 +-}
575 +--- Clementine-1.3.1/src/songinfo/echonesttags.h
576 ++++ Clementine-1.3.1/src/songinfo/echonesttags.h
577 +@@ -1,43 +0,0 @@
578 +-/* This file is part of Clementine.
579 +- Copyright 2010, David Sansome <me@××××××××××××.com>
580 +-
581 +- Clementine is free software: you can redistribute it and/or modify
582 +- it under the terms of the GNU General Public License as published by
583 +- the Free Software Foundation, either version 3 of the License, or
584 +- (at your option) any later version.
585 +-
586 +- Clementine is distributed in the hope that it will be useful,
587 +- but WITHOUT ANY WARRANTY; without even the implied warranty of
588 +- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
589 +- GNU General Public License for more details.
590 +-
591 +- You should have received a copy of the GNU General Public License
592 +- along with Clementine. If not, see <http://www.gnu.org/licenses/>.
593 +-*/
594 +-
595 +-#ifndef ECHONESTTAGS_H
596 +-#define ECHONESTTAGS_H
597 +-
598 +-#include <memory>
599 +-
600 +-#include "songinfoprovider.h"
601 +-
602 +-class QNetworkReply;
603 +-
604 +-class EchoNestTags : public SongInfoProvider {
605 +- Q_OBJECT
606 +-
607 +- public:
608 +- void FetchInfo(int id, const Song& metadata);
609 +-
610 +- private slots:
611 +- void RequestFinished();
612 +-
613 +- private:
614 +- struct Request;
615 +- typedef std::shared_ptr<Request> RequestPtr;
616 +-
617 +- QMap<QNetworkReply*, RequestPtr> requests_;
618 +-};
619 +-
620 +-#endif // ECHONESTTAGS_H
621 +--- Clementine-1.3.1/src/songinfo/songkickconcerts.cpp
622 ++++ Clementine-1.3.1/src/songinfo/songkickconcerts.cpp
623 +@@ -21,9 +21,6 @@
624 + #include <QVBoxLayout>
625 + #include <QXmlStreamWriter>
626 +
627 +-#include <echonest/Artist.h>
628 +-#include <echonest/TypeInformation.h>
629 +-
630 + #include <qjson/parser.h>
631 +
632 + #include "core/closure.h"
633 +@@ -31,77 +28,64 @@
634 + #include "songkickconcertwidget.h"
635 + #include "ui/iconloader.h"
636 +
637 +-const char* SongkickConcerts::kSongkickArtistBucket = "songkick";
638 +-const char* SongkickConcerts::kSongkickArtistCalendarUrl =
639 +- "https://api.songkick.com/api/3.0/artists/%1/calendar.json?"
640 +- "per_page=5&"
641 +- "apikey=8rgKfy1WU6IlJFfN";
642 ++namespace {
643 ++const char* kSongkickArtistCalendarUrl =
644 ++ "https://api.songkick.com/api/3.0/artists/%1/calendar.json";
645 ++const char* kSongkickArtistSearchUrl =
646 ++ "https://api.songkick.com/api/3.0/search/artists.json";
647 ++const char* kSongkickApiKey = "8rgKfy1WU6IlJFfN";
648 ++} // namespace
649 +
650 + SongkickConcerts::SongkickConcerts() {
651 + Geolocator* geolocator = new Geolocator;
652 + geolocator->Geolocate();
653 + connect(geolocator, SIGNAL(Finished(Geolocator::LatLng)),
654 + SLOT(GeolocateFinished(Geolocator::LatLng)));
655 +- NewClosure(geolocator, SIGNAL(Finished(Geolocator::LatLng)), geolocator,
656 +- SLOT(deleteLater()));
657 ++ connect(geolocator, SIGNAL(Finished(Geolocator::LatLng)), geolocator,
658 ++ SLOT(deleteLater()));
659 + }
660 +
661 + void SongkickConcerts::FetchInfo(int id, const Song& metadata) {
662 +- Echonest::Artist::SearchParams params;
663 +- params.push_back(
664 +- qMakePair(Echonest::Artist::Name, QVariant(metadata.artist())));
665 +- qLog(Debug) << "Params:" << params;
666 +- QNetworkReply* reply = Echonest::Artist::search(
667 +- params,
668 +- Echonest::ArtistInformation(Echonest::ArtistInformation::NoInformation,
669 +- QStringList() << kSongkickArtistBucket));
670 +- qLog(Debug) << reply->request().url();
671 ++ if (metadata.artist().isEmpty()) {
672 ++ emit Finished(id);
673 ++ return;
674 ++ }
675 ++
676 ++ QUrl url(kSongkickArtistSearchUrl);
677 ++ url.addQueryItem("apikey", kSongkickApiKey);
678 ++ url.addQueryItem("query", metadata.artist());
679 ++
680 ++ QNetworkRequest request(url);
681 ++ QNetworkReply* reply = network_.get(request);
682 + NewClosure(reply, SIGNAL(finished()), this,
683 + SLOT(ArtistSearchFinished(QNetworkReply*, int)), reply, id);
684 + }
685 +
686 + void SongkickConcerts::ArtistSearchFinished(QNetworkReply* reply, int id) {
687 + reply->deleteLater();
688 +- try {
689 +- Echonest::Artists artists = Echonest::Artist::parseSearch(reply);
690 +- if (artists.isEmpty()) {
691 +- qLog(Debug) << "Failed to find artist in echonest";
692 +- emit Finished(id);
693 +- return;
694 +- }
695 +-
696 +- const Echonest::Artist& artist = artists[0];
697 +- const Echonest::ForeignIds& foreign_ids = artist.foreignIds();
698 +- QString songkick_id;
699 +- for (const Echonest::ForeignId& id : foreign_ids) {
700 +- if (id.catalog == "songkick") {
701 +- songkick_id = id.foreign_id;
702 +- break;
703 +- }
704 +- }
705 +-
706 +- if (songkick_id.isEmpty()) {
707 +- qLog(Debug) << "Failed to fetch songkick foreign id for artist";
708 +- emit Finished(id);
709 +- return;
710 +- }
711 +-
712 +- QStringList split = songkick_id.split(':');
713 +- if (split.count() != 3) {
714 +- qLog(Error) << "Weird songkick id";
715 +- emit Finished(id);
716 +- return;
717 +- }
718 +-
719 +- FetchSongkickCalendar(split[2], id);
720 +- } catch (Echonest::ParseError& e) {
721 +- qLog(Error) << "Error parsing echonest reply:" << e.errorType() << e.what();
722 ++
723 ++ QJson::Parser parser;
724 ++ QVariantMap json = parser.parse(reply).toMap();
725 ++
726 ++ QVariantMap results_page = json["resultsPage"].toMap();
727 ++ QVariantMap results = results_page["results"].toMap();
728 ++ QVariantList artists = results["artist"].toList();
729 ++
730 ++ if (artists.isEmpty()) {
731 + emit Finished(id);
732 ++ return;
733 + }
734 ++
735 ++ QVariantMap artist = artists.first().toMap();
736 ++ QString artist_id = artist["id"].toString();
737 ++
738 ++ FetchSongkickCalendar(artist_id, id);
739 + }
740 +
741 + void SongkickConcerts::FetchSongkickCalendar(const QString& artist_id, int id) {
742 + QUrl url(QString(kSongkickArtistCalendarUrl).arg(artist_id));
743 ++ url.addQueryItem("per_page", "5");
744 ++ url.addQueryItem("apikey", kSongkickApiKey);
745 + qLog(Debug) << url;
746 + QNetworkReply* reply = network_.get(QNetworkRequest(url));
747 + NewClosure(reply, SIGNAL(finished()), this,
748 +--- Clementine-1.3.1/src/songinfo/songkickconcerts.h
749 ++++ Clementine-1.3.1/src/songinfo/songkickconcerts.h
750 +@@ -44,9 +44,6 @@
751 +
752 + NetworkAccessManager network_;
753 + Geolocator::LatLng latlng_;
754 +-
755 +- static const char* kSongkickArtistBucket;
756 +- static const char* kSongkickArtistCalendarUrl;
757 + };
758 +
759 + #endif