Skip to content

Commit

Permalink
Add arg to change vlc status port.
Browse files Browse the repository at this point in the history
  • Loading branch information
mason-larobina committed Feb 22, 2024
1 parent 6ddc64e commit d2c47aa
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/classifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,6 @@ impl NaiveBayesClassifier {
*k = crate::round(*k);
}

scores
scores.into_iter().rev().take(32).collect()
}
}
3 changes: 3 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ struct Args {
#[clap(long)]
file_size_log_base: Option<f64>,

#[clap(long, default_value = "9010")]
vlc_port: u16,

#[arg(
long,
value_delimiter = ',',
Expand Down
8 changes: 4 additions & 4 deletions src/tokenizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ impl Tokenizer {
common_tokens.insert(token);
}
}
debug!("Drop unique tokens: {:?}", unique_tokens);
debug!("Drop common tokens: {:?}", common_tokens);
//debug!("Drop unique tokens: {:?}", unique_tokens);
//debug!("Drop common tokens: {:?}", common_tokens);

let mut ngram_counts: HashMap<Vec<Token>, usize> = HashMap::new();
for path in files.keys() {
Expand All @@ -96,8 +96,8 @@ impl Tokenizer {
common_ngrams.insert(ngram);
}
}
debug!("Drop unique ngrams: {:?}", unique_ngrams);
debug!("Drop common ngrams: {:?}", common_ngrams);
//debug!("Drop unique ngrams: {:?}", unique_ngrams);
//debug!("Drop common ngrams: {:?}", common_ngrams);

info!("File count: {}", file_count);
info!("Token count: {}", tokenizer.token_count);
Expand Down
15 changes: 10 additions & 5 deletions src/vlc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub struct Meta {

pub struct VLCProcessHandle {
handle: Option<Child>,
status_url: String,
}

impl VLCProcessHandle {
Expand All @@ -57,11 +58,11 @@ impl VLCProcessHandle {
"--no-play-and-exit",
"--http-host",
"localhost",
"--http-port",
"9090",
"--http-password",
"password",
"--http-port",
])
.arg(format!("{}", args.vlc_port))
.arg(path)
.stdout(Stdio::null())
.stderr(Stdio::null());
Expand All @@ -76,14 +77,18 @@ impl VLCProcessHandle {

VLCProcessHandle {
handle: Some(child),
status_url: format!(
"http://:password@localhost:{}/requests/status.json",
args.vlc_port
),
}
}

pub fn status(&self) -> Result<Status, Error> {
let url = "http://:password@localhost:9090/requests/status.json";
let response = reqwest::blocking::get(url)?;
//let url = "http://:password@localhost:9090/requests/status.json";
let response = reqwest::blocking::get(&self.status_url)?;
let text = response.text()?;
//debug!("Response: {}", text);
debug!("Response: {}", text);
Ok(serde_json::from_str(&text)?)
}

Expand Down

0 comments on commit d2c47aa

Please sign in to comment.