mirror of
https://github.com/badaix/snapcast.git
synced 2025-06-06 21:01:42 +02:00
Added basics for maintaining metadata by stream on server and pushing to clients.
Modified Spotify stream handler to get the track name from Libreelec's stderr. Note, to support artist/album (or album art) we need to modify Libreelec to print these.
This commit is contained in:
parent
034c7f5f98
commit
d444052233
11 changed files with 166 additions and 2 deletions
|
@ -16,6 +16,7 @@
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <regex>
|
||||
#include "spotifyStream.h"
|
||||
#include "common/snapException.h"
|
||||
#include "common/utils/string_utils.h"
|
||||
|
@ -92,6 +93,9 @@ void SpotifyStream::initExeAndPath(const std::string& filename)
|
|||
|
||||
void SpotifyStream::onStderrMsg(const char* buffer, size_t n)
|
||||
{
|
||||
// Watch stderr for 'Loading track' messages and set the stream metadata
|
||||
// For more than track name check: https://github.com/plietar/librespot/issues/154
|
||||
|
||||
/// Watch will kill librespot if there was no message received for 130min
|
||||
// 2016-11-02 22-05-15 [out] TRACE:librespot::stream: allocated stream 3580
|
||||
// 2016-11-02 22-05-15 [Debug] DEBUG:librespot::audio_file2: Got channel 3580
|
||||
|
@ -118,6 +122,19 @@ void SpotifyStream::onStderrMsg(const char* buffer, size_t n)
|
|||
{
|
||||
LOG(INFO) << "(" << getName() << ") " << logmsg << "\n";
|
||||
}
|
||||
|
||||
// Check for metadata
|
||||
if (logmsg.find("Loading track") != string::npos)
|
||||
{
|
||||
regex re("Loading track \"(.*)\"");
|
||||
smatch m;
|
||||
|
||||
if (regex_search(logmsg, m, re))
|
||||
{
|
||||
LOG(INFO) << "Loading track (" << m[1] << ")\n";
|
||||
getMeta()->setTrack(m[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue