Skip to content

Commit

Permalink
Encode file names in playlist
Browse files Browse the repository at this point in the history
  • Loading branch information
izderadicka committed Aug 5, 2024
1 parent 510c2ee commit e7829bf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions crates/librqbit/src/http_api.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::Context;
use axum::body::Bytes;
use axum::extract::{Path, Query, Request, State};
use axum::extract::{Path, Query, State};
use axum::response::{IntoResponse, Redirect};
use axum::routing::{get, post};
use futures::future::BoxFuture;
Expand Down Expand Up @@ -148,15 +148,15 @@ impl HttpApi {
.into_iter()
.enumerate()
.filter_map(|(file_idx, f)| {
let file_name = f.name;
let is_playable = mime_guess::from_path(&file_name)
let is_playable = mime_guess::from_path(&f.name)
.first()
.map(|mime| {
mime.type_() == mime_guess::mime::VIDEO
|| mime.type_() == mime_guess::mime::AUDIO
})
.unwrap_or(false);
if is_playable {
let file_name = urlencoding::encode(&f.name);
Some(format!(
"http://{host}/torrents/{idx}/stream/{file_idx}/{file_name}"
))
Expand Down

0 comments on commit e7829bf

Please sign in to comment.