feat: add database connections, initial migration and early CLI tooling
All checks were successful
Update changelog / changelog (push) Successful in 25s

This commit is contained in:
2025-12-09 01:46:05 +01:00
parent ad3cd6710d
commit f648a73cb2
26 changed files with 2399 additions and 52 deletions

59
Entities/Song.cs Normal file
View File

@@ -0,0 +1,59 @@
using System.Numerics;
namespace Shadow.Entities;
public class Song
{
public int Id { get; set; }
required public string Title { get; set; }
required public string Uri { get; set; }
required public string Filepath { get; set; }
public int State { get; set; }
required public string Filetype { get; set; }
public DateTime Date { get; set; }
public int Duration { get; set; }
public int Bitrate { get; set; }
public int Size { get; set; }
public string? Comment { get; set; } = null;
public int Channels { get; set; } = 2;
public int SamplingRate { get; set; }
public int? BitDepth { get; set; } = null;
public int Index { get; set; }
public int? TrackNumber { get; set; } = null;
public int? DiscNumber { get; set; } = null;
required public int AlbumId { get; set; }
required public int ArtistId { get; set; }
public int? ImageId { get; set; } = null;
// Songs without an album entry shall default to "[Unnamed album]".
required public Album Album { get; set; }
// Same for artists, with "[Unknown artist]".
required public Artist Artist { get; set; }
public List<GenreSong> GenreSongPair { get; set; } = [];
public Image? Image { get; set; } = null;
public bool IsOk() => State == 0;
public bool IsOrphaned() => State == 1;
public bool IsArchived() => State == 2;
public string GetMimeType()
{
// Might be nice to rewrite like this later:
// https://stackoverflow.com/a/47601452
string mimeType = String.Empty;
switch (Filetype)
{
case "flac":
mimeType = "audio/flac"; break;
case "m4a":
mimeType = "audio/mp4"; break;
case "mp3":
mimeType = "audio/mpeg"; break;
case "ogg":
mimeType = "audio/ogg"; break;
case "wav":
mimeType = "audio/x-wav"; break;
default:
mimeType = "audio/unknown"; break;
}
return mimeType;
}
}