Encode file names in playlist
This commit is contained in:
parent
510c2ee231
commit
e7829bf213
1 changed files with 3 additions and 3 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use axum::body::Bytes;
|
use axum::body::Bytes;
|
||||||
use axum::extract::{Path, Query, Request, State};
|
use axum::extract::{Path, Query, State};
|
||||||
use axum::response::{IntoResponse, Redirect};
|
use axum::response::{IntoResponse, Redirect};
|
||||||
use axum::routing::{get, post};
|
use axum::routing::{get, post};
|
||||||
use futures::future::BoxFuture;
|
use futures::future::BoxFuture;
|
||||||
|
|
@ -148,8 +148,7 @@ impl HttpApi {
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.filter_map(|(file_idx, f)| {
|
.filter_map(|(file_idx, f)| {
|
||||||
let file_name = f.name;
|
let is_playable = mime_guess::from_path(&f.name)
|
||||||
let is_playable = mime_guess::from_path(&file_name)
|
|
||||||
.first()
|
.first()
|
||||||
.map(|mime| {
|
.map(|mime| {
|
||||||
mime.type_() == mime_guess::mime::VIDEO
|
mime.type_() == mime_guess::mime::VIDEO
|
||||||
|
|
@ -157,6 +156,7 @@ impl HttpApi {
|
||||||
})
|
})
|
||||||
.unwrap_or(false);
|
.unwrap_or(false);
|
||||||
if is_playable {
|
if is_playable {
|
||||||
|
let file_name = urlencoding::encode(&f.name);
|
||||||
Some(format!(
|
Some(format!(
|
||||||
"http://{host}/torrents/{idx}/stream/{file_idx}/{file_name}"
|
"http://{host}/torrents/{idx}/stream/{file_idx}/{file_name}"
|
||||||
))
|
))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue