PageRenderTime 102ms CodeModel.GetById 40ms app.highlight 5ms RepoModel.GetById 56ms app.codeStats 0ms

/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
 5   This file is part of liblastfm.
 6
 7   liblastfm is free software: you can redistribute it and/or modify
 8   it under the terms of the GNU General Public License as published by
 9   the Free Software Foundation, either version 3 of the License, or
10   (at your option) any later version.
11
12   liblastfm is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   GNU General Public License for more details.
16
17   You should have received a copy of the GNU General Public License
18   along with liblastfm.  If not, see <http://www.gnu.org/licenses/>.
19*/
20#include "Playlist.h"
21#include "Track.h"
22#include "../ws/ws.h"
23
24
25QNetworkReply*
26lastfm::Playlist::addTrack( const Track& t ) const
27{
28    QMap<QString, QString> map;
29    map["method"] = "playlist.addTrack";
30    map["playlistID"] = m_id;
31    map["artist"] = t.artist();
32    map["track"] = t.title();
33    return lastfm::ws::post(map);
34}
35
36
37QNetworkReply*
38lastfm::Playlist::fetch() const
39{
40    return fetch( QUrl("lastfm://playlist/" + QString::number( m_id )) );
41}
42
43
44QNetworkReply* //static
45lastfm::Playlist::fetch( const QUrl& url )
46{
47    QMap<QString, QString> map;
48    map["method"] = "playlist.fetch";
49    map["playlistURL"] = url.toString();
50    return lastfm::ws::get(map);
51}
52
53
54QNetworkReply* //static
55lastfm::Playlist::create( const QString& title, const QString& description /*=""*/ )
56{
57    QMap<QString, QString> map;
58    map["method"] = "playlist.create";
59    map["title"] = title;
60    if (description.size()) 
61        map["description"] = description;
62    return lastfm::ws::post(map);
63}