Replace QStringLiteral with u""_s operator
This commit is contained in:
@@ -40,104 +40,103 @@ struct IconProperties {
|
||||
|
||||
static const QMap<QString, IconProperties> iconmapper_ = { // clazy:exclude=non-pod-global-static
|
||||
|
||||
{ QStringLiteral("albums"), { {QStringLiteral("media-optical")}} },
|
||||
{ QStringLiteral("alsa"), { {}} },
|
||||
{ QStringLiteral("application-exit"), { {}} },
|
||||
{ QStringLiteral("applications-internet"), { {}} },
|
||||
{ QStringLiteral("bluetooth"), { {QStringLiteral("preferences-system-bluetooth"), QStringLiteral("bluetooth-active")}} },
|
||||
{ QStringLiteral("cdcase"), { {QStringLiteral("cdcover"), QStringLiteral("media-optical")}} },
|
||||
{ QStringLiteral("media-optical"), { {QStringLiteral("cd")}} },
|
||||
{ QStringLiteral("configure"), { {}} },
|
||||
{ QStringLiteral("device-ipod-nano"), { {}} },
|
||||
{ QStringLiteral("device-ipod"), { {}} },
|
||||
{ QStringLiteral("device-phone"), { {}} },
|
||||
{ QStringLiteral("device"), { {QStringLiteral("drive-removable-media-usb-pendrive")}} },
|
||||
{ QStringLiteral("device-usb-drive"), { {}} },
|
||||
{ QStringLiteral("device-usb-flash"), { {}} },
|
||||
{ QStringLiteral("dialog-error"), { {}} },
|
||||
{ QStringLiteral("dialog-information"), { {}} },
|
||||
{ QStringLiteral("dialog-ok-apply"), { {}} },
|
||||
{ QStringLiteral("dialog-password"), { {}} },
|
||||
{ QStringLiteral("dialog-warning"), { {}} },
|
||||
{ QStringLiteral("document-download"), { {QStringLiteral("download")}} },
|
||||
{ QStringLiteral("document-new"), { {}} },
|
||||
{ QStringLiteral("document-open-folder"), { {}} },
|
||||
{ QStringLiteral("document-open"), { {}} },
|
||||
{ QStringLiteral("document-save"), { {}} },
|
||||
{ QStringLiteral("document-search"), { {}} },
|
||||
{ QStringLiteral("document-open-remote"), { {}} },
|
||||
{ QStringLiteral("download"), { {QStringLiteral("applications-internet"), QStringLiteral("network-workgroup")}} },
|
||||
{ QStringLiteral("edit-clear-list"), { {QStringLiteral("edit-clear-list"), QStringLiteral("edit-clear-all")}} },
|
||||
{ QStringLiteral("edit-clear-locationbar-ltr"), { {QStringLiteral("edit-clear-locationbar-ltr")}} },
|
||||
{ QStringLiteral("edit-copy"), { {}} },
|
||||
{ QStringLiteral("edit-delete"), { {}} },
|
||||
{ QStringLiteral("edit-find"), { {}} },
|
||||
{ QStringLiteral("edit-redo"), { {}} },
|
||||
{ QStringLiteral("edit-rename"), { {}} },
|
||||
{ QStringLiteral("edit-undo"), { {}} },
|
||||
{ QStringLiteral("electrocompaniet"), { {}} },
|
||||
{ QStringLiteral("equalizer"), { {QStringLiteral("view-media-equalizer")}} },
|
||||
{ QStringLiteral("folder-new"), { {}} },
|
||||
{ QStringLiteral("folder"), { {}} },
|
||||
{ QStringLiteral("folder-sound"), { {QStringLiteral("folder-music")}} },
|
||||
{ QStringLiteral("footsteps"), { {QStringLiteral("go-jump")}} },
|
||||
{ QStringLiteral("go-down"), { {}} },
|
||||
{ QStringLiteral("go-home"), { {}} },
|
||||
{ QStringLiteral("go-jump"), { {}} },
|
||||
{ QStringLiteral("go-next"), { {}} },
|
||||
{ QStringLiteral("go-previous"), { {}} },
|
||||
{ QStringLiteral("go-up"), { {}} },
|
||||
{ QStringLiteral("gstreamer"), { {QStringLiteral("phonon-gstreamer")}} },
|
||||
{ QStringLiteral("headset"), { {QStringLiteral("audio-headset")}} },
|
||||
{ QStringLiteral("help-hint"), { {}} },
|
||||
{ QStringLiteral("intel"), { {}} },
|
||||
{ QStringLiteral("jack"), { {QStringLiteral("audio-input-line")}} },
|
||||
{ QStringLiteral("keyboard"), { {QStringLiteral("input-keyboard")}} },
|
||||
{ QStringLiteral("list-add"), { {}} },
|
||||
{ QStringLiteral("list-remove"), { {}} },
|
||||
{ QStringLiteral("love"), { {QStringLiteral("heart"), QStringLiteral("emblem-favorite")}} },
|
||||
{ QStringLiteral("mcintosh-player"), { {}} },
|
||||
{ QStringLiteral("mcintosh"), { {}} },
|
||||
{ QStringLiteral("mcintosh-text"), { {}} },
|
||||
{ QStringLiteral("media-eject"), { {}} },
|
||||
{ QStringLiteral("media-playback-pause"), { {QStringLiteral("media-pause")}} },
|
||||
{ QStringLiteral("media-playlist-repeat"), { {}} },
|
||||
{ QStringLiteral("media-playlist-shuffle"), { {""_L1}} },
|
||||
{ QStringLiteral("media-playback-start"), { {QStringLiteral("media-play"), QStringLiteral("media-playback-playing")}} },
|
||||
{ QStringLiteral("media-seek-backward"), { {}} },
|
||||
{ QStringLiteral("media-seek-forward"), { {}} },
|
||||
{ QStringLiteral("media-skip-backward"), { {}} },
|
||||
{ QStringLiteral("media-skip-forward"), { {}} },
|
||||
{ QStringLiteral("media-playback-stop"), { {QStringLiteral("media-stop")}} },
|
||||
{ QStringLiteral("moodbar"), { {QStringLiteral("preferences-desktop-icons")}} },
|
||||
{ QStringLiteral("nvidia"), { {}} },
|
||||
{ QStringLiteral("pulseaudio"), { {}} },
|
||||
{ QStringLiteral("realtek"), { {}} },
|
||||
{ QStringLiteral("scrobble-disabled"), { {}} },
|
||||
{ QStringLiteral("scrobble"), { {QStringLiteral("love")}} },
|
||||
{ QStringLiteral("search"), { {}} },
|
||||
{ QStringLiteral("soundcard"), { {QStringLiteral("audiocard"), QStringLiteral("audio-card")}} },
|
||||
{ QStringLiteral("speaker"), { {}} },
|
||||
{ QStringLiteral("star-grey"), { {}} },
|
||||
{ QStringLiteral("star"), { {}} },
|
||||
{ QStringLiteral("strawberry"), { {}} },
|
||||
{ QStringLiteral("subsonic"), { {}} },
|
||||
{ QStringLiteral("tidal"), { {}} },
|
||||
{ QStringLiteral("tools-wizard"), { {}} },
|
||||
{ QStringLiteral("view-choose"), { {}} },
|
||||
{ QStringLiteral("view-fullscreen"), { {}} },
|
||||
{ QStringLiteral("view-media-lyrics"), { {}} },
|
||||
{ QStringLiteral("view-media-playlist"), { {}} },
|
||||
{ QStringLiteral("view-media-visualization"), { {QStringLiteral("preferences-desktop-theme")}} },
|
||||
{ QStringLiteral("view-refresh"), { {}} },
|
||||
{ QStringLiteral("library-music"), { {QStringLiteral("vinyl")}} },
|
||||
{ QStringLiteral("vlc"), { {}} },
|
||||
{ QStringLiteral("zoom-in"), { {}} },
|
||||
{ QStringLiteral("zoom-out"), { {}, 0, 0 } }
|
||||
{ u"albums"_s, { {u"media-optical"_s}} },
|
||||
{ u"alsa"_s, { {}} },
|
||||
{ u"application-exit"_s, { {}} },
|
||||
{ u"applications-internet"_s, { {}} },
|
||||
{ u"bluetooth"_s, { {u"preferences-system-bluetooth"_s, u"bluetooth-active"_s}} },
|
||||
{ u"cdcase"_s, { {u"cdcover"_s, u"media-optical"_s}} },
|
||||
{ u"media-optical"_s, { {u"cd"_s}} },
|
||||
{ u"configure"_s, { {}} },
|
||||
{ u"device-ipod-nano"_s, { {}} },
|
||||
{ u"device-ipod"_s, { {}} },
|
||||
{ u"device-phone"_s, { {}} },
|
||||
{ u"device"_s, { {u"drive-removable-media-usb-pendrive"_s}} },
|
||||
{ u"device-usb-drive"_s, { {}} },
|
||||
{ u"device-usb-flash"_s, { {}} },
|
||||
{ u"dialog-error"_s, { {}} },
|
||||
{ u"dialog-information"_s, { {}} },
|
||||
{ u"dialog-ok-apply"_s, { {}} },
|
||||
{ u"dialog-password"_s, { {}} },
|
||||
{ u"dialog-warning"_s, { {}} },
|
||||
{ u"document-download"_s, { {u"download"_s}} },
|
||||
{ u"document-new"_s, { {}} },
|
||||
{ u"document-open-folder"_s, { {}} },
|
||||
{ u"document-open"_s, { {}} },
|
||||
{ u"document-save"_s, { {}} },
|
||||
{ u"document-search"_s, { {}} },
|
||||
{ u"document-open-remote"_s, { {}} },
|
||||
{ u"download"_s, { {u"applications-internet"_s, u"network-workgroup"_s}} },
|
||||
{ u"edit-clear-list"_s, { {u"edit-clear-list"_s, u"edit-clear-all"_s}} },
|
||||
{ u"edit-clear-locationbar-ltr"_s, { {u"edit-clear-locationbar-ltr"_s}} },
|
||||
{ u"edit-copy"_s, { {}} },
|
||||
{ u"edit-delete"_s, { {}} },
|
||||
{ u"edit-find"_s, { {}} },
|
||||
{ u"edit-redo"_s, { {}} },
|
||||
{ u"edit-rename"_s, { {}} },
|
||||
{ u"edit-undo"_s, { {}} },
|
||||
{ u"electrocompaniet"_s, { {}} },
|
||||
{ u"equalizer"_s, { {u"view-media-equalizer"_s}} },
|
||||
{ u"folder-new"_s, { {}} },
|
||||
{ u"folder"_s, { {}} },
|
||||
{ u"folder-sound"_s, { {u"folder-music"_s}} },
|
||||
{ u"footsteps"_s, { {u"go-jump"_s}} },
|
||||
{ u"go-down"_s, { {}} },
|
||||
{ u"go-home"_s, { {}} },
|
||||
{ u"go-jump"_s, { {}} },
|
||||
{ u"go-next"_s, { {}} },
|
||||
{ u"go-previous"_s, { {}} },
|
||||
{ u"go-up"_s, { {}} },
|
||||
{ u"gstreamer"_s, { {u"phonon-gstreamer"_s}} },
|
||||
{ u"headset"_s, { {u"audio-headset"_s}} },
|
||||
{ u"help-hint"_s, { {}} },
|
||||
{ u"intel"_s, { {}} },
|
||||
{ u"jack"_s, { {u"audio-input-line"_s}} },
|
||||
{ u"keyboard"_s, { {u"input-keyboard"_s}} },
|
||||
{ u"list-add"_s, { {}} },
|
||||
{ u"list-remove"_s, { {}} },
|
||||
{ u"love"_s, { {u"heart"_s, u"emblem-favorite"_s}} },
|
||||
{ u"mcintosh-player"_s, { {}} },
|
||||
{ u"mcintosh"_s, { {}} },
|
||||
{ u"mcintosh-text"_s, { {}} },
|
||||
{ u"media-eject"_s, { {}} },
|
||||
{ u"media-playback-pause"_s, { {u"media-pause"_s}} },
|
||||
{ u"media-playlist-repeat"_s, { {}} },
|
||||
{ u"media-playlist-shuffle"_s, { {""_L1}} },
|
||||
{ u"media-playback-start"_s, { {u"media-play"_s, u"media-playback-playing"_s}} },
|
||||
{ u"media-seek-backward"_s, { {}} },
|
||||
{ u"media-seek-forward"_s, { {}} },
|
||||
{ u"media-skip-backward"_s, { {}} },
|
||||
{ u"media-skip-forward"_s, { {}} },
|
||||
{ u"media-playback-stop"_s, { {u"media-stop"_s}} },
|
||||
{ u"moodbar"_s, { {u"preferences-desktop-icons"_s}} },
|
||||
{ u"nvidia"_s, { {}} },
|
||||
{ u"pulseaudio"_s, { {}} },
|
||||
{ u"realtek"_s, { {}} },
|
||||
{ u"scrobble-disabled"_s, { {}} },
|
||||
{ u"scrobble"_s, { {u"love"_s}} },
|
||||
{ u"search"_s, { {}} },
|
||||
{ u"soundcard"_s, { {u"audiocard"_s, u"audio-card"_s}} },
|
||||
{ u"speaker"_s, { {}} },
|
||||
{ u"star-grey"_s, { {}} },
|
||||
{ u"star"_s, { {}} },
|
||||
{ u"strawberry"_s, { {}} },
|
||||
{ u"subsonic"_s, { {}} },
|
||||
{ u"tidal"_s, { {}} },
|
||||
{ u"tools-wizard"_s, { {}} },
|
||||
{ u"view-choose"_s, { {}} },
|
||||
{ u"view-fullscreen"_s, { {}} },
|
||||
{ u"view-media-lyrics"_s, { {}} },
|
||||
{ u"view-media-playlist"_s, { {}} },
|
||||
{ u"view-media-visualization"_s, { {u"preferences-desktop-theme"_s}} },
|
||||
{ u"view-refresh"_s, { {}} },
|
||||
{ u"library-music"_s, { {u"vinyl"_s}} },
|
||||
{ u"vlc"_s, { {}} },
|
||||
{ u"zoom-in"_s, { {}} },
|
||||
{ u"zoom-out"_s, { {}, 0, 0 } }
|
||||
|
||||
};
|
||||
|
||||
} // namespace IconMapper
|
||||
|
||||
#endif // ICONMAPPER_H
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -41,29 +41,29 @@ using namespace Qt::StringLiterals;
|
||||
const char OrganizeFormat::kBlockPattern[] = "\\{([^{}]+)\\}";
|
||||
const char OrganizeFormat::kTagPattern[] = "\\%([a-zA-Z]*)";
|
||||
|
||||
const QStringList OrganizeFormat::kKnownTags = QStringList() << QStringLiteral("title")
|
||||
<< QStringLiteral("album")
|
||||
<< QStringLiteral("artist")
|
||||
<< QStringLiteral("artistinitial")
|
||||
<< QStringLiteral("albumartist")
|
||||
<< QStringLiteral("composer")
|
||||
<< QStringLiteral("track")
|
||||
<< QStringLiteral("disc")
|
||||
<< QStringLiteral("year")
|
||||
<< QStringLiteral("originalyear")
|
||||
<< QStringLiteral("genre")
|
||||
<< QStringLiteral("comment")
|
||||
<< QStringLiteral("length")
|
||||
<< QStringLiteral("bitrate")
|
||||
<< QStringLiteral("samplerate")
|
||||
<< QStringLiteral("bitdepth")
|
||||
<< QStringLiteral("extension")
|
||||
<< QStringLiteral("performer")
|
||||
<< QStringLiteral("grouping")
|
||||
<< QStringLiteral("lyrics");
|
||||
const QStringList OrganizeFormat::kKnownTags = QStringList() << u"title"_s
|
||||
<< u"album"_s
|
||||
<< u"artist"_s
|
||||
<< u"artistinitial"_s
|
||||
<< u"albumartist"_s
|
||||
<< u"composer"_s
|
||||
<< u"track"_s
|
||||
<< u"disc"_s
|
||||
<< u"year"_s
|
||||
<< u"originalyear"_s
|
||||
<< u"genre"_s
|
||||
<< u"comment"_s
|
||||
<< u"length"_s
|
||||
<< u"bitrate"_s
|
||||
<< u"samplerate"_s
|
||||
<< u"bitdepth"_s
|
||||
<< u"extension"_s
|
||||
<< u"performer"_s
|
||||
<< u"grouping"_s
|
||||
<< u"lyrics"_s;
|
||||
|
||||
const QStringList OrganizeFormat::kUniqueTags = QStringList() << QStringLiteral("title")
|
||||
<< QStringLiteral("track");
|
||||
const QStringList OrganizeFormat::kUniqueTags = QStringList() << u"title"_s
|
||||
<< u"track"_s;
|
||||
|
||||
OrganizeFormat::OrganizeFormat(const QString &format)
|
||||
: format_(format),
|
||||
@@ -184,12 +184,12 @@ OrganizeFormat::GetFilenameForSongResult OrganizeFormat::GetFilenameForSong(cons
|
||||
filepath = parts_new.join(u'/');
|
||||
|
||||
if (replace_spaces_) {
|
||||
static const QRegularExpression regex_whitespaces(QStringLiteral("\\s"));
|
||||
filepath.replace(regex_whitespaces, QStringLiteral("_"));
|
||||
static const QRegularExpression regex_whitespaces(u"\\s"_s);
|
||||
filepath.replace(regex_whitespaces, u"_"_s);
|
||||
}
|
||||
|
||||
if (!extension.isEmpty()) {
|
||||
filepath.append(QStringLiteral(".%1").arg(extension));
|
||||
filepath.append(u".%1"_s.arg(extension));
|
||||
}
|
||||
|
||||
return GetFilenameForSongResult(filepath, unique_filename);
|
||||
@@ -302,13 +302,13 @@ QString OrganizeFormat::TagValue(const QString &tag, const Song &song) const {
|
||||
else if (tag == "artistinitial"_L1) {
|
||||
value = song.effective_albumartist().trimmed();
|
||||
if (!value.isEmpty()) {
|
||||
static const QRegularExpression regex_the(QStringLiteral("^the\\s+"), QRegularExpression::CaseInsensitiveOption);
|
||||
static const QRegularExpression regex_the(u"^the\\s+"_s, QRegularExpression::CaseInsensitiveOption);
|
||||
value = value.remove(regex_the);
|
||||
value = value[0].toUpper();
|
||||
}
|
||||
}
|
||||
else if (tag == "albumartist"_L1) {
|
||||
value = song.is_compilation() ? QStringLiteral("Various Artists") : song.effective_albumartist();
|
||||
value = song.is_compilation() ? u"Various Artists"_s : song.effective_albumartist();
|
||||
}
|
||||
|
||||
if (value == u'0' || value == "-1"_L1) value = ""_L1;
|
||||
|
||||
@@ -209,8 +209,8 @@ void ScrobblingAPI20::Authenticate() {
|
||||
}
|
||||
|
||||
QUrlQuery url_query;
|
||||
url_query.addQueryItem(QStringLiteral("api_key"), QLatin1String(kApiKey));
|
||||
url_query.addQueryItem(QStringLiteral("cb"), server_->url().toString());
|
||||
url_query.addQueryItem(u"api_key"_s, QLatin1String(kApiKey));
|
||||
url_query.addQueryItem(u"cb"_s, server_->url().toString());
|
||||
QUrl url(auth_url_);
|
||||
url.setQuery(url_query);
|
||||
|
||||
@@ -252,8 +252,8 @@ void ScrobblingAPI20::RedirectArrived() {
|
||||
QUrl url = server_->request_url();
|
||||
if (url.isValid()) {
|
||||
QUrlQuery url_query(url);
|
||||
if (url_query.hasQueryItem(QStringLiteral("token"))) {
|
||||
QString token = url_query.queryItemValue(QStringLiteral("token"));
|
||||
if (url_query.hasQueryItem(u"token"_s)) {
|
||||
QString token = url_query.queryItemValue(u"token"_s);
|
||||
RequestSession(token);
|
||||
}
|
||||
else {
|
||||
@@ -278,9 +278,9 @@ void ScrobblingAPI20::RequestSession(const QString &token) {
|
||||
|
||||
QUrl session_url(api_url_);
|
||||
QUrlQuery session_url_query;
|
||||
session_url_query.addQueryItem(QStringLiteral("api_key"), QLatin1String(kApiKey));
|
||||
session_url_query.addQueryItem(QStringLiteral("method"), QStringLiteral("auth.getSession"));
|
||||
session_url_query.addQueryItem(QStringLiteral("token"), token);
|
||||
session_url_query.addQueryItem(u"api_key"_s, QLatin1String(kApiKey));
|
||||
session_url_query.addQueryItem(u"method"_s, u"auth.getSession"_s);
|
||||
session_url_query.addQueryItem(u"token"_s, token);
|
||||
QString data_to_sign;
|
||||
const ParamList params = session_url_query.queryItems();
|
||||
for (const Param ¶m : params) {
|
||||
@@ -289,8 +289,8 @@ void ScrobblingAPI20::RequestSession(const QString &token) {
|
||||
data_to_sign += QLatin1String(kSecret);
|
||||
QByteArray const digest = QCryptographicHash::hash(data_to_sign.toUtf8(), QCryptographicHash::Md5);
|
||||
const QString signature = QString::fromLatin1(digest.toHex()).rightJustified(32, u'0').toLower();
|
||||
session_url_query.addQueryItem(QStringLiteral("api_sig"), signature);
|
||||
session_url_query.addQueryItem(QString::fromLatin1(QUrl::toPercentEncoding(QStringLiteral("format"))), QString::fromLatin1(QUrl::toPercentEncoding(QStringLiteral("json"))));
|
||||
session_url_query.addQueryItem(u"api_sig"_s, signature);
|
||||
session_url_query.addQueryItem(QString::fromLatin1(QUrl::toPercentEncoding(u"format"_s)), QString::fromLatin1(QUrl::toPercentEncoding(u"json"_s)));
|
||||
session_url.setQuery(session_url_query);
|
||||
|
||||
QNetworkRequest req(session_url);
|
||||
@@ -316,22 +316,22 @@ void ScrobblingAPI20::AuthenticateReplyFinished(QNetworkReply *reply) {
|
||||
}
|
||||
|
||||
if (!json_obj.contains("session"_L1)) {
|
||||
AuthError(QStringLiteral("Json reply from server is missing session."));
|
||||
AuthError(u"Json reply from server is missing session."_s);
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonValue json_session = json_obj["session"_L1];
|
||||
if (!json_session.isObject()) {
|
||||
AuthError(QStringLiteral("Json session is not an object."));
|
||||
AuthError(u"Json session is not an object."_s);
|
||||
return;
|
||||
}
|
||||
json_obj = json_session.toObject();
|
||||
if (json_obj.isEmpty()) {
|
||||
AuthError(QStringLiteral("Json session object is empty."));
|
||||
AuthError(u"Json session object is empty."_s);
|
||||
return;
|
||||
}
|
||||
if (!json_obj.contains("subscriber"_L1) || !json_obj.contains("name"_L1) || !json_obj.contains("key"_L1)) {
|
||||
AuthError(QStringLiteral("Json session object is missing values."));
|
||||
AuthError(u"Json session object is missing values."_s);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -355,9 +355,9 @@ void ScrobblingAPI20::AuthenticateReplyFinished(QNetworkReply *reply) {
|
||||
QNetworkReply *ScrobblingAPI20::CreateRequest(const ParamList &request_params) {
|
||||
|
||||
ParamList params = ParamList()
|
||||
<< Param(QStringLiteral("api_key"), QLatin1String(kApiKey))
|
||||
<< Param(QStringLiteral("sk"), session_key_)
|
||||
<< Param(QStringLiteral("lang"), QLocale().name().left(2).toLower())
|
||||
<< Param(u"api_key"_s, QLatin1String(kApiKey))
|
||||
<< Param(u"sk"_s, session_key_)
|
||||
<< Param(u"lang"_s, QLocale().name().left(2).toLower())
|
||||
<< request_params;
|
||||
|
||||
std::sort(params.begin(), params.end());
|
||||
@@ -374,13 +374,13 @@ QNetworkReply *ScrobblingAPI20::CreateRequest(const ParamList &request_params) {
|
||||
QByteArray const digest = QCryptographicHash::hash(data_to_sign.toUtf8(), QCryptographicHash::Md5);
|
||||
const QString signature = QString::fromLatin1(digest.toHex()).rightJustified(32, u'0').toLower();
|
||||
|
||||
url_query.addQueryItem(QStringLiteral("api_sig"), QString::fromLatin1(QUrl::toPercentEncoding(signature)));
|
||||
url_query.addQueryItem(QStringLiteral("format"), QStringLiteral("json"));
|
||||
url_query.addQueryItem(u"api_sig"_s, QString::fromLatin1(QUrl::toPercentEncoding(signature)));
|
||||
url_query.addQueryItem(u"format"_s, u"json"_s);
|
||||
|
||||
QUrl url(api_url_);
|
||||
QNetworkRequest req(url);
|
||||
req.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
|
||||
req.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
|
||||
req.setHeader(QNetworkRequest::ContentTypeHeader, u"application/x-www-form-urlencoded"_s);
|
||||
QByteArray query = url_query.toString(QUrl::FullyEncoded).toUtf8();
|
||||
QNetworkReply *reply = network_->post(req, query);
|
||||
replies_ << reply;
|
||||
@@ -402,16 +402,16 @@ void ScrobblingAPI20::UpdateNowPlaying(const Song &song) {
|
||||
if (!authenticated() || !song.is_metadata_good() || settings_->offline()) return;
|
||||
|
||||
ParamList params = ParamList()
|
||||
<< Param(QStringLiteral("method"), QStringLiteral("track.updateNowPlaying"))
|
||||
<< Param(QStringLiteral("artist"), prefer_albumartist_ ? song.effective_albumartist() : song.artist())
|
||||
<< Param(QStringLiteral("track"), StripTitle(song.title()));
|
||||
<< Param(u"method"_s, u"track.updateNowPlaying"_s)
|
||||
<< Param(u"artist"_s, prefer_albumartist_ ? song.effective_albumartist() : song.artist())
|
||||
<< Param(u"track"_s, StripTitle(song.title()));
|
||||
|
||||
if (!song.album().isEmpty()) {
|
||||
params << Param(QStringLiteral("album"), StripAlbum(song.album()));
|
||||
params << Param(u"album"_s, StripAlbum(song.album()));
|
||||
}
|
||||
|
||||
if (!prefer_albumartist_ && !song.albumartist().isEmpty()) {
|
||||
params << Param(QStringLiteral("albumArtist"), song.albumartist());
|
||||
params << Param(u"albumArtist"_s, song.albumartist());
|
||||
}
|
||||
|
||||
QNetworkReply *reply = CreateRequest(params);
|
||||
@@ -434,7 +434,7 @@ void ScrobblingAPI20::UpdateNowPlayingRequestFinished(QNetworkReply *reply) {
|
||||
}
|
||||
|
||||
if (!json_obj.contains("nowplaying"_L1)) {
|
||||
Error(QStringLiteral("Json reply from server is missing nowplaying."), json_obj);
|
||||
Error(u"Json reply from server is missing nowplaying."_s, json_obj);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -494,7 +494,7 @@ void ScrobblingAPI20::Submit() {
|
||||
|
||||
qLog(Debug) << name_ << "Submitting scrobbles.";
|
||||
|
||||
ParamList params = ParamList() << Param(QStringLiteral("method"), QStringLiteral("track.scrobble"));
|
||||
ParamList params = ParamList() << Param(u"method"_s, u"track.scrobble"_s);
|
||||
|
||||
int i = 0;
|
||||
const ScrobblerCacheItemPtrList all_cache_items = cache_->List();
|
||||
@@ -507,18 +507,18 @@ void ScrobblingAPI20::Submit() {
|
||||
continue;
|
||||
}
|
||||
cache_items_sent << cache_item;
|
||||
params << Param(QStringLiteral("%1[%2]").arg(QStringLiteral("artist")).arg(i), prefer_albumartist_ ? cache_item->metadata.effective_albumartist() : cache_item->metadata.artist);
|
||||
params << Param(QStringLiteral("%1[%2]").arg(QStringLiteral("track")).arg(i), StripTitle(cache_item->metadata.title));
|
||||
params << Param(QStringLiteral("%1[%2]").arg(QStringLiteral("timestamp")).arg(i), QString::number(cache_item->timestamp));
|
||||
params << Param(QStringLiteral("%1[%2]").arg(QStringLiteral("duration")).arg(i), QString::number(cache_item->metadata.length_nanosec / kNsecPerSec));
|
||||
params << Param(u"%1[%2]"_s.arg(u"artist"_s).arg(i), prefer_albumartist_ ? cache_item->metadata.effective_albumartist() : cache_item->metadata.artist);
|
||||
params << Param(u"%1[%2]"_s.arg(u"track"_s).arg(i), StripTitle(cache_item->metadata.title));
|
||||
params << Param(u"%1[%2]"_s.arg(u"timestamp"_s).arg(i), QString::number(cache_item->timestamp));
|
||||
params << Param(u"%1[%2]"_s.arg(u"duration"_s).arg(i), QString::number(cache_item->metadata.length_nanosec / kNsecPerSec));
|
||||
if (!cache_item->metadata.album.isEmpty()) {
|
||||
params << Param(QStringLiteral("%1[%2]").arg("album"_L1).arg(i), StripAlbum(cache_item->metadata.album));
|
||||
params << Param(u"%1[%2]"_s.arg("album"_L1).arg(i), StripAlbum(cache_item->metadata.album));
|
||||
}
|
||||
if (!prefer_albumartist_ && !cache_item->metadata.albumartist.isEmpty()) {
|
||||
params << Param(QStringLiteral("%1[%2]").arg("albumArtist"_L1).arg(i), cache_item->metadata.albumartist);
|
||||
params << Param(u"%1[%2]"_s.arg("albumArtist"_L1).arg(i), cache_item->metadata.albumartist);
|
||||
}
|
||||
if (cache_item->metadata.track > 0) {
|
||||
params << Param(QStringLiteral("%1[%2]").arg("trackNumber"_L1).arg(i), QString::number(cache_item->metadata.track));
|
||||
params << Param(u"%1[%2]"_s.arg("trackNumber"_L1).arg(i), QString::number(cache_item->metadata.track));
|
||||
}
|
||||
++i;
|
||||
if (cache_items_sent.count() >= kScrobblesPerRequest) break;
|
||||
@@ -556,43 +556,43 @@ void ScrobblingAPI20::ScrobbleRequestFinished(QNetworkReply *reply, ScrobblerCac
|
||||
submit_error_ = false;
|
||||
|
||||
if (!json_obj.contains("scrobbles"_L1)) {
|
||||
Error(QStringLiteral("Json reply from server is missing scrobbles."), json_obj);
|
||||
Error(u"Json reply from server is missing scrobbles."_s, json_obj);
|
||||
StartSubmit();
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonValue value_scrobbles = json_obj["scrobbles"_L1];
|
||||
if (!value_scrobbles.isObject()) {
|
||||
Error(QStringLiteral("Json scrobbles is not an object."), json_obj);
|
||||
Error(u"Json scrobbles is not an object."_s, json_obj);
|
||||
StartSubmit();
|
||||
return;
|
||||
}
|
||||
json_obj = value_scrobbles.toObject();
|
||||
if (json_obj.isEmpty()) {
|
||||
Error(QStringLiteral("Json scrobbles object is empty."), value_scrobbles);
|
||||
Error(u"Json scrobbles object is empty."_s, value_scrobbles);
|
||||
StartSubmit();
|
||||
return;
|
||||
}
|
||||
if (!json_obj.contains("@attr"_L1) || !json_obj.contains("scrobble"_L1)) {
|
||||
Error(QStringLiteral("Json scrobbles object is missing values."), json_obj);
|
||||
Error(u"Json scrobbles object is missing values."_s, json_obj);
|
||||
StartSubmit();
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonValue value_attr = json_obj["@attr"_L1];
|
||||
if (!value_attr.isObject()) {
|
||||
Error(QStringLiteral("Json scrobbles attr is not an object."), value_attr);
|
||||
Error(u"Json scrobbles attr is not an object."_s, value_attr);
|
||||
StartSubmit();
|
||||
return;
|
||||
}
|
||||
QJsonObject obj_attr = value_attr.toObject();
|
||||
if (obj_attr.isEmpty()) {
|
||||
Error(QStringLiteral("Json scrobbles attr is empty."), value_attr);
|
||||
Error(u"Json scrobbles attr is empty."_s, value_attr);
|
||||
StartSubmit();
|
||||
return;
|
||||
}
|
||||
if (!obj_attr.contains("accepted"_L1) || !obj_attr.contains("ignored"_L1)) {
|
||||
Error(QStringLiteral("Json scrobbles attr is missing values."), obj_attr);
|
||||
Error(u"Json scrobbles attr is missing values."_s, obj_attr);
|
||||
StartSubmit();
|
||||
return;
|
||||
}
|
||||
@@ -607,7 +607,7 @@ void ScrobblingAPI20::ScrobbleRequestFinished(QNetworkReply *reply, ScrobblerCac
|
||||
if (value_scrobble.isObject()) {
|
||||
QJsonObject obj_scrobble = value_scrobble.toObject();
|
||||
if (obj_scrobble.isEmpty()) {
|
||||
Error(QStringLiteral("Json scrobbles scrobble object is empty."), obj_scrobble);
|
||||
Error(u"Json scrobbles scrobble object is empty."_s, obj_scrobble);
|
||||
StartSubmit();
|
||||
return;
|
||||
}
|
||||
@@ -616,13 +616,13 @@ void ScrobblingAPI20::ScrobbleRequestFinished(QNetworkReply *reply, ScrobblerCac
|
||||
else if (value_scrobble.isArray()) {
|
||||
array_scrobble = value_scrobble.toArray();
|
||||
if (array_scrobble.isEmpty()) {
|
||||
Error(QStringLiteral("Json scrobbles scrobble array is empty."), value_scrobble);
|
||||
Error(u"Json scrobbles scrobble array is empty."_s, value_scrobble);
|
||||
StartSubmit();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Error(QStringLiteral("Json scrobbles scrobble is not an object or array."), value_scrobble);
|
||||
Error(u"Json scrobbles scrobble is not an object or array."_s, value_scrobble);
|
||||
StartSubmit();
|
||||
return;
|
||||
}
|
||||
@@ -630,7 +630,7 @@ void ScrobblingAPI20::ScrobbleRequestFinished(QNetworkReply *reply, ScrobblerCac
|
||||
for (const QJsonValue &value : std::as_const(array_scrobble)) {
|
||||
|
||||
if (!value.isObject()) {
|
||||
Error(QStringLiteral("Json scrobbles scrobble array value is not an object."));
|
||||
Error(u"Json scrobbles scrobble array value is not an object."_s);
|
||||
continue;
|
||||
}
|
||||
QJsonObject json_track = value.toObject();
|
||||
@@ -645,7 +645,7 @@ void ScrobblingAPI20::ScrobbleRequestFinished(QNetworkReply *reply, ScrobblerCac
|
||||
!json_track.contains("timestamp"_L1) ||
|
||||
!json_track.contains("ignoredMessage"_L1)
|
||||
) {
|
||||
Error(QStringLiteral("Json scrobbles scrobble is missing values."), json_track);
|
||||
Error(u"Json scrobbles scrobble is missing values."_s, json_track);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -653,10 +653,10 @@ void ScrobblingAPI20::ScrobbleRequestFinished(QNetworkReply *reply, ScrobblerCac
|
||||
QJsonValue value_album = json_track["album"_L1];
|
||||
QJsonValue value_song = json_track["track"_L1];
|
||||
QJsonValue value_ignoredmessage = json_track["ignoredMessage"_L1];
|
||||
//quint64 timestamp = json_track[QLatin1String("timestamp")].toVariant().toULongLong();
|
||||
//quint64 timestamp = json_track[u"timestamp"_s].toVariant().toULongLong();
|
||||
|
||||
if (!value_artist.isObject() || !value_album.isObject() || !value_song.isObject() || !value_ignoredmessage.isObject()) {
|
||||
Error(QStringLiteral("Json scrobbles scrobble values are not objects."), json_track);
|
||||
Error(u"Json scrobbles scrobble values are not objects."_s, json_track);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -666,7 +666,7 @@ void ScrobblingAPI20::ScrobbleRequestFinished(QNetworkReply *reply, ScrobblerCac
|
||||
QJsonObject obj_ignoredmessage = value_ignoredmessage.toObject();
|
||||
|
||||
if (obj_artist.isEmpty() || obj_album.isEmpty() || obj_song.isEmpty() || obj_ignoredmessage.isEmpty()) {
|
||||
Error(QStringLiteral("Json scrobbles scrobble values objects are empty."), json_track);
|
||||
Error(u"Json scrobbles scrobble values objects are empty."_s, json_track);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -681,7 +681,7 @@ void ScrobblingAPI20::ScrobbleRequestFinished(QNetworkReply *reply, ScrobblerCac
|
||||
QString ignoredmessage_text = obj_ignoredmessage["#text"_L1].toString();
|
||||
|
||||
if (ignoredmessage) {
|
||||
Error(QStringLiteral("Scrobble for \"%1\" ignored: %2").arg(song, ignoredmessage_text));
|
||||
Error(u"Scrobble for \"%1\" ignored: %2"_s.arg(song, ignoredmessage_text));
|
||||
}
|
||||
else {
|
||||
qLog(Debug) << name_ << "Scrobble for" << song << "accepted";
|
||||
@@ -696,20 +696,20 @@ void ScrobblingAPI20::ScrobbleRequestFinished(QNetworkReply *reply, ScrobblerCac
|
||||
void ScrobblingAPI20::SendSingleScrobble(ScrobblerCacheItemPtr item) {
|
||||
|
||||
ParamList params = ParamList()
|
||||
<< Param(QStringLiteral("method"), QStringLiteral("track.scrobble"))
|
||||
<< Param(QStringLiteral("artist"), prefer_albumartist_ ? item->metadata.effective_albumartist() : item->metadata.artist)
|
||||
<< Param(QStringLiteral("track"), StripTitle(item->metadata.title))
|
||||
<< Param(QStringLiteral("timestamp"), QString::number(item->timestamp))
|
||||
<< Param(QStringLiteral("duration"), QString::number(item->metadata.length_nanosec / kNsecPerSec));
|
||||
<< Param(u"method"_s, u"track.scrobble"_s)
|
||||
<< Param(u"artist"_s, prefer_albumartist_ ? item->metadata.effective_albumartist() : item->metadata.artist)
|
||||
<< Param(u"track"_s, StripTitle(item->metadata.title))
|
||||
<< Param(u"timestamp"_s, QString::number(item->timestamp))
|
||||
<< Param(u"duration"_s, QString::number(item->metadata.length_nanosec / kNsecPerSec));
|
||||
|
||||
if (!item->metadata.album.isEmpty()) {
|
||||
params << Param(QStringLiteral("album"), StripAlbum(item->metadata.album));
|
||||
params << Param(u"album"_s, StripAlbum(item->metadata.album));
|
||||
}
|
||||
if (!prefer_albumartist_ && !item->metadata.albumartist.isEmpty()) {
|
||||
params << Param(QStringLiteral("albumArtist"), item->metadata.albumartist);
|
||||
params << Param(u"albumArtist"_s, item->metadata.albumartist);
|
||||
}
|
||||
if (item->metadata.track > 0) {
|
||||
params << Param(QStringLiteral("trackNumber"), QString::number(item->metadata.track));
|
||||
params << Param(u"trackNumber"_s, QString::number(item->metadata.track));
|
||||
}
|
||||
|
||||
QNetworkReply *reply = CreateRequest(params);
|
||||
@@ -733,7 +733,7 @@ void ScrobblingAPI20::SingleScrobbleRequestFinished(QNetworkReply *reply, Scrobb
|
||||
}
|
||||
|
||||
if (!json_obj.contains("scrobbles"_L1)) {
|
||||
Error(QStringLiteral("Json reply from server is missing scrobbles."), json_obj);
|
||||
Error(u"Json reply from server is missing scrobbles."_s, json_obj);
|
||||
cache_item->sent = false;
|
||||
return;
|
||||
}
|
||||
@@ -742,48 +742,48 @@ void ScrobblingAPI20::SingleScrobbleRequestFinished(QNetworkReply *reply, Scrobb
|
||||
|
||||
QJsonValue value_scrobbles = json_obj["scrobbles"_L1];
|
||||
if (!value_scrobbles.isObject()) {
|
||||
Error(QStringLiteral("Json scrobbles is not an object."), json_obj);
|
||||
Error(u"Json scrobbles is not an object."_s, json_obj);
|
||||
return;
|
||||
}
|
||||
json_obj = value_scrobbles.toObject();
|
||||
if (json_obj.isEmpty()) {
|
||||
Error(QStringLiteral("Json scrobbles object is empty."), value_scrobbles);
|
||||
Error(u"Json scrobbles object is empty."_s, value_scrobbles);
|
||||
return;
|
||||
}
|
||||
if (!json_obj.contains("@attr"_L1) || !json_obj.contains("scrobble"_L1)) {
|
||||
Error(QStringLiteral("Json scrobbles object is missing values."), json_obj);
|
||||
Error(u"Json scrobbles object is missing values."_s, json_obj);
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonValue value_attr = json_obj["@attr"_L1];
|
||||
if (!value_attr.isObject()) {
|
||||
Error(QStringLiteral("Json scrobbles attr is not an object."), value_attr);
|
||||
Error(u"Json scrobbles attr is not an object."_s, value_attr);
|
||||
return;
|
||||
}
|
||||
QJsonObject obj_attr = value_attr.toObject();
|
||||
if (obj_attr.isEmpty()) {
|
||||
Error(QStringLiteral("Json scrobbles attr is empty."), value_attr);
|
||||
Error(u"Json scrobbles attr is empty."_s, value_attr);
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonValue value_scrobble = json_obj["scrobble"_L1];
|
||||
if (!value_scrobble.isObject()) {
|
||||
Error(QStringLiteral("Json scrobbles scrobble is not an object."), value_scrobble);
|
||||
Error(u"Json scrobbles scrobble is not an object."_s, value_scrobble);
|
||||
return;
|
||||
}
|
||||
QJsonObject json_obj_scrobble = value_scrobble.toObject();
|
||||
if (json_obj_scrobble.isEmpty()) {
|
||||
Error(QStringLiteral("Json scrobbles scrobble is empty."), value_scrobble);
|
||||
Error(u"Json scrobbles scrobble is empty."_s, value_scrobble);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!obj_attr.contains("accepted"_L1) || !obj_attr.contains("ignored"_L1)) {
|
||||
Error(QStringLiteral("Json scrobbles attr is missing values."), obj_attr);
|
||||
Error(u"Json scrobbles attr is missing values."_s, obj_attr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!json_obj_scrobble.contains("artist"_L1) || !json_obj_scrobble.contains("album"_L1) || !json_obj_scrobble.contains("albumArtist"_L1) || !json_obj_scrobble.contains("track"_L1) || !json_obj_scrobble.contains("timestamp"_L1)) {
|
||||
Error(QStringLiteral("Json scrobbles scrobble is missing values."), json_obj_scrobble);
|
||||
Error(u"Json scrobbles scrobble is missing values."_s, json_obj_scrobble);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -792,7 +792,7 @@ void ScrobblingAPI20::SingleScrobbleRequestFinished(QNetworkReply *reply, Scrobb
|
||||
QJsonValue json_value_song = json_obj_scrobble["track"_L1];
|
||||
|
||||
if (!json_value_artist.isObject() || !json_value_album.isObject() || !json_value_song.isObject()) {
|
||||
Error(QStringLiteral("Json scrobbles scrobble values are not objects."), json_obj_scrobble);
|
||||
Error(u"Json scrobbles scrobble values are not objects."_s, json_obj_scrobble);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -801,12 +801,12 @@ void ScrobblingAPI20::SingleScrobbleRequestFinished(QNetworkReply *reply, Scrobb
|
||||
QJsonObject json_obj_song = json_value_song.toObject();
|
||||
|
||||
if (json_obj_artist.isEmpty() || json_obj_album.isEmpty() || json_obj_song.isEmpty()) {
|
||||
Error(QStringLiteral("Json scrobbles scrobble values objects are empty."), json_obj_scrobble);
|
||||
Error(u"Json scrobbles scrobble values objects are empty."_s, json_obj_scrobble);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!json_obj_artist.contains("#text"_L1) || !json_obj_album.contains("#text"_L1) || !json_obj_song.contains("#text"_L1)) {
|
||||
Error(QStringLiteral("Json scrobbles scrobble values objects are missing #text."), json_obj_artist);
|
||||
Error(u"Json scrobbles scrobble values objects are missing #text."_s, json_obj_artist);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -833,16 +833,16 @@ void ScrobblingAPI20::Love() {
|
||||
qLog(Debug) << name_ << "Sending love for song" << song_playing_.artist() << song_playing_.album() << song_playing_.title();
|
||||
|
||||
ParamList params = ParamList()
|
||||
<< Param(QStringLiteral("method"), QStringLiteral("track.love"))
|
||||
<< Param(QStringLiteral("artist"), prefer_albumartist_ ? song_playing_.effective_albumartist() : song_playing_.artist())
|
||||
<< Param(QStringLiteral("track"), song_playing_.title());
|
||||
<< Param(u"method"_s, u"track.love"_s)
|
||||
<< Param(u"artist"_s, prefer_albumartist_ ? song_playing_.effective_albumartist() : song_playing_.artist())
|
||||
<< Param(u"track"_s, song_playing_.title());
|
||||
|
||||
if (!song_playing_.album().isEmpty()) {
|
||||
params << Param(QStringLiteral("album"), song_playing_.album());
|
||||
params << Param(u"album"_s, song_playing_.album());
|
||||
}
|
||||
|
||||
if (!prefer_albumartist_ && !song_playing_.albumartist().isEmpty()) {
|
||||
params << Param(QStringLiteral("albumArtist"), song_playing_.albumartist());
|
||||
params << Param(u"albumArtist"_s, song_playing_.albumartist());
|
||||
}
|
||||
|
||||
QNetworkReply *reply = CreateRequest(params);
|
||||
@@ -867,12 +867,12 @@ void ScrobblingAPI20::LoveRequestFinished(QNetworkReply *reply) {
|
||||
if (json_obj.contains("error"_L1)) {
|
||||
QJsonValue json_value = json_obj["error"_L1];
|
||||
if (!json_value.isObject()) {
|
||||
Error(QStringLiteral("Error is not on object."));
|
||||
Error(u"Error is not on object."_s);
|
||||
return;
|
||||
}
|
||||
QJsonObject json_obj_error = json_value.toObject();
|
||||
if (json_obj_error.isEmpty()) {
|
||||
Error(QStringLiteral("Received empty json error object."), json_obj);
|
||||
Error(u"Received empty json error object."_s, json_obj);
|
||||
return;
|
||||
}
|
||||
if (json_obj_error.contains("code"_L1) && json_obj_error.contains("#text"_L1)) {
|
||||
@@ -919,64 +919,64 @@ QString ScrobblingAPI20::ErrorString(const ScrobbleErrorCode error) {
|
||||
|
||||
switch (error) {
|
||||
case ScrobbleErrorCode::NoError:
|
||||
return QStringLiteral("This error does not exist.");
|
||||
return u"This error does not exist."_s;
|
||||
case ScrobbleErrorCode::InvalidService:
|
||||
return QStringLiteral("Invalid service - This service does not exist.");
|
||||
return u"Invalid service - This service does not exist."_s;
|
||||
case ScrobbleErrorCode::InvalidMethod:
|
||||
return QStringLiteral("Invalid Method - No method with that name in this package.");
|
||||
return u"Invalid Method - No method with that name in this package."_s;
|
||||
case ScrobbleErrorCode::AuthenticationFailed:
|
||||
return QStringLiteral("Authentication Failed - You do not have permissions to access the service.");
|
||||
return u"Authentication Failed - You do not have permissions to access the service."_s;
|
||||
case ScrobbleErrorCode::InvalidFormat:
|
||||
return QStringLiteral("Invalid format - This service doesn't exist in that format.");
|
||||
return u"Invalid format - This service doesn't exist in that format."_s;
|
||||
case ScrobbleErrorCode::InvalidParameters:
|
||||
return QStringLiteral("Invalid parameters - Your request is missing a required parameter.");
|
||||
return u"Invalid parameters - Your request is missing a required parameter."_s;
|
||||
case ScrobbleErrorCode::InvalidResourceSpecified:
|
||||
return QStringLiteral("Invalid resource specified");
|
||||
return u"Invalid resource specified"_s;
|
||||
case ScrobbleErrorCode::OperationFailed:
|
||||
return QStringLiteral("Operation failed - Most likely the backend service failed. Please try again.");
|
||||
return u"Operation failed - Most likely the backend service failed. Please try again."_s;
|
||||
case ScrobbleErrorCode::InvalidSessionKey:
|
||||
return QStringLiteral("Invalid session key - Please re-authenticate.");
|
||||
return u"Invalid session key - Please re-authenticate."_s;
|
||||
case ScrobbleErrorCode::InvalidApiKey:
|
||||
return QStringLiteral("Invalid API key - You must be granted a valid key by last.fm.");
|
||||
return u"Invalid API key - You must be granted a valid key by last.fm."_s;
|
||||
case ScrobbleErrorCode::ServiceOffline:
|
||||
return QStringLiteral("Service Offline - This service is temporarily offline. Try again later.");
|
||||
return u"Service Offline - This service is temporarily offline. Try again later."_s;
|
||||
case ScrobbleErrorCode::SubscribersOnly:
|
||||
return QStringLiteral("Subscribers Only - This station is only available to paid last.fm subscribers.");
|
||||
return u"Subscribers Only - This station is only available to paid last.fm subscribers."_s;
|
||||
case ScrobbleErrorCode::InvalidMethodSignature:
|
||||
return QStringLiteral("Invalid method signature supplied.");
|
||||
return u"Invalid method signature supplied."_s;
|
||||
case ScrobbleErrorCode::UnauthorizedToken:
|
||||
return QStringLiteral("Unauthorized Token - This token has not been authorized.");
|
||||
return u"Unauthorized Token - This token has not been authorized."_s;
|
||||
case ScrobbleErrorCode::ItemUnavailable:
|
||||
return QStringLiteral("This item is not available for streaming.");
|
||||
return u"This item is not available for streaming."_s;
|
||||
case ScrobbleErrorCode::TemporarilyUnavailable:
|
||||
return QStringLiteral("The service is temporarily unavailable, please try again.");
|
||||
return u"The service is temporarily unavailable, please try again."_s;
|
||||
case ScrobbleErrorCode::LoginRequired:
|
||||
return QStringLiteral("Login: User requires to be logged in.");
|
||||
return u"Login: User requires to be logged in."_s;
|
||||
case ScrobbleErrorCode::TrialExpired:
|
||||
return QStringLiteral("Trial Expired - This user has no free radio plays left. Subscription required.");
|
||||
return u"Trial Expired - This user has no free radio plays left. Subscription required."_s;
|
||||
case ScrobbleErrorCode::ErrorDoesNotExist:
|
||||
return QStringLiteral("This error does not exist.");
|
||||
return u"This error does not exist."_s;
|
||||
case ScrobbleErrorCode::NotEnoughContent:
|
||||
return QStringLiteral("Not Enough Content - There is not enough content to play this station.");
|
||||
return u"Not Enough Content - There is not enough content to play this station."_s;
|
||||
case ScrobbleErrorCode::NotEnoughMembers:
|
||||
return QStringLiteral("Not Enough Members - This group does not have enough members for radio.");
|
||||
return u"Not Enough Members - This group does not have enough members for radio."_s;
|
||||
case ScrobbleErrorCode::NotEnoughFans:
|
||||
return QStringLiteral("Not Enough Fans - This artist does not have enough fans for for radio.");
|
||||
return u"Not Enough Fans - This artist does not have enough fans for for radio."_s;
|
||||
case ScrobbleErrorCode::NotEnoughNeighbours:
|
||||
return QStringLiteral("Not Enough Neighbours - There are not enough neighbours for radio.");
|
||||
return u"Not Enough Neighbours - There are not enough neighbours for radio."_s;
|
||||
case ScrobbleErrorCode::NoPeakRadio:
|
||||
return QStringLiteral("No Peak Radio - This user is not allowed to listen to radio during peak usage.");
|
||||
return u"No Peak Radio - This user is not allowed to listen to radio during peak usage."_s;
|
||||
case ScrobbleErrorCode::RadioNotFound:
|
||||
return QStringLiteral("Radio Not Found - Radio station not found.");
|
||||
return u"Radio Not Found - Radio station not found."_s;
|
||||
case ScrobbleErrorCode::APIKeySuspended:
|
||||
return QStringLiteral("Suspended API key - Access for your account has been suspended, please contact Last.fm");
|
||||
return u"Suspended API key - Access for your account has been suspended, please contact Last.fm"_s;
|
||||
case ScrobbleErrorCode::Deprecated:
|
||||
return QStringLiteral("Deprecated - This type of request is no longer supported.");
|
||||
return u"Deprecated - This type of request is no longer supported."_s;
|
||||
case ScrobbleErrorCode::RateLimitExceeded:
|
||||
return QStringLiteral("Rate limit exceeded - Your IP has made too many requests in a short period.");
|
||||
return u"Rate limit exceeded - Your IP has made too many requests in a short period."_s;
|
||||
}
|
||||
|
||||
return QStringLiteral("Unknown error.");
|
||||
return u"Unknown error."_s;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
|
||||
namespace Utilities {
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
QString PrettyTime(int seconds) {
|
||||
|
||||
// last.fm sometimes gets the track length wrong, so you end up with negative times.
|
||||
@@ -82,8 +84,8 @@ QString Ago(const qint64 seconds_since_epoch, const QLocale &locale) {
|
||||
const qint64 days_ago = then.date().daysTo(now.date());
|
||||
const QString time = then.time().toString(locale.timeFormat(QLocale::ShortFormat));
|
||||
|
||||
if (days_ago == 0) return QObject::tr("Today") + QLatin1Char(' ') + time;
|
||||
if (days_ago == 1) return QObject::tr("Yesterday") + QLatin1Char(' ') + time;
|
||||
if (days_ago == 0) return QObject::tr("Today") + u' ' + time;
|
||||
if (days_ago == 1) return QObject::tr("Yesterday") + u' ' + time;
|
||||
if (days_ago <= 7) return QObject::tr("%1 days ago").arg(days_ago);
|
||||
|
||||
return then.date().toString(locale.dateFormat(QLocale::ShortFormat));
|
||||
@@ -107,7 +109,7 @@ QString PrettyFutureDate(const QDate date) {
|
||||
|
||||
QDateTime ParseRFC822DateTime(const QString &text) {
|
||||
|
||||
static const QRegularExpression regexp(QStringLiteral("(\\d{1,2}) (\\w{3,12}) (\\d+) (\\d{1,2}):(\\d{1,2}):(\\d{1,2})"));
|
||||
static const QRegularExpression regexp(u"(\\d{1,2}) (\\w{3,12}) (\\d+) (\\d{1,2}):(\\d{1,2}):(\\d{1,2})"_s);
|
||||
QRegularExpressionMatch re_match = regexp.match(text);
|
||||
if (!re_match.hasMatch()) {
|
||||
return QDateTime();
|
||||
@@ -116,30 +118,30 @@ QDateTime ParseRFC822DateTime(const QString &text) {
|
||||
enum class MatchNames { DAYS = 1, MONTHS, YEARS, HOURS, MINUTES, SECONDS };
|
||||
|
||||
QMap<QString, int> monthmap;
|
||||
monthmap[QStringLiteral("Jan")] = 1;
|
||||
monthmap[QStringLiteral("Feb")] = 2;
|
||||
monthmap[QStringLiteral("Mar")] = 3;
|
||||
monthmap[QStringLiteral("Apr")] = 4;
|
||||
monthmap[QStringLiteral("May")] = 5;
|
||||
monthmap[QStringLiteral("Jun")] = 6;
|
||||
monthmap[QStringLiteral("Jul")] = 7;
|
||||
monthmap[QStringLiteral("Aug")] = 8;
|
||||
monthmap[QStringLiteral("Sep")] = 9;
|
||||
monthmap[QStringLiteral("Oct")] = 10;
|
||||
monthmap[QStringLiteral("Nov")] = 11;
|
||||
monthmap[QStringLiteral("Dec")] = 12;
|
||||
monthmap[QStringLiteral("January")] = 1;
|
||||
monthmap[QStringLiteral("February")] = 2;
|
||||
monthmap[QStringLiteral("March")] = 3;
|
||||
monthmap[QStringLiteral("April")] = 4;
|
||||
monthmap[QStringLiteral("May")] = 5;
|
||||
monthmap[QStringLiteral("June")] = 6;
|
||||
monthmap[QStringLiteral("July")] = 7;
|
||||
monthmap[QStringLiteral("August")] = 8;
|
||||
monthmap[QStringLiteral("September")] = 9;
|
||||
monthmap[QStringLiteral("October")] = 10;
|
||||
monthmap[QStringLiteral("November")] = 11;
|
||||
monthmap[QStringLiteral("December")] = 12;
|
||||
monthmap[u"Jan"_s] = 1;
|
||||
monthmap[u"Feb"_s] = 2;
|
||||
monthmap[u"Mar"_s] = 3;
|
||||
monthmap[u"Apr"_s] = 4;
|
||||
monthmap[u"May"_s] = 5;
|
||||
monthmap[u"Jun"_s] = 6;
|
||||
monthmap[u"Jul"_s] = 7;
|
||||
monthmap[u"Aug"_s] = 8;
|
||||
monthmap[u"Sep"_s] = 9;
|
||||
monthmap[u"Oct"_s] = 10;
|
||||
monthmap[u"Nov"_s] = 11;
|
||||
monthmap[u"Dec"_s] = 12;
|
||||
monthmap[u"January"_s] = 1;
|
||||
monthmap[u"February"_s] = 2;
|
||||
monthmap[u"March"_s] = 3;
|
||||
monthmap[u"April"_s] = 4;
|
||||
monthmap[u"May"_s] = 5;
|
||||
monthmap[u"June"_s] = 6;
|
||||
monthmap[u"July"_s] = 7;
|
||||
monthmap[u"August"_s] = 8;
|
||||
monthmap[u"September"_s] = 9;
|
||||
monthmap[u"October"_s] = 10;
|
||||
monthmap[u"November"_s] = 11;
|
||||
monthmap[u"December"_s] = 12;
|
||||
|
||||
const QDate date(re_match.captured(static_cast<int>(MatchNames::YEARS)).toInt(), monthmap[re_match.captured(static_cast<int>(MatchNames::MONTHS))], re_match.captured(static_cast<int>(MatchNames::DAYS)).toInt());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user