Receive autoplay and other attributes

This commit is contained in:
Roderick van Domburg 2021-12-11 16:43:34 +01:00
parent 9a0d2390b7
commit 51b6c46fcd
No known key found for this signature in database
GPG key ID: A9EF5222A26F0451
3 changed files with 17 additions and 8 deletions

View file

@ -14,6 +14,7 @@ use crate::protocol;
use crate::protocol::keyexchange::{ use crate::protocol::keyexchange::{
APResponseMessage, ClientHello, ClientResponsePlaintext, Platform, ProductFlags, APResponseMessage, ClientHello, ClientResponsePlaintext, Platform, ProductFlags,
}; };
use crate::version;
pub async fn handshake<T: AsyncRead + AsyncWrite + Unpin>( pub async fn handshake<T: AsyncRead + AsyncWrite + Unpin>(
mut connection: T, mut connection: T,
@ -84,13 +85,17 @@ where
let mut packet = ClientHello::new(); let mut packet = ClientHello::new();
packet packet
.mut_build_info() .mut_build_info()
.set_product(protocol::keyexchange::Product::PRODUCT_LIBSPOTIFY); // ProductInfo won't push autoplay and perhaps other settings
// when set to anything else than PRODUCT_CLIENT
.set_product(protocol::keyexchange::Product::PRODUCT_CLIENT);
packet packet
.mut_build_info() .mut_build_info()
.mut_product_flags() .mut_product_flags()
.push(PRODUCT_FLAGS); .push(PRODUCT_FLAGS);
packet.mut_build_info().set_platform(platform); packet.mut_build_info().set_platform(platform);
packet.mut_build_info().set_version(999999999); packet
.mut_build_info()
.set_version(version::SPOTIFY_VERSION);
packet packet
.mut_cryptosuites_supported() .mut_cryptosuites_supported()
.push(protocol::keyexchange::Cryptosuite::CRYPTO_SUITE_SHANNON); .push(protocol::keyexchange::Cryptosuite::CRYPTO_SUITE_SHANNON);

View file

@ -9,7 +9,7 @@ use std::env::consts::OS;
use thiserror::Error; use thiserror::Error;
use url::Url; use url::Url;
use crate::version; use crate::version::{SPOTIFY_MOBILE_VERSION, SPOTIFY_VERSION, VERSION_STRING};
pub struct HttpClient { pub struct HttpClient {
proxy: Option<Url>, proxy: Option<Url>,
@ -54,8 +54,8 @@ impl HttpClient {
let connector = HttpsConnector::with_native_roots(); let connector = HttpsConnector::with_native_roots();
let spotify_version = match OS { let spotify_version = match OS {
"android" | "ios" => "8.6.84", "android" | "ios" => SPOTIFY_MOBILE_VERSION.to_owned(),
_ => "117300517", _ => SPOTIFY_VERSION.to_string(),
}; };
let spotify_platform = match OS { let spotify_platform = match OS {
@ -72,9 +72,7 @@ impl HttpClient {
// Some features like lyrics are version-gated and require an official version string. // Some features like lyrics are version-gated and require an official version string.
HeaderValue::from_str(&format!( HeaderValue::from_str(&format!(
"Spotify/{} {} ({})", "Spotify/{} {} ({})",
spotify_version, spotify_version, spotify_platform, VERSION_STRING
spotify_platform,
version::VERSION_STRING
))?, ))?,
); );

View file

@ -15,3 +15,9 @@ pub const SEMVER: &str = env!("CARGO_PKG_VERSION");
/// A random build id. /// A random build id.
pub const BUILD_ID: &str = env!("LIBRESPOT_BUILD_ID"); pub const BUILD_ID: &str = env!("LIBRESPOT_BUILD_ID");
/// The protocol version of the Spotify desktop client.
pub const SPOTIFY_VERSION: u64 = 117300517;
/// The protocol version of the Spotify mobile app.
pub const SPOTIFY_MOBILE_VERSION: &str = "8.6.84";