/thirdparty/liblastfm2/src/types/Album.cpp

http://github.com/tomahawk-player/tomahawk · C++ · 87 lines · 58 code · 10 blank · 19 comment · 4 complexity · 5fd92f90bf52c506e44e8f504759f698 MD5 · raw file

  1. /*
  2. Copyright 2009-2010 Last.fm Ltd.
  3. - Primarily authored by Max Howell, Jono Cole and Doug Mansell
  4. This file is part of liblastfm.
  5. liblastfm is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. liblastfm is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with liblastfm. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include "Album.h"
  17. #include "Artist.h"
  18. #include "User.h"
  19. #include "../core/UrlBuilder.h"
  20. #include "../core/XmlQuery.h"
  21. #include "../ws/ws.h"
  22. #include <QFile>
  23. #include <QStringList>
  24. #include <QTimer>
  25. QNetworkReply*
  26. lastfm::Album::getInfo() const
  27. {
  28. QMap<QString, QString> map;
  29. map["method"] = "album.getInfo";
  30. map["artist"] = m_artist;
  31. map["album"] = m_title;
  32. if (!lastfm::ws::Username.isEmpty()) map["username"] = lastfm::ws::Username;
  33. if (!lastfm::ws::SessionKey.isEmpty()) map["sk"] = lastfm::ws::SessionKey;
  34. return lastfm::ws::get(map);
  35. }
  36. QNetworkReply*
  37. lastfm::Album::getTags() const
  38. {
  39. QMap<QString, QString> map;
  40. map["method"] = "album.getTags";
  41. map["artist"] = m_artist;
  42. map["album"] = m_title;
  43. return lastfm::ws::get(map);
  44. }
  45. QNetworkReply*
  46. lastfm::Album::share( const QStringList& recipients, const QString& message, bool isPublic ) const
  47. {
  48. QMap<QString, QString> map;
  49. map["method"] = "album.share";
  50. map["artist"] = m_artist;
  51. map["album"] = m_title;
  52. map["recipient"] = recipients.join(",");
  53. map["public"] = isPublic ? "1" : "0";
  54. if (message.size()) map["message"] = message;
  55. return lastfm::ws::post(map);
  56. }
  57. QUrl
  58. lastfm::Album::www() const
  59. {
  60. return lastfm::UrlBuilder( "music" ).slash( m_artist ).slash( m_title ).url();
  61. }
  62. QNetworkReply*
  63. lastfm::Album::addTags( const QStringList& tags ) const
  64. {
  65. if (tags.isEmpty())
  66. return 0;
  67. QMap<QString, QString> map;
  68. map["method"] = "album.addTags";
  69. map["artist"] = m_artist;
  70. map["album"] = m_title;
  71. map["tags"] = tags.join( QChar(',') );
  72. return lastfm::ws::post(map);
  73. }