mirror of
https://github.com/badaix/snapcast.git
synced 2025-07-28 22:07:51 +02:00
x-out spotify username and password
This commit is contained in:
parent
baf5a7af3b
commit
a490402721
3 changed files with 42 additions and 2 deletions
|
@ -51,6 +51,11 @@ SpotifyStream::SpotifyStream(PcmListener* pcmListener, const StreamUri& uri) : P
|
|||
params_ += " --onstart \"" + onstart + "\"";
|
||||
if (!onstop.empty())
|
||||
params_ += " --onstop \"" + onstop + "\"";
|
||||
|
||||
if (uri_.query.find("username") != uri_.query.end())
|
||||
uri_.query["username"] = "xxx";
|
||||
if (uri_.query.find("password") != uri_.query.end())
|
||||
uri_.query["password"] = "xxx";
|
||||
// LOG(INFO) << "params: " << params << "\n";
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,14 @@ using namespace std;
|
|||
namespace strutils = utils::string;
|
||||
|
||||
|
||||
StreamUri::StreamUri(const std::string& streamUri)
|
||||
StreamUri::StreamUri(const std::string& uri)
|
||||
{
|
||||
parse(uri);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void StreamUri::parse(const std::string& streamUri)
|
||||
{
|
||||
// https://en.wikipedia.org/wiki/Uniform_Resource_Identifier
|
||||
// scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]
|
||||
|
@ -92,13 +99,38 @@ StreamUri::StreamUri(const std::string& streamUri)
|
|||
query[key] = value;
|
||||
}
|
||||
}
|
||||
LOG(DEBUG) << "StreamUri.toString: " << toString() << "\n";
|
||||
}
|
||||
|
||||
|
||||
std::string StreamUri::toString() const
|
||||
{
|
||||
// scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]
|
||||
stringstream ss;
|
||||
ss << scheme << "://" << host << "/" + path;
|
||||
if (!query.empty())
|
||||
{
|
||||
ss << "?";
|
||||
auto iter = query.begin();
|
||||
while (true)
|
||||
{
|
||||
ss << iter->first << "=" << iter->second;
|
||||
if (++iter == query.end())
|
||||
break;
|
||||
ss << "&";
|
||||
}
|
||||
}
|
||||
if (!fragment.empty())
|
||||
ss << "#" << fragment;
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
|
||||
json StreamUri::toJson() const
|
||||
{
|
||||
json j = {
|
||||
{"raw", uri},
|
||||
{"raw", toString()},
|
||||
{"scheme", scheme},
|
||||
{"host", host},
|
||||
{"path", path},
|
||||
|
|
|
@ -49,6 +49,9 @@ struct StreamUri
|
|||
std::string id() const;
|
||||
json toJson() const;
|
||||
std::string getQuery(const std::string& key, const std::string& def = "") const;
|
||||
|
||||
void parse(const std::string& streamUri);
|
||||
std::string toString() const;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue