mirror of
https://github.com/wkulhanek/bonob.git
synced 2025-12-21 17:33:29 +01:00
Fix scrobbling. For real?
This commit is contained in:
@@ -608,17 +608,21 @@ function server(
|
|||||||
logger.debug(`Received Sonos reporting event (v${version}): ${JSON.stringify(req.body)}`);
|
logger.debug(`Received Sonos reporting event (v${version}): ${JSON.stringify(req.body)}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Sonos may send an array of reports
|
// Sonos may send an array of reports or a single report with items array
|
||||||
const reports = Array.isArray(req.body) ? req.body : [req.body];
|
const reports = Array.isArray(req.body) ? req.body : [req.body];
|
||||||
|
|
||||||
for (const report of reports) {
|
for (const report of reports) {
|
||||||
const {
|
// Handle both direct report format and items array format
|
||||||
reportId,
|
const items = report.items || [report];
|
||||||
mediaUrl,
|
|
||||||
durationPlayedMillis,
|
for (const item of items) {
|
||||||
positionMillis,
|
const {
|
||||||
type,
|
reportId,
|
||||||
} = report;
|
mediaUrl,
|
||||||
|
durationPlayedMillis,
|
||||||
|
positionMillis,
|
||||||
|
type,
|
||||||
|
} = item;
|
||||||
|
|
||||||
// Extract track ID from mediaUrl (format: /stream/track/{id} or x-sonos-http:track%3a{id}.mp3)
|
// Extract track ID from mediaUrl (format: /stream/track/{id} or x-sonos-http:track%3a{id}.mp3)
|
||||||
let trackId: string | undefined;
|
let trackId: string | undefined;
|
||||||
@@ -692,6 +696,7 @@ function server(
|
|||||||
logger.debug("No authentication available for reporting endpoint scrobble");
|
logger.debug("No authentication available for reporting endpoint scrobble");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.status(200).json({ status: "ok" });
|
return res.status(200).json({ status: "ok" });
|
||||||
|
|||||||
Reference in New Issue
Block a user