diff --git a/.gitignore b/.gitignore index 6d6452e..78bbb51 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ api/vids/ frontend/themes/clippable/static/js/index.js frontend/public/ frontend/themes/clippable/static/js/category.js +frontend/themes/clippable/static/js/collection.js diff --git a/api/src/main.rs b/api/src/main.rs index 67a190f..ddcc9d6 100644 --- a/api/src/main.rs +++ b/api/src/main.rs @@ -12,6 +12,6 @@ fn main() { * CLIP_DIR */ let _ = rocket::ignite() - .mount("/api", routes![video::list_categories]) + .mount("/api", routes![video::list_categories, video::list_videos]) .launch(); } diff --git a/api/src/video.rs b/api/src/video.rs index 5b5df7d..71f0a17 100644 --- a/api/src/video.rs +++ b/api/src/video.rs @@ -13,6 +13,13 @@ struct Category { thumbnail: Option } +#[derive(Serialize)] +struct Video { + name: String, + category: String, + thumbnail: Option +} + fn get_nail(dirpath: &Path) -> std::io::Result> { let mut t_path = dirpath.to_path_buf(); t_path.push(".thumbnail.jpg"); @@ -29,7 +36,7 @@ fn get_nail(dirpath: &Path) -> std::io::Result> { pub fn list_categories() -> JsonValue { let dir = match env::var("CLIPS_DIR") { Ok(val) => val, - Err(e) => "/media/clips/".to_string() + Err(_) => "/media/clips/".to_string() }; // Fucking hell this is going to be dumb @@ -48,3 +55,24 @@ pub fn list_categories() -> JsonValue { json!({"categories": cats}) } + +#[get("/category/")] +pub fn list_videos(cat: String) -> JsonValue { + let dir = match env::var("CLIPS_DIR") { + Ok(val) => val, + Err(_) => "/media/clips".to_string() + }; + + let mut vids: Vec