Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getFavorites() returns fewer entries due to wrong User-Agent #540

Open
jordansissel opened this issue Jan 21, 2023 · 0 comments
Open

getFavorites() returns fewer entries due to wrong User-Agent #540

jordansissel opened this issue Jan 21, 2023 · 0 comments

Comments

@jordansissel
Copy link

jordansissel commented Jan 21, 2023

When calling getFavorites(), in my test, node-sonos gives me two (2) results. In the macOS Sonos app, I show four (4) entries.

Expected Behavior

It should return the same items as the Sonos app has.

Current Behavior

It omits (due to some weirdness in Sonos UPnP?) certain records.

Possible Solution

const axios = require("axios");
axios.defaults.headers.common['User-Agent'] = "Linux UPnP/1.0 Sonos/70.4-35282 (MDCR_Mac14,2)"

This sets the default 'User-Agent' header on all axios requests.

I discovered this by sniffing traffic between the Sonos app and my network and comparing the results, then trying to change one thing at a time to see what improved the outcome.

Sample code or executed example

      device.getFavorites()
        .then(result => { console.log(`Total (default): ${result.total}`) })
        .then(() => {
            const axios = require("axios");
            axios.defaults.headers.common['User-Agent'] = "Linux UPnP/1.0 Sonos/70.4-35282 (MDCR_Mac14,2)"
            return device.getFavorites()
        }).then(result => { console.log(`Total (after setting user-agent): ${result.total}`) })
Total (default): 2
Total (after setting user-agent): 4

Versions (and Environment)

Node version: v19.2.0
node-sonos version: 1.14.1
OS: macOS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant