diff --git a/migrations/0001_init.sql b/migrations/0001_init.sql index c0b94b7..26e02dc 100644 --- a/migrations/0001_init.sql +++ b/migrations/0001_init.sql @@ -25,12 +25,11 @@ CREATE TABLE IF NOT EXISTS "youtube_meta_categories" ( ); CREATE TABLE IF NOT EXISTS "videos" ( - "sha256" TEXT NOT NULL, + "id" UUID NOT NULL PRIMARY KEY DEFAULT gen_random_uuid(), "directory" TEXT NOT NULL, "path" TEXT NOT NULL, "duration" INTEGER, "title" TEXT, "youtube_id" TEXT, - PRIMARY KEY("sha256"), FOREIGN KEY("youtube_id") REFERENCES "youtube_meta"("id") ); diff --git a/src/library/func.rs b/src/library/func.rs index 2b3a8cd..7ac06b9 100644 --- a/src/library/func.rs +++ b/src/library/func.rs @@ -1,6 +1,3 @@ -use ring::digest::{Context, SHA256}; -use std::io::Read; - pub fn is_video_file(filename: &str) -> bool { let video_extensions = vec!["mp4", "mkv", "webm"]; @@ -11,21 +8,3 @@ pub fn is_video_file(filename: &str) -> bool { } false } - -pub fn calculate_sha256_hash(file_path: &str) -> std::io::Result { - log::info!("Hashing {file_path}"); - let mut context = Context::new(&SHA256); - let mut file = std::fs::File::open(file_path)?; - - let mut buffer = [0u8; 4096]; - loop { - let n = file.read(&mut buffer)?; - if n == 0 { - break; - } - context.update(&buffer[..n]); - } - - let digest = context.finish(); - Ok(hex::encode(digest.as_ref())) -} diff --git a/src/library/mod.rs b/src/library/mod.rs index 16246bc..1024fb1 100644 --- a/src/library/mod.rs +++ b/src/library/mod.rs @@ -42,21 +42,11 @@ impl Library { } pub async fn get_directory_videos(&self, dir: &str) -> Vec