/thirdparty/liblastfm2/src/radio/RadioStation.h

http://github.com/tomahawk-player/tomahawk · C Header · 123 lines · 71 code · 24 blank · 28 comment · 0 complexity · 09a04b3b4e08b7b4a8d306b7a508f925 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. #ifndef LASTFM_RADIO_STATION_H
  17. #define LASTFM_RADIO_STATION_H
  18. #include <lastfm/User>
  19. #include <lastfm/Tag>
  20. #include <lastfm/Artist>
  21. namespace lastfm
  22. {
  23. /** @author <jono@last.fm>
  24. */
  25. class LASTFM_DLLEXPORT RadioStation
  26. {
  27. public:
  28. RadioStation()
  29. {}
  30. RadioStation( const QString& s )
  31. {
  32. setString( s );
  33. }
  34. static RadioStation library( const lastfm::User& user );
  35. static RadioStation library( QList<lastfm::User>& users );
  36. static RadioStation similar( const lastfm::Artist& artist );
  37. static RadioStation similar( QList<lastfm::Artist>& artist );
  38. static RadioStation tag( const lastfm::Tag& tag );
  39. static RadioStation tag( QList<lastfm::Tag>& tag );
  40. static RadioStation recommendations( const lastfm::User& user );
  41. static RadioStation friends( const lastfm::User& user );
  42. static RadioStation neighbourhood( const lastfm::User& user );
  43. static RadioStation mix( const lastfm::User& user );
  44. QNetworkReply* getSampleArtists( int limit = 50 ) const;
  45. QNetworkReply* getTagSuggestions( int limit = 50 ) const;
  46. /** eg. "mxcl's Loved Tracks"
  47. * It is worth noting that the Radio doesn't set the title of RadioStation
  48. * object until we have tuned to it, and then we only set the one we give
  49. * you back.
  50. */
  51. QString title() const;
  52. /** the Last.fm url, eg. lastfm://user/mxcl/loved */
  53. QString url() const;
  54. void setTitle( const QString& title );
  55. void setTagFilter( const QString& tag );
  56. void setRep(float rep);
  57. void setMainstr(float mainstr);
  58. void setDisco(bool disco);
  59. float rep() const;
  60. float mainstr() const;
  61. bool disco() const;
  62. bool isLegacyPlaylist() const
  63. {
  64. return m_url.toString().startsWith( "lastfm://play/" ) ||
  65. m_url.toString().startsWith( "lastfm://preview/" ) ||
  66. m_url.toString().startsWith( "lastfm://track/" ) ||
  67. m_url.toString().startsWith( "lastfm://playlist/" );
  68. }
  69. // good for getRecentStations:
  70. static QList<RadioStation> list( QNetworkReply* );
  71. bool operator==( const RadioStation& that ) const;
  72. private:
  73. void setString( const QString& s );
  74. static QString libraryStr( QList<lastfm::User>& user );
  75. static QString recommendationsStr( const lastfm::User& user ) { return "lastfm://user/" + user + "/recommended"; }
  76. static QString friendsStr( const lastfm::User& user ) { return "lastfm://user/" + user + "/friends"; }
  77. static QString neighbourhoodStr( const lastfm::User& user ) { return "lastfm://user/" + user + "/neighbours"; }
  78. static QString tagStr( QList<lastfm::Tag>& tag );
  79. static QString similarStr( QList<lastfm::Artist>& artist );
  80. static QString mixStr( const lastfm::User& user ) { return "lastfm://user/" + user + "/mix"; }
  81. private:
  82. QUrl m_url;
  83. QString m_title;
  84. QString m_tagFilter;
  85. float m_rep;
  86. float m_mainstr;
  87. bool m_disco;
  88. };
  89. }
  90. Q_DECLARE_METATYPE( lastfm::RadioStation )
  91. inline QDebug operator<<( QDebug d, const lastfm::RadioStation& station )
  92. {
  93. return d << station.url();
  94. }
  95. #endif