diff --git a/.gitignore b/.gitignore index c099ee3..afdf578 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,4 @@ frontend/themes/clippable/static/js/index.js frontend/public/ frontend/themes/clippable/static/js/category.js frontend/themes/clippable/static/js/collection.js -api/static/js/index.js +api/static/js/ diff --git a/api/src/video.rs b/api/src/video.rs index cebd620..8e37e9c 100644 --- a/api/src/video.rs +++ b/api/src/video.rs @@ -26,7 +26,7 @@ fn vid_file_entries(path: &str) -> std::io::Result> { return Ok(entries); } -pub fn get_thumbnail(clips_dir: &str, vid_file: &str) -> std::io::Result> { +pub fn get_video_preview(clips_dir: &str, vid_file: &str) -> std::io::Result { use std::io::Read; // Contruct the full path to the video file itself // NOTE: thumbnail file names are basically file.mkv.jpg @@ -41,20 +41,25 @@ pub fn get_thumbnail(clips_dir: &str, vid_file: &str) -> std::io::Result Ok(None), - _ => Ok(Some(nail)) + let thumbnail = base64::encode(buf).to_string(); + let thumbnail = match thumbnail.len() { + 0 => None, + _ => Some(thumbnail) }; + let name = match path.file_name() { + Some(val) => val.to_string_lossy().to_string(), + None => String::new() + }; + Ok(VideoPreview { name, thumbnail }) } #[get("/category/")] @@ -77,11 +82,10 @@ pub fn list(cat: String) -> Json> { for vf in vid_files { // jfc this is rarted let name = vf.file_name().to_string_lossy().to_string(); - let thumbnail = match get_thumbnail(&thumbs_dir, &name) { - Ok(val) => val, - _ => None + match get_video_preview(&thumbs_dir, &name) { + Ok(val) => json.push(val), + _ => continue }; - json.push(VideoPreview { name, thumbnail }) } return Json(json)