Add album artist field

This commit is contained in:
Agatha Lovelace 2022-09-23 20:39:19 +02:00
parent 429755f1e1
commit 644403c2f3
Signed by: sorceress
GPG Key ID: 11BBCFC65FC9F401
5 changed files with 12 additions and 3 deletions

View File

@ -98,6 +98,9 @@ pub async fn index_source(source: Source, mode: IndexMode, db: &DatabaseConnecti
source_id: Set(source.id.into()),
hash: Set(hash.try_into().into_diagnostic()?),
artist: Set(tags.and_then(|t| t.artist()).map(|t| t.to_string())),
album_artist: Set(tags
.and_then(|t| t.get_string(&lofty::ItemKey::AlbumArtist))
.map(|t| t.to_string())),
name: Set(tags.and_then(|t| t.title()).map(|t| t.to_string())),
album: Set(tags.and_then(|t| t.album()).map(|t| t.to_string())),
genres: Set(tags.and_then(|t| t.genre()).map(|t| t.to_string())),

View File

@ -28,6 +28,7 @@ impl MigrationTrait for Migration {
.col(ColumnDef::new(Song::SourceId).integer().not_null())
.col(ColumnDef::new(Song::Hash).integer().not_null().unique_key())
.col(ColumnDef::new(Song::Artist).string())
.col(ColumnDef::new(Song::AlbumArtist).string())
.col(ColumnDef::new(Song::Name).string())
.col(ColumnDef::new(Song::Album).string())
.col(ColumnDef::new(Song::Duration).integer().not_null())
@ -60,6 +61,7 @@ pub enum Song {
/// A hash of the song's samples as Vec<f32>
Hash,
Artist,
AlbumArtist,
Name,
Album,
Duration,

View File

@ -1,8 +1,9 @@
//! SeaORM Entity. Generated by sea-orm-codegen 0.9.1
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "library")]
pub struct Model {
#[sea_orm(primary_key)]
@ -12,6 +13,7 @@ pub struct Model {
pub source_id: i32,
pub hash: u32,
pub artist: Option<String>,
pub album_artist: Option<String>,
pub name: Option<String>,
pub album: Option<String>,
pub duration: u32,

View File

@ -1,8 +1,9 @@
//! SeaORM Entity. Generated by sea-orm-codegen 0.9.1
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "playlist_entries")]
pub struct Model {
#[sea_orm(primary_key)]

View File

@ -1,8 +1,9 @@
//! SeaORM Entity. Generated by sea-orm-codegen 0.9.1
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "playlists")]
pub struct Model {
#[sea_orm(primary_key)]