mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
parent
685fb4e345
commit
58ea1baa98
4 changed files with 12 additions and 11 deletions
|
@ -1,6 +1,4 @@
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use crypto::digest::Digest;
|
|
||||||
use crypto::sha1::Sha1;
|
|
||||||
use futures::{Async, Future, IntoFuture, Poll, Stream};
|
use futures::{Async, Future, IntoFuture, Poll, Stream};
|
||||||
use futures::sync::mpsc;
|
use futures::sync::mpsc;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
@ -45,12 +43,6 @@ static SESSION_COUNTER: AtomicUsize = ATOMIC_USIZE_INIT;
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Session(Arc<SessionInternal>);
|
pub struct Session(Arc<SessionInternal>);
|
||||||
|
|
||||||
pub fn device_id(name: &str) -> String {
|
|
||||||
let mut h = Sha1::new();
|
|
||||||
h.input_str(name);
|
|
||||||
h.result_str()
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Session {
|
impl Session {
|
||||||
pub fn connect(
|
pub fn connect(
|
||||||
config: SessionConfig,
|
config: SessionConfig,
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std;
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub struct u128 {
|
pub(crate) struct u128 {
|
||||||
high: u64,
|
high: u64,
|
||||||
low: u64,
|
low: u64,
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ use std::ops::{Mul, Rem, Shr};
|
||||||
|
|
||||||
mod int128;
|
mod int128;
|
||||||
|
|
||||||
pub use util::int128::u128;
|
pub(crate) use util::int128::u128;
|
||||||
|
|
||||||
pub fn rand_vec<G: Rng, R: Rand>(rng: &mut G, size: usize) -> Vec<R> {
|
pub fn rand_vec<G: Rng, R: Rand>(rng: &mut G, size: usize) -> Vec<R> {
|
||||||
rng.gen_iter().take(size).collect()
|
rng.gen_iter().take(size).collect()
|
||||||
|
|
11
src/main.rs
11
src/main.rs
|
@ -6,6 +6,7 @@ extern crate librespot;
|
||||||
extern crate tokio_core;
|
extern crate tokio_core;
|
||||||
extern crate tokio_io;
|
extern crate tokio_io;
|
||||||
extern crate tokio_signal;
|
extern crate tokio_signal;
|
||||||
|
extern crate crypto;
|
||||||
|
|
||||||
use env_logger::LogBuilder;
|
use env_logger::LogBuilder;
|
||||||
use futures::{Future, Async, Poll, Stream};
|
use futures::{Future, Async, Poll, Stream};
|
||||||
|
@ -17,6 +18,8 @@ use std::str::FromStr;
|
||||||
use tokio_core::reactor::{Handle, Core};
|
use tokio_core::reactor::{Handle, Core};
|
||||||
use tokio_io::IoStream;
|
use tokio_io::IoStream;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
use crypto::digest::Digest;
|
||||||
|
use crypto::sha1::Sha1;
|
||||||
|
|
||||||
use librespot::core::authentication::{get_credentials, Credentials};
|
use librespot::core::authentication::{get_credentials, Credentials};
|
||||||
use librespot::core::cache::Cache;
|
use librespot::core::cache::Cache;
|
||||||
|
@ -31,6 +34,12 @@ use librespot::playback::mixer::{self, Mixer};
|
||||||
use librespot::playback::player::Player;
|
use librespot::playback::player::Player;
|
||||||
use librespot::connect::spirc::{Spirc, SpircTask};
|
use librespot::connect::spirc::{Spirc, SpircTask};
|
||||||
|
|
||||||
|
fn device_id(name: &str) -> String {
|
||||||
|
let mut h = Sha1::new();
|
||||||
|
h.input_str(name);
|
||||||
|
h.result_str()
|
||||||
|
}
|
||||||
|
|
||||||
fn usage(program: &str, opts: &getopts::Options) -> String {
|
fn usage(program: &str, opts: &getopts::Options) -> String {
|
||||||
let brief = format!("Usage: {} [options]", program);
|
let brief = format!("Usage: {} [options]", program);
|
||||||
opts.usage(&brief)
|
opts.usage(&brief)
|
||||||
|
@ -170,7 +179,7 @@ fn setup(args: &[String]) -> Setup {
|
||||||
};
|
};
|
||||||
|
|
||||||
let session_config = {
|
let session_config = {
|
||||||
let device_id = librespot::core::session::device_id(&name);
|
let device_id = device_id(&name);
|
||||||
|
|
||||||
SessionConfig {
|
SessionConfig {
|
||||||
user_agent: version::version_string(),
|
user_agent: version::version_string(),
|
||||||
|
|
Loading…
Reference in a new issue