Skip to content

jeremyandrews/ria

Repository files navigation

Ria

An audio management system.

Roadmap

  • improve artist, album, and track detection/identification o match directories to musicbrainz releases o get and present information about aritsts and releases
  • improve CLI management and playing of local audio files
  • explore playing audio files remotely (airplay?) o test https://github.com/arilence/airplay-rs o unfortunately: arilence/airplay-rs#1
  • integrate comprehensive search o test https://docs.rs/tantivy/latest/tantivy/
  • automate creation of database
  • implement recommendation system, "if you like this, you may also like ..."
  • expose all features through an API for a web-based UI

Getting Started

Ria can be configured (in order of precedence) by setting CLI flags, by setting environment variables, and via the ria.toml configuration file. The default configuration assumes all audio files live in a ./music directory. It defaults to using SQLite in a file named ./ria.db. For large audio collections it's strongly recommended to use PostgreSQL or MySQL instead.

  1. Create the SQLite database file with the following commaned:
touch ria.db
  1. Scan all audio files, and print the results:
cargo run --release -- --scan --print
  1. Filter selected audio files with --artist, --directory and --track options
  2. Play filtered audio files by adding the --play flag

Database

For ease of development, Ria defaults to using SQLite. All database connections are managed through SeaORM making it possible to also use PostgreSQL and MySQL by simply configuring database_type in ria.toml, RIA_DATABASE_TYPE, or the --database-type command line configuration option. If using SQLite you just need to specify a database_name. If using PostgreSQL or MySQL you also need to specify a database_user and a database_password.

Creation

It is on the roadmap for Ria to auto-create the database when necessary, but this has not yet been implemented.

SeaORM CLI is required to manually run the database migrations:

cargo install sea-orm-cli

SQLite

There are two steps to create the Ria SQLite database:

  1. Create an empty database file, for example: touch ria.db
  2. Run the database migration:
DATABASE_URL="sqlite://ria.db" sea-orm-cli migrate fresh

PostgreSQL or MySQL

To create the Ria PostgreSQL database, first create a database and a database user with read/write access. Then, run the database migration. For example, if the database_name is ria, the database_user is ria and the database_password password, for PostgreSQL run the command as follows:

DATABASE_URL="postgres://ria:password@database/ria" sea-orm-cli migrate fresh

For MySQL run the following command:

DATABASE_URL="mysql://ria:password@database/ria" sea-orm-cli migrate fresh

Implementation Notes

Ria depends on a number of packages, including:

  • symphonia is used to identify, validate, and decode audio files;
  • rodio is used to locally play music files;
  • sea-orm is used to communicat with the database, supporting SQLite, PostgreSQL and MySQL.

Docker

A local development environment can be created using Docker and Docker Compose by checking out the ria codebase with git, and then from within ria/ run the following command:

docker-compose up --build

It will take some time to download and install all dependencies. Once complete, you can connect into the ria_ria container as follows:

docker exec -it `docker ps | grep ria-ria | awk '{print $1}'` /bin/bash

The ria/ codebase can be found in /app. For example:

% docker exec -it `docker ps | grep ria-ria | awk '{print $1}'` /bin/bash
root@8a6b1779e907:/app# cargo run --release

To copy files from the docker container back to the host, try something like:

docker cp `docker ps | grep ria_ria | awk '{print $1}'`:/app/src/entities/artist.rs .

The docker image uses the PostgreSQL database. To connect to the database through the CLI, from bash within the ria docker image:

psql --host database --username ria

Schema

The underlying database schema is controlled by SeaORM, and was built through the numbered files in migration/src. The following command drops the database (deleting everything) and reloads it with the latest schema:

sea-orm-cli migrate fresh

Individual entity files are auto-generated in src/entities/ by running the following SeaORM command:

sea-orm-cli generate entity -u postgres://ria:password@database/ria -o src/entities

Identifying music

Some APIs to explore:

About

An audio management system.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published