feat: add basic types and scanning
This commit is contained in:
63
src/main.rs
63
src/main.rs
@@ -1,3 +1,64 @@
|
||||
fn main() {
|
||||
use std::{fs::metadata, path::Path};
|
||||
|
||||
use lofty::ogg::tag;
|
||||
use rusqlite::{Connection, Result};
|
||||
|
||||
mod library_scan;
|
||||
mod types;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
println!("Hello, world!");
|
||||
|
||||
let conn = Connection::open_in_memory()?;
|
||||
|
||||
println!("Initializing database...");
|
||||
|
||||
conn.execute(
|
||||
"CREATE TABLE artist (
|
||||
id INTEGER PRIMARY KEY,
|
||||
name TEXT NOT NULL
|
||||
)",
|
||||
(),
|
||||
)?;
|
||||
|
||||
conn.execute(
|
||||
"CREATE TABLE collection (
|
||||
id INTEGER PRIMARY KEY,
|
||||
name TEXT NOT NULL
|
||||
)",
|
||||
(),
|
||||
)?;
|
||||
|
||||
conn.execute(
|
||||
"CREATE TABLE track (
|
||||
id INTEGER PRIMARY KEY,
|
||||
artist INTEGER,
|
||||
collection INTEGER,
|
||||
title TEXT
|
||||
)",
|
||||
(),
|
||||
)?;
|
||||
|
||||
println!("Database initialized.");
|
||||
|
||||
for track in library_scan::scan(Path::new("./test/fixtures")).expect("oh no") {
|
||||
println!("-- {}", track.path.into_string().unwrap());
|
||||
|
||||
match track.metadata {
|
||||
Ok(metadata) => {
|
||||
println!("artist: {}", metadata.artist.unwrap_or("unknown".into()));
|
||||
println!(
|
||||
"collection: {}",
|
||||
metadata.collection.unwrap_or("unknown".into())
|
||||
);
|
||||
println!("title: {}", metadata.title.unwrap_or("unknown".into()));
|
||||
}
|
||||
Err(e) => {
|
||||
eprint!("{e}");
|
||||
}
|
||||
}
|
||||
println!("");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user