Merge branch 'ncmpcpp:master' into master

This commit is contained in:
Salastil
2025-04-21 18:56:55 -04:00
committed by GitHub
4 changed files with 21 additions and 4 deletions

View File

@@ -1,3 +1,7 @@
# ncmpcpp-0.10.2 (2025-??-??)
* Update lyrics fetchers.
* Add support for hexadecimal HTML escape codes.
# ncmpcpp-0.10.1 (2024-10-24)
* Fix compilation with `libc++`.
* Remove `autogen.sh` in favour of `autoreconf`.

View File

@@ -1,4 +1,4 @@
AC_INIT([ncmpcpp],[0.10.1])
AC_INIT([ncmpcpp],[0.10.2_dev])
AC_CONFIG_SRCDIR([configure.ac])
AC_CONFIG_HEADERS(config.h)
AM_INIT_AUTOMAKE([subdir-objects])

View File

@@ -84,7 +84,7 @@ struct GeniusFetcher : public GoogleLyricsFetcher
virtual const char *name() const override { return "genius.com"; }
protected:
virtual const char *regex() const override { return "<div.*?class=\"(?:lyrics|Lyrics__Container).*?>(.*?)</div>"; }
virtual const char *regex() const override { return "<div data-lyrics-container.*?>(.*?)</div>"; }
};
struct JahLyricsFetcher : public GoogleLyricsFetcher
@@ -116,7 +116,7 @@ struct ZeneszovegFetcher : public GoogleLyricsFetcher
virtual const char *name() const override { return "zeneszoveg.hu"; }
protected:
virtual const char *regex() const override { return "<div id=\"tartalom_slide_content\"> (.*?)<style>"; }
virtual const char *regex() const override { return "<div class=\"lyrics-plain-text trans_original\">(.*?)</div>"; }
};
struct InternetLyricsFetcher : public GoogleLyricsFetcher

View File

@@ -20,16 +20,29 @@
#include <algorithm>
#include <boost/algorithm/string/replace.hpp>
#include <cstdlib>
#include "utility/html.h"
std::string unescapeHtmlUtf8(const std::string &data)
{
int base;
size_t offset;
std::string result;
for (size_t i = 0, j; i < data.length(); ++i)
{
if (data[i] == '&' && data[i+1] == '#' && (j = data.find(';', i)) != std::string::npos)
{
int n = atoi(&data.c_str()[i+2]);
if (data[i+2] == 'x')
{
offset = 3;
base = 16;
}
else
{
offset = 2;
base = 10;
}
int n = strtol(&data.c_str()[i+offset], nullptr, base);
if (n >= 0x800)
{
result += (0xe0 | ((n >> 12) & 0x0f));