Organize: Only load embedded cover if the destination is a device
This commit is contained in:
@@ -33,6 +33,7 @@
|
|||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
#include <QImage>
|
||||||
|
|
||||||
#include "song.h"
|
#include "song.h"
|
||||||
|
|
||||||
@@ -67,6 +68,7 @@ class MusicStorage {
|
|||||||
bool albumcover_;
|
bool albumcover_;
|
||||||
QString cover_source_;
|
QString cover_source_;
|
||||||
QString cover_dest_;
|
QString cover_dest_;
|
||||||
|
QImage cover_image_;
|
||||||
ProgressFunction progress_;
|
ProgressFunction progress_;
|
||||||
QString playlist_;
|
QString playlist_;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -44,7 +44,6 @@
|
|||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QImage>
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
|
||||||
@@ -224,7 +223,6 @@ struct Song::Private : public QSharedData {
|
|||||||
float rating_; // Database rating, initial rating read from tag.
|
float rating_; // Database rating, initial rating read from tag.
|
||||||
|
|
||||||
QUrl stream_url_; // Temporary stream url set by url handler.
|
QUrl stream_url_; // Temporary stream url set by url handler.
|
||||||
QImage image_; // Album Cover image set by album cover loader.
|
|
||||||
bool init_from_file_; // Whether this song was loaded from a file using taglib.
|
bool init_from_file_; // Whether this song was loaded from a file using taglib.
|
||||||
bool suspicious_tags_; // Whether our encoding guesser thinks these tags might be incorrectly encoded.
|
bool suspicious_tags_; // Whether our encoding guesser thinks these tags might be incorrectly encoded.
|
||||||
|
|
||||||
@@ -365,7 +363,6 @@ bool Song::save_embedded_cover_supported(const FileType filetype) {
|
|||||||
|
|
||||||
const QUrl &Song::stream_url() const { return d->stream_url_; }
|
const QUrl &Song::stream_url() const { return d->stream_url_; }
|
||||||
const QUrl &Song::effective_stream_url() const { return !d->stream_url_.isEmpty() && d->stream_url_.isValid() ? d->stream_url_ : d->url_; }
|
const QUrl &Song::effective_stream_url() const { return !d->stream_url_.isEmpty() && d->stream_url_.isValid() ? d->stream_url_ : d->url_; }
|
||||||
const QImage &Song::image() const { return d->image_; }
|
|
||||||
bool Song::init_from_file() const { return d->init_from_file_; }
|
bool Song::init_from_file() const { return d->init_from_file_; }
|
||||||
|
|
||||||
const QString &Song::cue_path() const { return d->cue_path_; }
|
const QString &Song::cue_path() const { return d->cue_path_; }
|
||||||
@@ -479,7 +476,6 @@ void Song::set_cue_path(const QString &v) { d->cue_path_ = v; }
|
|||||||
void Song::set_rating(const float v) { d->rating_ = v; }
|
void Song::set_rating(const float v) { d->rating_ = v; }
|
||||||
|
|
||||||
void Song::set_stream_url(const QUrl &v) { d->stream_url_ = v; }
|
void Song::set_stream_url(const QUrl &v) { d->stream_url_ = v; }
|
||||||
void Song::set_image(const QImage &i) { d->image_ = i; }
|
|
||||||
|
|
||||||
QString Song::JoinSpec(const QString &table) {
|
QString Song::JoinSpec(const QString &table) {
|
||||||
return Utilities::Prepend(table + ".", kColumns).join(", ");
|
return Utilities::Prepend(table + ".", kColumns).join(", ");
|
||||||
|
|||||||
@@ -37,7 +37,6 @@
|
|||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QImage>
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
|
||||||
class SqlQuery;
|
class SqlQuery;
|
||||||
@@ -301,7 +300,6 @@ class Song {
|
|||||||
|
|
||||||
const QUrl &stream_url() const;
|
const QUrl &stream_url() const;
|
||||||
const QUrl &effective_stream_url() const;
|
const QUrl &effective_stream_url() const;
|
||||||
const QImage &image() const;
|
|
||||||
bool init_from_file() const;
|
bool init_from_file() const;
|
||||||
|
|
||||||
// Pretty accessors
|
// Pretty accessors
|
||||||
@@ -380,7 +378,6 @@ class Song {
|
|||||||
void set_rating(const float v);
|
void set_rating(const float v);
|
||||||
|
|
||||||
void set_stream_url(const QUrl &v);
|
void set_stream_url(const QUrl &v);
|
||||||
void set_image(const QImage &i);
|
|
||||||
|
|
||||||
// Comparison functions
|
// Comparison functions
|
||||||
bool IsMetadataEqual(const Song &other) const;
|
bool IsMetadataEqual(const Song &other) const;
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ bool GPodDevice::CopyToStorage(const CopyJob &job) {
|
|||||||
|
|
||||||
if (job.albumcover_) {
|
if (job.albumcover_) {
|
||||||
bool result = false;
|
bool result = false;
|
||||||
if (!job.metadata_.image().isNull()) {
|
if (!job.cover_image_.isNull()) {
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef Q_OS_LINUX
|
||||||
QString temp_path = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/organize";
|
QString temp_path = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/organize";
|
||||||
#else
|
#else
|
||||||
@@ -201,7 +201,7 @@ bool GPodDevice::CopyToStorage(const CopyJob &job) {
|
|||||||
cover_file->setAutoRemove(true);
|
cover_file->setAutoRemove(true);
|
||||||
if (cover_file->open()) {
|
if (cover_file->open()) {
|
||||||
cover_file->close();
|
cover_file->close();
|
||||||
QImage image = job.metadata_.image();
|
const QImage &image = job.cover_image_;
|
||||||
if (image.save(cover_file->fileName(), "JPG")) {
|
if (image.save(cover_file->fileName(), "JPG")) {
|
||||||
const QByteArray filename = QFile::encodeName(cover_file->fileName());
|
const QByteArray filename = QFile::encodeName(cover_file->fileName());
|
||||||
result = itdb_track_set_thumbnails(track, filename.constData());
|
result = itdb_track_set_thumbnails(track, filename.constData());
|
||||||
|
|||||||
@@ -174,10 +174,6 @@ void Organize::ProcessSomeFiles() {
|
|||||||
Song song = task.song_info_.song_;
|
Song song = task.song_info_.song_;
|
||||||
if (!song.is_valid()) continue;
|
if (!song.is_valid()) continue;
|
||||||
|
|
||||||
// Get embedded album cover
|
|
||||||
QImage cover = TagReaderClient::Instance()->LoadEmbeddedArtAsImageBlocking(task.song_info_.song_.url().toLocalFile());
|
|
||||||
if (!cover.isNull()) song.set_image(cover);
|
|
||||||
|
|
||||||
#ifdef HAVE_GSTREAMER
|
#ifdef HAVE_GSTREAMER
|
||||||
// Maybe this file is one that's been transcoded already?
|
// Maybe this file is one that's been transcoded already?
|
||||||
if (!task.transcoded_filename_.isEmpty()) {
|
if (!task.transcoded_filename_.isEmpty()) {
|
||||||
@@ -242,6 +238,10 @@ void Organize::ProcessSomeFiles() {
|
|||||||
job.cover_source_ = task.song_info_.song_.art_automatic().path();
|
job.cover_source_ = task.song_info_.song_.art_automatic().path();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (destination_->source() == Song::Source_Device) {
|
||||||
|
job.cover_image_ = TagReaderClient::Instance()->LoadEmbeddedArtAsImageBlocking(task.song_info_.song_.url().toLocalFile());
|
||||||
|
}
|
||||||
|
|
||||||
if (!job.cover_source_.isEmpty()) {
|
if (!job.cover_source_.isEmpty()) {
|
||||||
job.cover_dest_ = QFileInfo(job.destination_).path() + "/" + QFileInfo(job.cover_source_).fileName();
|
job.cover_dest_ = QFileInfo(job.destination_).path() + "/" + QFileInfo(job.cover_source_).fileName();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user