Made UserAgent configurable and docs

This commit is contained in:
Jonas Dellinger 2018-07-18 21:51:56 +02:00
parent 1cae73b1c1
commit 6763d3cccc
3 changed files with 15 additions and 1 deletions

View File

@ -52,6 +52,18 @@ _spotify = new SpotifyLocalAPI(new SpotifyLocalAPIConfig
});
```
it's also possible to change the current `UserAgent` string, which is needed if the library wasn't updated for some time. In this case, you should first make an unauthenticated call with `spotify.GetStatus()`, receive the current spotify version, and update the config afterwards:
```cs
var config = new SpotifyLocalAPIConfig { Port = 4371, HostUrl = "https://127.0.0.1" });
_spotify = new SpotifyLocalAPI(config);
var status = _spotify.GetStatus();
config.UserAgent = status.ClientVersion;
// Now you should call auth stuff, like "_spotify.Connect()"
```
## Proxy Settings
You can forward your proxy settings to the local api by using a field in the `SpotifyLocalAPIConfig`.

View File

@ -186,7 +186,7 @@ namespace SpotifyAPI.Local
{
Proxy = _config?.ProxyConfig?.CreateWebProxy()
};
wc.Headers.Add(HttpRequestHeader.UserAgent, "Spotify (1.0.85.257.g0f8531bd)");
wc.Headers.Add(HttpRequestHeader.UserAgent, _config?.UserAgent);
return wc;
}

View File

@ -10,5 +10,7 @@
public int Port { get; set; } = 4381;
public ProxyConfig ProxyConfig { get; set; }
public string UserAgent { get; set; } = "Spotify (1.0.85.257.g0f8531bd)";
}
}