1
0
Fork 0
mirror of https://github.com/librespot-org/librespot.git synced 2025-10-04 02:09:26 +02:00

Easier mocking of platforms (#1378)

* core: move OS info into config.rs
This commit is contained in:
Felix Prillwitz 2024-10-21 22:11:38 +02:00 committed by GitHub
parent 4580dab73f
commit 2e655e7f80
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 25 additions and 15 deletions

View file

@ -1,6 +1,5 @@
use std::{
collections::HashMap,
env::consts::OS,
time::{Duration, Instant},
};
@ -21,11 +20,11 @@ use hyper_util::{
use nonzero_ext::nonzero;
use once_cell::sync::OnceCell;
use parking_lot::Mutex;
use sysinfo::System;
use thiserror::Error;
use url::Url;
use crate::{
config::{os_version, OS},
date::Date,
version::{spotify_version, FALLBACK_USER_AGENT, VERSION_STRING},
Error,
@ -106,12 +105,10 @@ pub struct HttpClient {
impl HttpClient {
pub fn new(proxy_url: Option<&Url>) -> Self {
let zero_str = String::from("0");
let os_version = System::os_version().unwrap_or_else(|| zero_str.clone());
let os_version = os_version();
let (spotify_platform, os_version) = match OS {
// example os_version: 30
"android" => ("Android", os_version),
// example os_version: 17
"ios" => ("iOS", os_version),
"macos" => ("OSX", zero_str),
"windows" => ("Win32", zero_str),