mirror of
https://github.com/strawberrymusicplayer/strawberry
synced 2025-02-03 10:57:33 +01:00
Decode HTML entities in lyrics
This commit is contained in:
parent
c5cd648b5d
commit
b85819ed9d
@ -650,11 +650,17 @@ QStringList Updateify(const QStringList &list) {
|
||||
QString DecodeHtmlEntities(const QString &text) {
|
||||
|
||||
QString copy(text);
|
||||
copy.replace("&", "&");
|
||||
copy.replace(""", "\"");
|
||||
copy.replace("'", "'");
|
||||
copy.replace("<", "<");
|
||||
copy.replace(">", ">");
|
||||
copy.replace("&", "&")
|
||||
.replace("&", "&")
|
||||
.replace(""", "\"")
|
||||
.replace(""", "\"")
|
||||
.replace("'", "'")
|
||||
.replace("'", "'")
|
||||
.replace("<", "<")
|
||||
.replace("<", "<")
|
||||
.replace(">", ">")
|
||||
.replace(">", ">");
|
||||
|
||||
return copy;
|
||||
|
||||
}
|
||||
|
@ -37,6 +37,7 @@
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/network.h"
|
||||
#include "core/utilities.h"
|
||||
#include "jsonlyricsprovider.h"
|
||||
#include "lyricsfetcher.h"
|
||||
#include "lyricsprovider.h"
|
||||
@ -129,6 +130,7 @@ void AuddLyricsProvider::HandleSearchReply(QNetworkReply *reply, const quint64 i
|
||||
if (result.artist.toLower() != artist.toLower() && result.title.toLower() != title.toLower()) continue;
|
||||
result.lyrics = json_obj["lyrics"].toString();
|
||||
if (result.lyrics.isEmpty() || result.lyrics.length() > kMaxLength || result.lyrics == "error") continue;
|
||||
result.lyrics = Utilities::DecodeHtmlEntities(result.lyrics);
|
||||
|
||||
//qLog(Debug) << "AudDLyrics:" << result.artist << result.title << result.lyrics.length();
|
||||
|
||||
|
@ -127,6 +127,7 @@ void ChartLyricsProvider::HandleSearchReply(QNetworkReply *reply, const quint64
|
||||
else if (type == QXmlStreamReader::EndElement) {
|
||||
if (name == "GetLyricResult") {
|
||||
if (!result.artist.isEmpty() && !result.title.isEmpty() && !result.lyrics.isEmpty() && (result.artist.toLower() == artist.toLower() || result.title.toLower() == title.toLower())) {
|
||||
result.lyrics = Utilities::DecodeHtmlEntities(result.lyrics);
|
||||
results << result;
|
||||
}
|
||||
result = LyricsSearchResult();
|
||||
|
@ -515,7 +515,7 @@ void GeniusLyricsProvider::HandleLyricReply(QNetworkReply *reply, const int sear
|
||||
LyricsSearchResult result;
|
||||
result.artist = lyric.artist;
|
||||
result.title = lyric.title;
|
||||
result.lyrics = lyrics;
|
||||
result.lyrics = Utilities::DecodeHtmlEntities(lyrics);
|
||||
search->results.append(result);
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/network.h"
|
||||
#include "core/utilities.h"
|
||||
#include "lyricsprovider.h"
|
||||
#include "lyricsfetcher.h"
|
||||
#include "lololyricsprovider.h"
|
||||
@ -137,6 +138,7 @@ void LoloLyricsProvider::HandleSearchReply(QNetworkReply *reply, const quint64 i
|
||||
else if (type == QXmlStreamReader::EndElement) {
|
||||
if (name == "result") {
|
||||
if (!result.lyrics.isEmpty()) {
|
||||
result.lyrics = Utilities::DecodeHtmlEntities(result.lyrics);
|
||||
results << result;
|
||||
}
|
||||
result = LyricsSearchResult();
|
||||
|
@ -34,6 +34,7 @@
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/network.h"
|
||||
#include "core/utilities.h"
|
||||
#include "jsonlyricsprovider.h"
|
||||
#include "lyricsfetcher.h"
|
||||
#include "lyricsprovider.h"
|
||||
@ -200,6 +201,7 @@ void MusixmatchLyricsProvider::HandleSearchReply(QNetworkReply *reply, const qui
|
||||
result.lyrics = obj_lyrics["body"].toString();
|
||||
|
||||
if (!result.lyrics.isEmpty() && (artist.toLower() == result.artist.toLower() || title.toLower() == result.title.toLower())) {
|
||||
result.lyrics = Utilities::DecodeHtmlEntities(result.lyrics);
|
||||
results.append(result);
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/network.h"
|
||||
#include "core/utilities.h"
|
||||
#include "lyricsfetcher.h"
|
||||
#include "jsonlyricsprovider.h"
|
||||
#include "ovhlyricsprovider.h"
|
||||
@ -107,6 +108,7 @@ void OVHLyricsProvider::HandleSearchReply(QNetworkReply *reply, const quint64 id
|
||||
emit SearchFinished(id, LyricsSearchResults());
|
||||
}
|
||||
else {
|
||||
result.lyrics = Utilities::DecodeHtmlEntities(result.lyrics);
|
||||
qLog(Debug) << "OVHLyrics: Got lyrics for" << artist << title;
|
||||
emit SearchFinished(id, LyricsSearchResults() << result);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user