diff --git a/NEWS b/NEWS index 810685c0b..cb203da29 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,7 @@ ver 0.22 (not yet released) * tags - new tags "Grouping" (for ID3 "TIT1") and "Work" * input + - curl: support "charset" parameter in URI fragment - ffmpeg: allow partial reads * archive - iso9660: support seeking diff --git a/doc/user.rst b/doc/user.rst index 6f07cf89e..70093874a 100644 --- a/doc/user.rst +++ b/doc/user.rst @@ -985,6 +985,22 @@ is no way for :program:`MPD` to find out whether the DAC supports it. DSD to PCM conversion is the fallback if DSD cannot be used directly. +ICY-MetaData +------------ + +Some MP3 streams send information about the current song with a +protocol named `"ICY-MetaData" +`_. +:program:`MPD` makes its ``StreamTitle`` value available as ``Title`` +tag. + +By default, :program:`MPD` assumes this tag is UTF-8-encoded. To tell +:program:`MPD` to assume a different character set, specify it in the +``charset`` URL fragment parameter, e.g.:: + + mpc add 'http://radio.example.com/stream#charset=cp1251' + + Client Hacks ************ diff --git a/src/input/IcyInputStream.cxx b/src/input/IcyInputStream.cxx index af61eda56..0a1703c90 100644 --- a/src/input/IcyInputStream.cxx +++ b/src/input/IcyInputStream.cxx @@ -20,11 +20,27 @@ #include "IcyInputStream.hxx" #include "IcyMetaDataParser.hxx" #include "tag/Tag.hxx" +#include "util/UriExtract.hxx" +#include "util/UriQueryParser.hxx" +#include "util/StringView.hxx" + +#include IcyInputStream::IcyInputStream(InputStreamPtr _input, - std::shared_ptr _parser) noexcept + std::shared_ptr _parser) :ProxyInputStream(std::move(_input)), parser(std::move(_parser)) { +#ifdef HAVE_ICU_CONVERTER + const char *fragment = uri_get_fragment(GetURI()); + if (fragment != nullptr) { + const auto charset = UriFindRawQueryParameter(fragment, + "charset"); + if (charset != nullptr) { + const std::string copy(charset.data, charset.size); + parser->SetCharset(copy.c_str()); + } + } +#endif } IcyInputStream::~IcyInputStream() noexcept = default; diff --git a/src/input/IcyInputStream.hxx b/src/input/IcyInputStream.hxx index f3f68b7bf..693dd82a5 100644 --- a/src/input/IcyInputStream.hxx +++ b/src/input/IcyInputStream.hxx @@ -52,9 +52,12 @@ public: * with our input; it needs to be shared because our input * needs to feed parameters (e.g. from the "icy-metaint" * header) into it + * + * Throws on error (e.g. if the charset converter specified by + * the URI fragment fails to initialize). */ IcyInputStream(InputStreamPtr _input, - std::shared_ptr _parser) noexcept; + std::shared_ptr _parser); virtual ~IcyInputStream() noexcept; IcyInputStream(const IcyInputStream &) = delete;