parent
fee63891ac
commit
fac4ad5313
@ -146,7 +146,6 @@ const QString Song::kEmbeddedCover = "(embedded)";
|
|||||||
const QRegularExpression Song::kAlbumRemoveDisc(" ?-? ((\\(|\\[)?)(Disc|CD) ?([0-9]{1,2})((\\)|\\])?)$", QRegularExpression::CaseInsensitiveOption);
|
const QRegularExpression Song::kAlbumRemoveDisc(" ?-? ((\\(|\\[)?)(Disc|CD) ?([0-9]{1,2})((\\)|\\])?)$", QRegularExpression::CaseInsensitiveOption);
|
||||||
const QRegularExpression Song::kAlbumRemoveMisc(" ?-? ((\\(|\\[)?)(Remastered|([0-9]{1,4}) *Remaster|Explicit) ?((\\)|\\])?)$", QRegularExpression::CaseInsensitiveOption);
|
const QRegularExpression Song::kAlbumRemoveMisc(" ?-? ((\\(|\\[)?)(Remastered|([0-9]{1,4}) *Remaster|Explicit) ?((\\)|\\])?)$", QRegularExpression::CaseInsensitiveOption);
|
||||||
const QRegularExpression Song::kTitleRemoveMisc(" ?-? ((\\(|\\[)?)(Remastered|Remastered Version|([0-9]{1,4}) *Remaster) ?((\\)|\\])?)$", QRegularExpression::CaseInsensitiveOption);
|
const QRegularExpression Song::kTitleRemoveMisc(" ?-? ((\\(|\\[)?)(Remastered|Remastered Version|([0-9]{1,4}) *Remaster) ?((\\)|\\])?)$", QRegularExpression::CaseInsensitiveOption);
|
||||||
const QString Song::kVariousArtists("various artists");
|
|
||||||
|
|
||||||
const QStringList Song::kArticles = QStringList() << "the " << "a " << "an ";
|
const QStringList Song::kArticles = QStringList() << "the " << "a " << "an ";
|
||||||
|
|
||||||
|
@ -132,8 +132,6 @@ class Song {
|
|||||||
static const QRegularExpression kAlbumRemoveMisc;
|
static const QRegularExpression kAlbumRemoveMisc;
|
||||||
static const QRegularExpression kTitleRemoveMisc;
|
static const QRegularExpression kTitleRemoveMisc;
|
||||||
|
|
||||||
static const QString kVariousArtists;
|
|
||||||
|
|
||||||
static const QStringList kArticles;
|
static const QStringList kArticles;
|
||||||
|
|
||||||
static const QStringList kAcceptedExtensions;
|
static const QStringList kAcceptedExtensions;
|
||||||
|
@ -430,20 +430,21 @@ void ListenBrainzScrobbler::UpdateNowPlaying(const Song &song) {
|
|||||||
QString album = song.album();
|
QString album = song.album();
|
||||||
QString title = song.title();
|
QString title = song.title();
|
||||||
|
|
||||||
album = album.remove(Song::kAlbumRemoveDisc);
|
album = album.remove(Song::kAlbumRemoveDisc)
|
||||||
album = album.remove(Song::kAlbumRemoveMisc);
|
.remove(Song::kAlbumRemoveMisc);
|
||||||
title = title.remove(Song::kTitleRemoveMisc);
|
title = title.remove(Song::kTitleRemoveMisc);
|
||||||
|
|
||||||
QJsonObject object_track_metadata;
|
QJsonObject object_track_metadata;
|
||||||
if (!prefer_albumartist_ || song.albumartist().isEmpty() || song.albumartist().compare(Song::kVariousArtists, Qt::CaseInsensitive) == 0) {
|
if (!prefer_albumartist_ || song.albumartist().isEmpty()) {
|
||||||
object_track_metadata.insert("artist_name", QJsonValue::fromVariant(song.artist()));
|
object_track_metadata.insert("artist_name", QJsonValue::fromVariant(song.artist()));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
object_track_metadata.insert("artist_name", QJsonValue::fromVariant(song.albumartist()));
|
object_track_metadata.insert("artist_name", QJsonValue::fromVariant(song.albumartist()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!album.isEmpty())
|
if (!album.isEmpty()) {
|
||||||
object_track_metadata.insert("release_name", QJsonValue::fromVariant(album));
|
object_track_metadata.insert("release_name", QJsonValue::fromVariant(album));
|
||||||
|
}
|
||||||
|
|
||||||
object_track_metadata.insert("track_name", QJsonValue::fromVariant(title));
|
object_track_metadata.insert("track_name", QJsonValue::fromVariant(title));
|
||||||
|
|
||||||
@ -573,7 +574,7 @@ void ListenBrainzScrobbler::Submit() {
|
|||||||
QJsonObject object_listen;
|
QJsonObject object_listen;
|
||||||
object_listen.insert("listened_at", QJsonValue::fromVariant(item->timestamp_));
|
object_listen.insert("listened_at", QJsonValue::fromVariant(item->timestamp_));
|
||||||
QJsonObject object_track_metadata;
|
QJsonObject object_track_metadata;
|
||||||
if (!prefer_albumartist_ || item->albumartist_.isEmpty() || item->albumartist_.compare(Song::kVariousArtists, Qt::CaseInsensitive) == 0) {
|
if (!prefer_albumartist_ || item->albumartist_.isEmpty()) {
|
||||||
object_track_metadata.insert("artist_name", QJsonValue::fromVariant(item->artist_));
|
object_track_metadata.insert("artist_name", QJsonValue::fromVariant(item->artist_));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -205,8 +205,8 @@ ScrobblerCacheItemPtr ScrobblerCache::Add(const Song &song, const quint64 timest
|
|||||||
QString album = song.album();
|
QString album = song.album();
|
||||||
QString title = song.title();
|
QString title = song.title();
|
||||||
|
|
||||||
album.remove(Song::kAlbumRemoveDisc);
|
album.remove(Song::kAlbumRemoveDisc)
|
||||||
album.remove(Song::kAlbumRemoveMisc);
|
.remove(Song::kAlbumRemoveMisc);
|
||||||
title.remove(Song::kTitleRemoveMisc);
|
title.remove(Song::kTitleRemoveMisc);
|
||||||
|
|
||||||
ScrobblerCacheItemPtr item = std::make_shared<ScrobblerCacheItem>(song.artist(), album, title, song.albumartist(), song.track(), song.length_nanosec(), timestamp);
|
ScrobblerCacheItemPtr item = std::make_shared<ScrobblerCacheItem>(song.artist(), album, title, song.albumartist(), song.track(), song.length_nanosec(), timestamp);
|
||||||
|
@ -28,15 +28,13 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include "core/song.h"
|
|
||||||
|
|
||||||
class ScrobblerCacheItem : public QObject {
|
class ScrobblerCacheItem : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ScrobblerCacheItem(const QString &artist, const QString &album, const QString &song, const QString &albumartist, const int track, const qint64 duration, const quint64 timestamp, QObject *parent = nullptr);
|
explicit ScrobblerCacheItem(const QString &artist, const QString &album, const QString &song, const QString &albumartist, const int track, const qint64 duration, const quint64 timestamp, QObject *parent = nullptr);
|
||||||
|
|
||||||
QString effective_albumartist() const { return albumartist_.isEmpty() || albumartist_.compare(Song::kVariousArtists, Qt::CaseInsensitive) == 0 ? artist_ : albumartist_; }
|
QString effective_albumartist() const { return albumartist_.isEmpty() ? artist_ : albumartist_; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString artist_;
|
QString artist_;
|
||||||
|
@ -454,20 +454,20 @@ void ScrobblingAPI20::UpdateNowPlaying(const Song &song) {
|
|||||||
QString album = song.album();
|
QString album = song.album();
|
||||||
QString title = song.title();
|
QString title = song.title();
|
||||||
|
|
||||||
album = album.remove(Song::kAlbumRemoveDisc);
|
album = album.remove(Song::kAlbumRemoveDisc)
|
||||||
album = album.remove(Song::kAlbumRemoveMisc);
|
.remove(Song::kAlbumRemoveMisc);
|
||||||
title = title.remove(Song::kTitleRemoveMisc);
|
title = title.remove(Song::kTitleRemoveMisc);
|
||||||
|
|
||||||
ParamList params = ParamList()
|
ParamList params = ParamList()
|
||||||
<< Param("method", "track.updateNowPlaying")
|
<< Param("method", "track.updateNowPlaying")
|
||||||
<< Param("artist", prefer_albumartist_ && song.effective_albumartist() != Song::kVariousArtists ? song.effective_albumartist() : song.artist())
|
<< Param("artist", prefer_albumartist_ ? song.effective_albumartist() : song.artist())
|
||||||
<< Param("track", title);
|
<< Param("track", title);
|
||||||
|
|
||||||
if (!album.isEmpty()) {
|
if (!album.isEmpty()) {
|
||||||
params << Param("album", album);
|
params << Param("album", album);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!prefer_albumartist_ && !song.albumartist().isEmpty() && song.albumartist().compare(Song::kVariousArtists, Qt::CaseInsensitive) != 0) {
|
if (!prefer_albumartist_ && !song.albumartist().isEmpty()) {
|
||||||
params << Param("albumArtist", song.albumartist());
|
params << Param("albumArtist", song.albumartist());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -582,7 +582,7 @@ void ScrobblingAPI20::Submit() {
|
|||||||
if (!item->album_.isEmpty()) {
|
if (!item->album_.isEmpty()) {
|
||||||
params << Param(QString("%1[%2]").arg("album").arg(i), item->album_);
|
params << Param(QString("%1[%2]").arg("album").arg(i), item->album_);
|
||||||
}
|
}
|
||||||
if (!prefer_albumartist_ && !item->albumartist_.isEmpty() && item->albumartist_.compare(Song::kVariousArtists, Qt::CaseInsensitive) != 0) {
|
if (!prefer_albumartist_ && !item->albumartist_.isEmpty()) {
|
||||||
params << Param(QString("%1[%2]").arg("albumArtist").arg(i), item->albumartist_);
|
params << Param(QString("%1[%2]").arg("albumArtist").arg(i), item->albumartist_);
|
||||||
}
|
}
|
||||||
if (item->track_ > 0) {
|
if (item->track_ > 0) {
|
||||||
@ -790,7 +790,7 @@ void ScrobblingAPI20::SendSingleScrobble(ScrobblerCacheItemPtr item) {
|
|||||||
if (!item->album_.isEmpty()) {
|
if (!item->album_.isEmpty()) {
|
||||||
params << Param("album", item->album_);
|
params << Param("album", item->album_);
|
||||||
}
|
}
|
||||||
if (!prefer_albumartist_ && !item->albumartist_.isEmpty() && item->albumartist_.compare(Song::kVariousArtists, Qt::CaseInsensitive) != 0) {
|
if (!prefer_albumartist_ && !item->albumartist_.isEmpty()) {
|
||||||
params << Param("albumArtist", item->albumartist_);
|
params << Param("albumArtist", item->albumartist_);
|
||||||
}
|
}
|
||||||
if (item->track_ > 0) {
|
if (item->track_ > 0) {
|
||||||
@ -939,14 +939,16 @@ void ScrobblingAPI20::Love() {
|
|||||||
|
|
||||||
ParamList params = ParamList()
|
ParamList params = ParamList()
|
||||||
<< Param("method", "track.love")
|
<< Param("method", "track.love")
|
||||||
<< Param("artist", prefer_albumartist_ && song_playing_.effective_albumartist() != Song::kVariousArtists ? song_playing_.effective_albumartist() : song_playing_.artist())
|
<< Param("artist", prefer_albumartist_ ? song_playing_.effective_albumartist() : song_playing_.artist())
|
||||||
<< Param("track", song_playing_.title());
|
<< Param("track", song_playing_.title());
|
||||||
|
|
||||||
if (!song_playing_.album().isEmpty())
|
if (!song_playing_.album().isEmpty()) {
|
||||||
params << Param("album", song_playing_.album());
|
params << Param("album", song_playing_.album());
|
||||||
|
}
|
||||||
|
|
||||||
if (!prefer_albumartist_ && !song_playing_.albumartist().isEmpty() && song_playing_.albumartist().compare(Song::kVariousArtists, Qt::CaseInsensitive) != 0)
|
if (!prefer_albumartist_ && !song_playing_.albumartist().isEmpty()) {
|
||||||
params << Param("albumArtist", song_playing_.albumartist());
|
params << Param("albumArtist", song_playing_.albumartist());
|
||||||
|
}
|
||||||
|
|
||||||
QNetworkReply *reply = CreateRequest(params);
|
QNetworkReply *reply = CreateRequest(params);
|
||||||
QObject::connect(reply, &QNetworkReply::finished, this, [this, reply] { LoveRequestFinished(reply); });
|
QObject::connect(reply, &QNetworkReply::finished, this, [this, reply] { LoveRequestFinished(reply); });
|
||||||
|
Loading…
x
Reference in New Issue
Block a user