mirror of
https://github.com/librespot-org/librespot.git
synced 2025-10-04 02:09:26 +02:00
Lots of stuff
This commit is contained in:
parent
1ad62e6f18
commit
7ffe996652
28 changed files with 2076 additions and 101 deletions
59
src/main.rs
59
src/main.rs
|
@ -1,6 +1,6 @@
|
|||
#![crate_name = "librespot"]
|
||||
|
||||
#![feature(plugin)]
|
||||
#![feature(alloc,plugin,core,collections,std_misc,zero_one)]
|
||||
|
||||
#![plugin(protobuf_macros)]
|
||||
#[macro_use] extern crate lazy_static;
|
||||
|
@ -9,29 +9,45 @@ extern crate byteorder;
|
|||
extern crate crypto;
|
||||
extern crate gmp;
|
||||
extern crate num;
|
||||
extern crate portaudio;
|
||||
extern crate protobuf;
|
||||
extern crate shannon;
|
||||
extern crate rand;
|
||||
extern crate readall;
|
||||
extern crate vorbis;
|
||||
|
||||
extern crate librespot_protocol;
|
||||
|
||||
#[macro_use] mod util;
|
||||
mod audio_decrypt;
|
||||
mod audio_file;
|
||||
mod audio_key;
|
||||
mod connection;
|
||||
mod keys;
|
||||
mod mercury;
|
||||
mod metadata;
|
||||
mod player;
|
||||
mod session;
|
||||
mod util;
|
||||
mod stream;
|
||||
mod subsystem;
|
||||
|
||||
use std::clone::Clone;
|
||||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
use std::io::{Read, Write};
|
||||
use std::path::Path;
|
||||
|
||||
use session::{Session,Config};
|
||||
use metadata::{MetadataCache, AlbumRef, ArtistRef, TrackRef};
|
||||
use session::{Config, Session};
|
||||
use util::SpotifyId;
|
||||
use player::Player;
|
||||
|
||||
fn main() {
|
||||
let mut args = std::env::args().skip(1);
|
||||
let mut appkey_file = File::open(Path::new(&args.next().unwrap())).unwrap();
|
||||
let username = args.next().unwrap();
|
||||
let password = args.next().unwrap();
|
||||
let track_uri = args.next().unwrap();
|
||||
let track_id = SpotifyId::from_base62(track_uri.split(':').nth(2).unwrap());
|
||||
|
||||
let mut appkey = Vec::new();
|
||||
appkey_file.read_to_end(&mut appkey).unwrap();
|
||||
|
@ -41,8 +57,39 @@ fn main() {
|
|||
user_agent: "ABC".to_string(),
|
||||
device_id: "ABC".to_string()
|
||||
};
|
||||
let mut s = Session::new(config);
|
||||
let session = Session::new(config);
|
||||
session.login(username, password);
|
||||
session.poll();
|
||||
|
||||
s.login(username, password);
|
||||
let mut cache = MetadataCache::new(session.metadata.clone());
|
||||
let track : TrackRef = cache.get(track_id);
|
||||
|
||||
let album : AlbumRef = {
|
||||
let handle = track.wait();
|
||||
let data = handle.unwrap();
|
||||
eprintln!("{}", data.name);
|
||||
cache.get(data.album)
|
||||
};
|
||||
|
||||
let artists : Vec<ArtistRef> = {
|
||||
let handle = album.wait();
|
||||
let data = handle.unwrap();
|
||||
eprintln!("{}", data.name);
|
||||
data.artists.iter().map(|id| {
|
||||
cache.get(*id)
|
||||
}).collect()
|
||||
};
|
||||
|
||||
for artist in artists {
|
||||
let handle = artist.wait();
|
||||
let data = handle.unwrap();
|
||||
eprintln!("{}", data.name);
|
||||
}
|
||||
|
||||
Player::play(&session, track);
|
||||
|
||||
loop {
|
||||
session.poll();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue