feat: rename module to soulseek-rs
This commit is contained in:
+26
-10
@@ -1,24 +1,40 @@
|
||||
fn main() {
|
||||
use soulseek_download::{Client, PeerAddress};
|
||||
use soulseek_rs::{Client, PeerAddress};
|
||||
use std::time::Duration;
|
||||
|
||||
let mut client = Client::new(
|
||||
PeerAddress::new(String::from("server.slsknet.org"), 2242),
|
||||
// PeerAddress::new(String::from("server.slsknet.org"), 2242),
|
||||
PeerAddress::new(String::from("127.0.0.1"), 2242),
|
||||
String::from("insane_in_the_brain3"),
|
||||
String::from("13375137"),
|
||||
);
|
||||
|
||||
client.connect();
|
||||
match client.login() {
|
||||
Ok(_) => {
|
||||
let results = client.search("Fantazia", Duration::from_secs(10));
|
||||
println!("Search results: {} - {:?} ", results.len(), results);
|
||||
if !results.is_empty() && !results[0].files.is_empty() {
|
||||
let file = results[0].files[0].clone();
|
||||
let download_result = client.download(file.name, file.username);
|
||||
println!("Download result: {:?}", download_result);
|
||||
Ok(_) => match client
|
||||
.search("michel test file", Duration::from_secs(20))
|
||||
{
|
||||
Ok(results) => {
|
||||
if let Some(result) =
|
||||
results.iter().find(|r| !r.files.is_empty())
|
||||
{
|
||||
let file = result.files[0].clone();
|
||||
match client.download(file.name, file.username, file.size) {
|
||||
Ok(download_result) => {
|
||||
println!("Download result: {:?}", download_result);
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("Failed to download: {}", e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
eprint!("No results")
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("Failed to search: {}", e);
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
eprintln!("Failed to login: {}", e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user