/thirdparty/liblastfm2/src/types/Playlist.cpp

http://github.com/tomahawk-player/tomahawk · C++ · 63 lines · 36 code · 8 blank · 19 comment · 1 complexity · b3cb000789441e03fbae98ae4534eff5 MD5 · raw file

  1. /*
  2. Copyright 2009 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 "Playlist.h"
  17. #include "Track.h"
  18. #include "../ws/ws.h"
  19. QNetworkReply*
  20. lastfm::Playlist::addTrack( const Track& t ) const
  21. {
  22. QMap<QString, QString> map;
  23. map["method"] = "playlist.addTrack";
  24. map["playlistID"] = m_id;
  25. map["artist"] = t.artist();
  26. map["track"] = t.title();
  27. return lastfm::ws::post(map);
  28. }
  29. QNetworkReply*
  30. lastfm::Playlist::fetch() const
  31. {
  32. return fetch( QUrl("lastfm://playlist/" + QString::number( m_id )) );
  33. }
  34. QNetworkReply* //static
  35. lastfm::Playlist::fetch( const QUrl& url )
  36. {
  37. QMap<QString, QString> map;
  38. map["method"] = "playlist.fetch";
  39. map["playlistURL"] = url.toString();
  40. return lastfm::ws::get(map);
  41. }
  42. QNetworkReply* //static
  43. lastfm::Playlist::create( const QString& title, const QString& description /*=""*/ )
  44. {
  45. QMap<QString, QString> map;
  46. map["method"] = "playlist.create";
  47. map["title"] = title;
  48. if (description.size())
  49. map["description"] = description;
  50. return lastfm::ws::post(map);
  51. }