Add album artist field
This commit is contained in:
parent
f471bd77a6
commit
0490795f02
|
@ -17,7 +17,7 @@ pub struct Config {
|
||||||
impl Config {
|
impl Config {
|
||||||
pub fn read_config() -> Result<Self> {
|
pub fn read_config() -> Result<Self> {
|
||||||
let file = std::env::current_dir()
|
let file = std::env::current_dir()
|
||||||
.and_then(|v| Ok(v.join("settings.toml")))
|
.map(|v| v.join("settings.toml"))
|
||||||
.into_diagnostic()?;
|
.into_diagnostic()?;
|
||||||
let contents = std::fs::read_to_string(file).into_diagnostic()?;
|
let contents = std::fs::read_to_string(file).into_diagnostic()?;
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ impl Config {
|
||||||
let contents = toml::to_string(config).into_diagnostic()?;
|
let contents = toml::to_string(config).into_diagnostic()?;
|
||||||
|
|
||||||
let path = std::env::current_dir()
|
let path = std::env::current_dir()
|
||||||
.and_then(|v| Ok(v.join("settings.toml")))
|
.map(|v| v.join("settings.toml"))
|
||||||
.into_diagnostic()?;
|
.into_diagnostic()?;
|
||||||
|
|
||||||
File::create(path)
|
File::create(path)
|
||||||
|
|
|
@ -61,7 +61,7 @@ pub async fn index_source(source: Source, mode: IndexMode, db: &DatabaseConnecti
|
||||||
.filter(|e| {
|
.filter(|e| {
|
||||||
mime_guess::from_path(e.path())
|
mime_guess::from_path(e.path())
|
||||||
.first()
|
.first()
|
||||||
.and_then(|v| Some(v.type_() == mime::AUDIO))
|
.map(|v| v.type_() == mime::AUDIO)
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
|
@ -92,20 +92,15 @@ pub async fn index_source(source: Source, mode: IndexMode, db: &DatabaseConnecti
|
||||||
.to_string()),
|
.to_string()),
|
||||||
source_id: Set(source.id.into()),
|
source_id: Set(source.id.into()),
|
||||||
hash: Set(hash.try_into().into_diagnostic()?),
|
hash: Set(hash.try_into().into_diagnostic()?),
|
||||||
artist: Set(tags
|
artist: Set(tags.and_then(|t| t.artist()).map(|t| t.to_string())),
|
||||||
.and_then(|t| t.artist())
|
album_artist: Set(tags
|
||||||
.and_then(|t| Some(t.to_string()))),
|
.and_then(|t| t.get_string(&lofty::ItemKey::AlbumArtist))
|
||||||
name: Set(tags
|
.map(|t| t.to_string())),
|
||||||
.and_then(|t| t.title())
|
name: Set(tags.and_then(|t| t.title()).map(|t| t.to_string())),
|
||||||
.and_then(|t| Some(t.to_string()))),
|
album: Set(tags.and_then(|t| t.album()).map(|t| t.to_string())),
|
||||||
album: Set(tags
|
genres: Set(tags.and_then(|t| t.genre()).map(|t| t.to_string())),
|
||||||
.and_then(|t| t.album())
|
track: Set(tags.and_then(|t| t.track()).map(|t| t as i32)),
|
||||||
.and_then(|t| Some(t.to_string()))),
|
year: Set(tags.and_then(|t| t.year()).map(|t| t as i32)),
|
||||||
genres: Set(tags
|
|
||||||
.and_then(|t| t.genre())
|
|
||||||
.and_then(|t| Some(t.to_string()))),
|
|
||||||
track: Set(tags.and_then(|t| t.track()).and_then(|t| Some(t as i32))),
|
|
||||||
year: Set(tags.and_then(|t| t.year()).and_then(|t| Some(t as i32))),
|
|
||||||
duration: Set(properties
|
duration: Set(properties
|
||||||
.duration()
|
.duration()
|
||||||
.as_millis()
|
.as_millis()
|
||||||
|
|
|
@ -28,6 +28,7 @@ impl MigrationTrait for Migration {
|
||||||
.col(ColumnDef::new(Song::SourceId).integer().not_null())
|
.col(ColumnDef::new(Song::SourceId).integer().not_null())
|
||||||
.col(ColumnDef::new(Song::Hash).integer().not_null().unique_key())
|
.col(ColumnDef::new(Song::Hash).integer().not_null().unique_key())
|
||||||
.col(ColumnDef::new(Song::Artist).string())
|
.col(ColumnDef::new(Song::Artist).string())
|
||||||
|
.col(ColumnDef::new(Song::AlbumArtist).string())
|
||||||
.col(ColumnDef::new(Song::Name).string())
|
.col(ColumnDef::new(Song::Name).string())
|
||||||
.col(ColumnDef::new(Song::Album).string())
|
.col(ColumnDef::new(Song::Album).string())
|
||||||
.col(ColumnDef::new(Song::Duration).integer().not_null())
|
.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>
|
/// A hash of the song's samples as Vec<f32>
|
||||||
Hash,
|
Hash,
|
||||||
Artist,
|
Artist,
|
||||||
|
AlbumArtist,
|
||||||
Name,
|
Name,
|
||||||
Album,
|
Album,
|
||||||
Duration,
|
Duration,
|
||||||
|
|
|
@ -13,6 +13,7 @@ pub struct Model {
|
||||||
pub source_id: i32,
|
pub source_id: i32,
|
||||||
pub hash: u32,
|
pub hash: u32,
|
||||||
pub artist: Option<String>,
|
pub artist: Option<String>,
|
||||||
|
pub album_artist: Option<String>,
|
||||||
pub name: Option<String>,
|
pub name: Option<String>,
|
||||||
pub album: Option<String>,
|
pub album: Option<String>,
|
||||||
pub duration: u32,
|
pub duration: u32,
|
||||||
|
|
|
@ -10,7 +10,7 @@ use sea_orm::{ColumnTrait, EntityTrait, QueryFilter};
|
||||||
/// If no files have been created in the current directory, the app is running for the first time
|
/// If no files have been created in the current directory, the app is running for the first time
|
||||||
pub fn is_first_run() -> Result<bool> {
|
pub fn is_first_run() -> Result<bool> {
|
||||||
let path = std::env::current_dir()
|
let path = std::env::current_dir()
|
||||||
.and_then(|v| Ok(v.join("settings.toml")))
|
.map(|v| v.join("settings.toml"))
|
||||||
.into_diagnostic()?;
|
.into_diagnostic()?;
|
||||||
|
|
||||||
Ok(!path.exists())
|
Ok(!path.exists())
|
||||||
|
|
Loading…
Reference in New Issue