librmo 0.1.2

A library to manage media files and play them
Documentation

libMO - Rust Media ORM

Provides an ORM to structure referencing media files and metadata. Leveraging this information we can validate the metadata for presence.

From a single entry point of defining at least 1 root folder to start from, generate a full media library and run useful functions off them.

Usage

[dependencies]
# Add to dependencies
librmo = "0.1.0"

Initialise the library, this generates the config %XDG_CONFIG_HOME/liborm and cache %XDG_CACHE_HOME/liborm folders, creates the sqlite DB and applies migrations

use librmo::migration;

migration::run().await;

Now the backend is ready, we can then provide a library directory to start collection from:

use librmo::media_manager as MM;

let lib_name = "MyMusic";
let lib_path = "/path/to/music";
MM::insert_library(lib_name, lib_path).await?;

We can confirm this library exists:

use librmo::media_manager as MM;
use librmo::entity::library::Model as LibraryModel

let libraries: Vec<LibraryModel> = MM::get_library().await?;
println!("{:?}", libraries);
// [Model { id: 1, name: "MyMusic", path: "/path/to/music", files: "" }]

Now we have a root directory to start from we set off the manager. This process is a simple walkdir for each file and we store them away in the database with their full path, modified time, and matching against an interal list of extension enums.
This should be a fast process, ~12s for ~16k files

use librmo::media_manager as MM;

MM::collect_media().await?;

Then taking each media file in the directory structure we need to work out which music fles we could care about
~20s for ~12k files

use librmo::media_checker as MC;

MC::check_media().await?;

Now onto populating the remainder of the ORM. This is a much more demanding function, currently generates all the valid track and album records and the album art thumbnail. This is where we read all the tag metadata present on the music records
~30mins for ~12k valid tracks
(~5mins without album art generation)

use librmo::media_checker as MC;

MC::check_albums().await?;

Future features/improvements

Bugs and Performance

  • check_media should first get all music records and compare there rather than 1 by 1
  • Seperate album art thumbnail generation out into async function, also allow it to be called on demand
  • Reset DB, currently slow if you delete the library record
  • Allow clearing down or report table
  • Delete media records that are no longer present in the library
  • Delete albums if no tracks remain after clearing deleted media

Features

  • Allow override of where DB and cache storage is set
  • Allow choice of artwork thumbnail file format, currently locked at jpg
  • Adjust resolution of output file, locked at 300x300
  • Check size of artwork and add report entry if too small
  • Logger settings and useful messages