Remove 175 transitive dependencies
This commit removes *175* crate dependencies from the build by:
* removing unused logging features from fruitbasket crate
* replacing regex with dumb string searches
* vendoring rustfm-scrobble, modifying to use 'curl' instead of 'reqwest'
* vendoring rust-url just to include percent-encoding subcrate directly
Dropped from 275 to 100 crates built. Build time and binary size both
halved as well.
[submodule "deps/systray-rs"]
path = deps/systray-rs
url = https://github.com/mrmekon/systray-rs
-[submodule "deps/timer.rs"]
- path = deps/timer.rs
- url = https://github.com/mrmekon/timer.rs
+[submodule "deps/rustfm-scrobble"]
+ path = deps/rustfm-scrobble
+ url = https://github.com/mrmekon/rustfm-scrobble.git
+[submodule "deps/rust-url"]
+ path = deps/rust-url
+ url = https://github.com/servo/rust-url.git
[dependencies]
curl = "0.4.11"
open = "1.2.1"
-regex = "1.1"
serde = "1.0.37"
serde_json = "1.0.13"
serde_derive = "1.0"
-url = "1.7"
rust-ini = "0.13"
time = "0.1"
-#timer = {path = "deps/timer.rs", version="0.1.4"} # Modified for chrono 0.3.1
timer = "0.2"
chrono = "0.4"
log = "0.4"
-log4rs = "0.8"
ctrlc = "3.1"
dirs = "2.0"
-rustfm-scrobble = {version="0.9.1", optional = true}
+percent-encoding = {version="1.0.2", path="deps/rust-url/percent_encoding/"}
+rustfm-scrobble = {version="0.9.2", optional = true, path = "deps/rustfm-scrobble/"}
[dependencies.fruitbasket]
-version = "^0.7"
+version = "0.8"
features = ["logging"]
[target."cfg(windows)".dependencies]
[target."cfg(windows)".dependencies.rubrail]
default-features=false
-version = "^0.8"
+version = "0.9"
[target."cfg(all(unix, not(target_os = \"macos\")))".dependencies]
[target."cfg(all(unix, not(target_os = \"macos\")))".dependencies.rubrail]
default-features = false
-version = "^0.8"
+version = "0.9"
[target."cfg(target_os = \"macos\")".dependencies]
cocoa = "0.18"
objc_id = "0.1"
[target."cfg(target_os = \"macos\")".dependencies.rubrail]
-version = "^0.8"
+version = "0.9"
[target."cfg(target_os = \"macos\")".dependencies.objc]
version = "0.2"
+Subproject commit c1914b3a27c657eac1def4a85aa97717460c3061
+Subproject commit b6bf724631a50592fa1a8967f8232808710aac78
-Subproject commit 9052a51a4a7d66a517926198a16d278d2cc22662
use std::time::Duration;
use std::collections::BTreeMap;
-extern crate regex;
-use self::regex::Regex;
-
extern crate curl;
use self::curl::easy::{Easy, List};
extern crate time;
extern crate open;
-extern crate url;
-use self::url::percent_encoding;
+extern crate percent_encoding;
use super::settings;
let stream = conn.unwrap().0;
let mut reader = BufReader::new(stream);
let mut response = Vec::<String>::new();
- let mut post_bytes: u32 = 0;
- let re = Regex::new(r"Content-Length: ([0-9 ]+)").unwrap();
+ let post_bytes: u32 = 0;
for line in reader.by_ref().lines() {
if let Ok(line_str) = line {
- if re.is_match(line_str.as_str()) {
- post_bytes = re.captures(line_str.as_str()).unwrap()[1].parse::<u32>().unwrap();
+ if line_str.starts_with("Content-Length: ") {
+ line_str[16..].parse::<u32>().unwrap_or(0);
}
response.push(line_str.clone());
if line_str == "" {
fn spotify_auth_code(lines: Vec<String>) -> String {
let mut auth_code = String::new();
+ // Looking for HTTP request header with format:
+ // GET /?code=<MASSIVE STRING> HTTP/1.1
for line in lines {
let line_str = line;
- let re = Regex::new(r"code=([^?& ]+)").unwrap();
- let ismatch = re.is_match(line_str.as_str());
- if ismatch {
- let cap = re.captures(line_str.as_str()).unwrap();
- auth_code = auth_code + &cap[1];
+ if !line_str.starts_with("GET ") {
+ continue;
}
+ let code_idx = line_str.find("code=").unwrap_or(line_str.len() - 5) + 5;
+ let code_end_idx = line_str[code_idx..].find(|c| { c == '&' || c == '?' || c == ' '}).unwrap_or(line_str.len() - code_idx) + code_idx;
+ auth_code.push_str(&line_str[code_idx..code_end_idx]);
}
auth_code
}
#[macro_use]
extern crate log;
-extern crate log4rs;
use std::ptr;
use std::thread;