Clementine Remote can now download all urls that are in the library.
This commit is contained in:
parent
c04eb3da19
commit
24481ae7bc
|
@ -243,10 +243,12 @@ enum DownloadItem {
|
|||
CurrentItem = 1;
|
||||
ItemAlbum = 2;
|
||||
APlaylist = 3;
|
||||
Urls = 4;
|
||||
}
|
||||
message RequestDownloadSongs {
|
||||
optional DownloadItem download_item = 1;
|
||||
optional int32 playlist_id = 2;
|
||||
repeated string urls = 3;
|
||||
}
|
||||
|
||||
message ResponseSongFileChunk {
|
||||
|
@ -278,7 +280,7 @@ message RequestRateSong {
|
|||
|
||||
// The message itself
|
||||
message Message {
|
||||
optional int32 version = 1 [default=14];
|
||||
optional int32 version = 1 [default=15];
|
||||
optional MsgType type = 2 [default=UNKNOWN]; // What data is in the message?
|
||||
|
||||
optional RequestConnect request_connect = 21;
|
||||
|
|
|
@ -588,6 +588,9 @@ void OutgoingDataCreator::SendSongs(
|
|||
case pb::remote::APlaylist:
|
||||
SendPlaylist(client, request.playlist_id());
|
||||
break;
|
||||
case pb::remote::Urls:
|
||||
SendUrls(client, request);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -737,6 +740,29 @@ void OutgoingDataCreator::SendPlaylist(RemoteClient* client, int playlist_id) {
|
|||
}
|
||||
}
|
||||
|
||||
void OutgoingDataCreator::SendUrls(RemoteClient *client,
|
||||
const pb::remote::RequestDownloadSongs &request) {
|
||||
SongList song_list;
|
||||
|
||||
// First gather all valid songs
|
||||
for (auto it = request.urls().begin(); it != request.urls().end(); ++it) {
|
||||
std::string s = *it;
|
||||
QUrl url = QUrl(QStringFromStdString(s));
|
||||
|
||||
Song song = app_->library_backend()->GetSongByUrl(url);
|
||||
|
||||
if (song.is_valid() && song.url().scheme() == "file") {
|
||||
song_list.append(song);
|
||||
}
|
||||
}
|
||||
|
||||
// Then send them to Clementine Remote
|
||||
for (Song s : song_list) {
|
||||
DownloadItem item(s, song_list.indexOf(s) + 1, song_list.count());
|
||||
download_queue_[client].append(item);
|
||||
}
|
||||
}
|
||||
|
||||
void OutgoingDataCreator::SendLibrary(RemoteClient* client) {
|
||||
// Get a temporary file name
|
||||
QString temp_file_name = Utilities::GetTemporaryFileName();
|
||||
|
|
|
@ -107,6 +107,7 @@ class OutgoingDataCreator : public QObject {
|
|||
int song_count);
|
||||
void SendAlbum(RemoteClient* client, const Song& song);
|
||||
void SendPlaylist(RemoteClient* client, int playlist_id);
|
||||
void SendUrls(RemoteClient* client, const pb::remote::RequestDownloadSongs& request);
|
||||
void OfferNextSong(RemoteClient* client);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue