feat: implement local-files feature with various enhancements and cleanup
This commit is contained in:
@@ -86,10 +86,8 @@ impl IMediaProvider for LocalFilesProvider {
|
||||
} else {
|
||||
ContentType::Movie
|
||||
};
|
||||
if let Some(ref ct) = filter.content_type {
|
||||
if &content_type != ct {
|
||||
return None;
|
||||
}
|
||||
if let Some(ref ct) = filter.content_type && &content_type != ct {
|
||||
return None;
|
||||
}
|
||||
|
||||
// collections: match against top_dir
|
||||
@@ -117,22 +115,16 @@ impl IMediaProvider for LocalFilesProvider {
|
||||
}
|
||||
|
||||
// duration bounds
|
||||
if let Some(min) = filter.min_duration_secs {
|
||||
if item.duration_secs < min {
|
||||
return None;
|
||||
}
|
||||
if let Some(min) = filter.min_duration_secs && item.duration_secs < min {
|
||||
return None;
|
||||
}
|
||||
if let Some(max) = filter.max_duration_secs {
|
||||
if item.duration_secs > max {
|
||||
return None;
|
||||
}
|
||||
if let Some(max) = filter.max_duration_secs && item.duration_secs > max {
|
||||
return None;
|
||||
}
|
||||
|
||||
// search_term: case-insensitive substring in title
|
||||
if let Some(ref q) = filter.search_term {
|
||||
if !item.title.to_lowercase().contains(&q.to_lowercase()) {
|
||||
return None;
|
||||
}
|
||||
if let Some(ref q) = filter.search_term && !item.title.to_lowercase().contains(&q.to_lowercase()) {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(to_media_item(id, &item))
|
||||
|
||||
@@ -171,15 +171,13 @@ impl TranscodeManager {
|
||||
continue;
|
||||
}
|
||||
let playlist = path.join("playlist.m3u8");
|
||||
if let Ok(meta) = tokio::fs::metadata(&playlist).await {
|
||||
if let Ok(modified) = meta.modified() {
|
||||
if let Ok(age) = now.duration_since(modified) {
|
||||
if age > ttl {
|
||||
warn!("cleanup: removing stale transcode {:?}", path);
|
||||
let _ = tokio::fs::remove_dir_all(&path).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Ok(meta) = tokio::fs::metadata(&playlist).await
|
||||
&& let Ok(modified) = meta.modified()
|
||||
&& let Ok(age) = now.duration_since(modified)
|
||||
&& age > ttl
|
||||
{
|
||||
warn!("cleanup: removing stale transcode {:?}", path);
|
||||
let _ = tokio::fs::remove_dir_all(&path).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user