2021-07-11 01:02:53 +02:00
|
|
|
/*
|
|
|
|
* Strawberry Music Player
|
|
|
|
* Copyright 2021, Jonas Kvinge <jonas@jkvinge.net>
|
|
|
|
*
|
|
|
|
* Strawberry is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Strawberry is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QVariant>
|
|
|
|
#include <QUrl>
|
|
|
|
|
|
|
|
#include "radioplaylistitem.h"
|
2022-05-13 18:15:04 +02:00
|
|
|
#include "core/sqlrow.h"
|
2021-07-11 01:02:53 +02:00
|
|
|
|
|
|
|
RadioPlaylistItem::RadioPlaylistItem(const Song::Source source)
|
|
|
|
: PlaylistItem(source), source_(source) {}
|
|
|
|
|
|
|
|
RadioPlaylistItem::RadioPlaylistItem(const Song &metadata)
|
|
|
|
: PlaylistItem(metadata.source()),
|
|
|
|
source_(metadata.source()),
|
|
|
|
metadata_(metadata) {
|
|
|
|
InitMetadata();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RadioPlaylistItem::InitFromQuery(const SqlRow &query) {
|
|
|
|
|
2021-11-09 19:34:20 +01:00
|
|
|
metadata_.InitFromQuery(query, false);
|
2021-07-11 01:02:53 +02:00
|
|
|
InitMetadata();
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
QVariant RadioPlaylistItem::DatabaseValue(DatabaseColumn column) const {
|
2021-07-11 09:49:38 +02:00
|
|
|
return PlaylistItem::DatabaseValue(column);
|
2021-07-11 01:02:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void RadioPlaylistItem::InitMetadata() {
|
|
|
|
|
|
|
|
if (metadata_.title().isEmpty()) metadata_.set_title(metadata_.url().toString());
|
2023-02-18 14:09:27 +01:00
|
|
|
if (metadata_.source() == Song::Source::Unknown) metadata_.set_source(Song::Source::Stream);
|
|
|
|
if (metadata_.filetype() == Song::FileType::Unknown) metadata_.set_filetype(Song::FileType::Stream);
|
2021-07-11 01:02:53 +02:00
|
|
|
metadata_.set_valid(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Song RadioPlaylistItem::Metadata() const {
|
|
|
|
|
|
|
|
if (HasTemporaryMetadata()) return temp_metadata_;
|
|
|
|
return metadata_;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
QUrl RadioPlaylistItem::Url() const { return metadata_.url(); }
|
|
|
|
|
|
|
|
void RadioPlaylistItem::SetArtManual(const QUrl &cover_url) {
|
|
|
|
|
|
|
|
metadata_.set_art_manual(cover_url);
|
|
|
|
temp_metadata_.set_art_manual(cover_url);
|
|
|
|
|
|
|
|
}
|