60 lines
1.8 KiB
C#
60 lines
1.8 KiB
C#
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;
|
|
}
|
|
}
|