This commit is contained in:
JMARyA 2024-09-15 04:09:46 +02:00
parent e431d3b745
commit 311b315990
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
7 changed files with 490 additions and 370 deletions

832
Cargo.lock generated

File diff suppressed because it is too large Load diff

17
Dockerfile Normal file
View file

@ -0,0 +1,17 @@
FROM rust:buster as builder
COPY . /app
WORKDIR /app
RUN cargo build --release
FROM ubuntu
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y ca-certificates openssl mkvtoolnix sqlite3
COPY --from=builder /app/target/release/watchdogs /watchdogs
WORKDIR /
CMD ["/watchdogs"]

View file

@ -2,11 +2,10 @@ use ring::digest::{Context, SHA256};
use std::io::Read; use std::io::Read;
pub fn is_video_file(filename: &str) -> bool { pub fn is_video_file(filename: &str) -> bool {
let video_extensions = vec![r"\.mp4$", r"\.mkv$", r"\.webm$", r"\.avi$"]; let video_extensions = vec!["mp4", "mkv", "webm"];
for ext in video_extensions { for ext in video_extensions {
let regex = regex::Regex::new(ext).unwrap(); if filename.ends_with(ext) {
if regex.is_match(filename) {
return true; return true;
} }
} }

View file

@ -246,7 +246,7 @@ impl Video {
} }
tx.execute( tx.execute(
"INSERT INTO videos (sha256, directory, path, title) VALUES (?1, ?2, ?3, ?4)", "INSERT OR REPLACE INTO videos (sha256, directory, path, title) VALUES (?1, ?2, ?3, ?4)",
[&id, &dir, v.to_str().unwrap(), &file_name], [&id, &dir, v.to_str().unwrap(), &file_name],
) )
.unwrap(); .unwrap();

View file

@ -4,6 +4,8 @@ mod library;
mod pages; mod pages;
mod yt_meta; mod yt_meta;
// TODO : Add User Auth DB
#[actix_web::main] #[actix_web::main]
async fn main() -> std::io::Result<()> { async fn main() -> std::io::Result<()> {
std::env::set_var("RUST_LOG", "info"); std::env::set_var("RUST_LOG", "info");

BIN
videos.db

Binary file not shown.