From ce779b3c8a7243dae426da96a2650c3541f13d6e Mon Sep 17 00:00:00 2001 From: V1ck3s Date: Thu, 8 Jan 2026 19:57:11 +0100 Subject: [PATCH] refactor: reorganize Models into subdirectories by context Split monolithic MusicModels.cs (177 lines) into separate files: - Models/Settings/ (DeezerSettings, QobuzSettings, SubsonicSettings) - Models/Domain/ (Song, Album, Artist) - Models/Search/ (SearchResult) - Models/Download/ (DownloadInfo, DownloadStatus) - Models/Subsonic/ (ScanStatus) Updated namespaces and imports across 22 files. Improves navigation and separates models by business context. --- .../DeezerDownloadServiceTests.cs | 6 +- .../DeezerMetadataServiceTests.cs | 6 +- octo-fiesta.Tests/LocalLibraryServiceTests.cs | 6 +- octo-fiesta/Controllers/SubSonicController.cs | 6 +- octo-fiesta/Models/Domain/Album.cs | 20 +++++ octo-fiesta/Models/Domain/Artist.cs | 15 ++++ .../Models/{MusicModels.cs => Domain/Song.cs} | 81 +------------------ octo-fiesta/Models/Download/DownloadInfo.cs | 17 ++++ octo-fiesta/Models/Download/DownloadStatus.cs | 12 +++ octo-fiesta/Models/Search/SearchResult.cs | 13 +++ .../Models/{ => Settings}/DeezerSettings.cs | 2 +- .../Models/{ => Settings}/QobuzSettings.cs | 2 +- .../Models/{ => Settings}/SubsonicSettings.cs | 2 +- octo-fiesta/Models/Subsonic/ScanStatus.cs | 10 +++ octo-fiesta/Program.cs | 2 +- .../Services/Common/BaseDownloadService.cs | 6 +- .../Services/Deezer/DeezerDownloadService.cs | 6 +- .../Services/Deezer/DeezerMetadataService.cs | 6 +- .../Services/Deezer/DeezerStartupValidator.cs | 2 +- octo-fiesta/Services/IDownloadService.cs | 6 +- octo-fiesta/Services/IMusicMetadataService.cs | 6 +- .../Services/Local/ILocalLibraryService.cs | 6 +- .../Services/Local/LocalLibraryService.cs | 6 +- .../Services/Qobuz/QobuzDownloadService.cs | 6 +- .../Services/Qobuz/QobuzMetadataService.cs | 6 +- .../Services/Qobuz/QobuzStartupValidator.cs | 2 +- .../Services/StartupValidationService.cs | 2 +- .../StartupValidationOrchestrator.cs | 2 +- .../Validation/SubsonicStartupValidator.cs | 2 +- 29 files changed, 162 insertions(+), 102 deletions(-) create mode 100644 octo-fiesta/Models/Domain/Album.cs create mode 100644 octo-fiesta/Models/Domain/Artist.cs rename octo-fiesta/Models/{MusicModels.cs => Domain/Song.cs} (56%) create mode 100644 octo-fiesta/Models/Download/DownloadInfo.cs create mode 100644 octo-fiesta/Models/Download/DownloadStatus.cs create mode 100644 octo-fiesta/Models/Search/SearchResult.cs rename octo-fiesta/Models/{ => Settings}/DeezerSettings.cs (94%) rename octo-fiesta/Models/{ => Settings}/QobuzSettings.cs (94%) rename octo-fiesta/Models/{ => Settings}/SubsonicSettings.cs (98%) create mode 100644 octo-fiesta/Models/Subsonic/ScanStatus.cs diff --git a/octo-fiesta.Tests/DeezerDownloadServiceTests.cs b/octo-fiesta.Tests/DeezerDownloadServiceTests.cs index e334db1..a740392 100644 --- a/octo-fiesta.Tests/DeezerDownloadServiceTests.cs +++ b/octo-fiesta.Tests/DeezerDownloadServiceTests.cs @@ -1,7 +1,11 @@ using octo_fiesta.Services; using octo_fiesta.Services.Deezer; using octo_fiesta.Services.Local; -using octo_fiesta.Models; +using octo_fiesta.Models.Domain; +using octo_fiesta.Models.Settings; +using octo_fiesta.Models.Download; +using octo_fiesta.Models.Search; +using octo_fiesta.Models.Subsonic; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; diff --git a/octo-fiesta.Tests/DeezerMetadataServiceTests.cs b/octo-fiesta.Tests/DeezerMetadataServiceTests.cs index e03a5e4..fe72a97 100644 --- a/octo-fiesta.Tests/DeezerMetadataServiceTests.cs +++ b/octo-fiesta.Tests/DeezerMetadataServiceTests.cs @@ -1,5 +1,9 @@ using octo_fiesta.Services.Deezer; -using octo_fiesta.Models; +using octo_fiesta.Models.Domain; +using octo_fiesta.Models.Settings; +using octo_fiesta.Models.Download; +using octo_fiesta.Models.Search; +using octo_fiesta.Models.Subsonic; using Moq; using Moq.Protected; using Microsoft.Extensions.Options; diff --git a/octo-fiesta.Tests/LocalLibraryServiceTests.cs b/octo-fiesta.Tests/LocalLibraryServiceTests.cs index 934ef27..61694d5 100644 --- a/octo-fiesta.Tests/LocalLibraryServiceTests.cs +++ b/octo-fiesta.Tests/LocalLibraryServiceTests.cs @@ -1,5 +1,9 @@ using octo_fiesta.Services.Local; -using octo_fiesta.Models; +using octo_fiesta.Models.Domain; +using octo_fiesta.Models.Settings; +using octo_fiesta.Models.Download; +using octo_fiesta.Models.Search; +using octo_fiesta.Models.Subsonic; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; diff --git a/octo-fiesta/Controllers/SubSonicController.cs b/octo-fiesta/Controllers/SubSonicController.cs index dd0570f..af7156c 100644 --- a/octo-fiesta/Controllers/SubSonicController.cs +++ b/octo-fiesta/Controllers/SubSonicController.cs @@ -3,7 +3,11 @@ using System.Xml.Linq; using System.Text; using System.Text.Json; using Microsoft.Extensions.Options; -using octo_fiesta.Models; +using octo_fiesta.Models.Domain; +using octo_fiesta.Models.Settings; +using octo_fiesta.Models.Download; +using octo_fiesta.Models.Search; +using octo_fiesta.Models.Subsonic; using octo_fiesta.Services; using octo_fiesta.Services.Local; diff --git a/octo-fiesta/Models/Domain/Album.cs b/octo-fiesta/Models/Domain/Album.cs new file mode 100644 index 0000000..bd272bb --- /dev/null +++ b/octo-fiesta/Models/Domain/Album.cs @@ -0,0 +1,20 @@ +namespace octo_fiesta.Models.Domain; + +/// +/// Represents an album +/// +public class Album +{ + public string Id { get; set; } = string.Empty; + public string Title { get; set; } = string.Empty; + public string Artist { get; set; } = string.Empty; + public string? ArtistId { get; set; } + public int? Year { get; set; } + public int? SongCount { get; set; } + public string? CoverArtUrl { get; set; } + public string? Genre { get; set; } + public bool IsLocal { get; set; } + public string? ExternalProvider { get; set; } + public string? ExternalId { get; set; } + public List Songs { get; set; } = new(); +} diff --git a/octo-fiesta/Models/Domain/Artist.cs b/octo-fiesta/Models/Domain/Artist.cs new file mode 100644 index 0000000..276a88b --- /dev/null +++ b/octo-fiesta/Models/Domain/Artist.cs @@ -0,0 +1,15 @@ +namespace octo_fiesta.Models.Domain; + +/// +/// Represents an artist +/// +public class Artist +{ + public string Id { get; set; } = string.Empty; + public string Name { get; set; } = string.Empty; + public string? ImageUrl { get; set; } + public int? AlbumCount { get; set; } + public bool IsLocal { get; set; } + public string? ExternalProvider { get; set; } + public string? ExternalId { get; set; } +} diff --git a/octo-fiesta/Models/MusicModels.cs b/octo-fiesta/Models/Domain/Song.cs similarity index 56% rename from octo-fiesta/Models/MusicModels.cs rename to octo-fiesta/Models/Domain/Song.cs index 35d1f18..01c9796 100644 --- a/octo-fiesta/Models/MusicModels.cs +++ b/octo-fiesta/Models/Domain/Song.cs @@ -1,4 +1,4 @@ -namespace octo_fiesta.Models; +namespace octo_fiesta.Models.Domain; /// /// Represents a song (local or external) @@ -95,82 +95,3 @@ public class Song /// public int? ExplicitContentLyrics { get; set; } } - -/// -/// Represents an artist -/// -public class Artist -{ - public string Id { get; set; } = string.Empty; - public string Name { get; set; } = string.Empty; - public string? ImageUrl { get; set; } - public int? AlbumCount { get; set; } - public bool IsLocal { get; set; } - public string? ExternalProvider { get; set; } - public string? ExternalId { get; set; } -} - -/// -/// Represents an album -/// -public class Album -{ - public string Id { get; set; } = string.Empty; - public string Title { get; set; } = string.Empty; - public string Artist { get; set; } = string.Empty; - public string? ArtistId { get; set; } - public int? Year { get; set; } - public int? SongCount { get; set; } - public string? CoverArtUrl { get; set; } - public string? Genre { get; set; } - public bool IsLocal { get; set; } - public string? ExternalProvider { get; set; } - public string? ExternalId { get; set; } - public List Songs { get; set; } = new(); -} - -/// -/// Search result combining local and external results -/// -public class SearchResult -{ - public List Songs { get; set; } = new(); - public List Albums { get; set; } = new(); - public List Artists { get; set; } = new(); -} - -/// -/// Download status of a song -/// -public enum DownloadStatus -{ - NotStarted, - InProgress, - Completed, - Failed -} - -/// -/// Information about an ongoing or completed download -/// -public class DownloadInfo -{ - public string SongId { get; set; } = string.Empty; - public string ExternalId { get; set; } = string.Empty; - public string ExternalProvider { get; set; } = string.Empty; - public DownloadStatus Status { get; set; } - public double Progress { get; set; } // 0.0 to 1.0 - public string? LocalPath { get; set; } - public string? ErrorMessage { get; set; } - public DateTime StartedAt { get; set; } - public DateTime? CompletedAt { get; set; } -} - -/// -/// Subsonic library scan status -/// -public class ScanStatus -{ - public bool Scanning { get; set; } - public int? Count { get; set; } -} diff --git a/octo-fiesta/Models/Download/DownloadInfo.cs b/octo-fiesta/Models/Download/DownloadInfo.cs new file mode 100644 index 0000000..608295d --- /dev/null +++ b/octo-fiesta/Models/Download/DownloadInfo.cs @@ -0,0 +1,17 @@ +namespace octo_fiesta.Models.Download; + +/// +/// Information about an ongoing or completed download +/// +public class DownloadInfo +{ + public string SongId { get; set; } = string.Empty; + public string ExternalId { get; set; } = string.Empty; + public string ExternalProvider { get; set; } = string.Empty; + public DownloadStatus Status { get; set; } + public double Progress { get; set; } // 0.0 to 1.0 + public string? LocalPath { get; set; } + public string? ErrorMessage { get; set; } + public DateTime StartedAt { get; set; } + public DateTime? CompletedAt { get; set; } +} diff --git a/octo-fiesta/Models/Download/DownloadStatus.cs b/octo-fiesta/Models/Download/DownloadStatus.cs new file mode 100644 index 0000000..5d5d4f9 --- /dev/null +++ b/octo-fiesta/Models/Download/DownloadStatus.cs @@ -0,0 +1,12 @@ +namespace octo_fiesta.Models.Download; + +/// +/// Download status of a song +/// +public enum DownloadStatus +{ + NotStarted, + InProgress, + Completed, + Failed +} diff --git a/octo-fiesta/Models/Search/SearchResult.cs b/octo-fiesta/Models/Search/SearchResult.cs new file mode 100644 index 0000000..25280a4 --- /dev/null +++ b/octo-fiesta/Models/Search/SearchResult.cs @@ -0,0 +1,13 @@ +namespace octo_fiesta.Models.Search; + +using octo_fiesta.Models.Domain; + +/// +/// Search result combining local and external results +/// +public class SearchResult +{ + public List Songs { get; set; } = new(); + public List Albums { get; set; } = new(); + public List Artists { get; set; } = new(); +} diff --git a/octo-fiesta/Models/DeezerSettings.cs b/octo-fiesta/Models/Settings/DeezerSettings.cs similarity index 94% rename from octo-fiesta/Models/DeezerSettings.cs rename to octo-fiesta/Models/Settings/DeezerSettings.cs index b333a5f..ecc50b9 100644 --- a/octo-fiesta/Models/DeezerSettings.cs +++ b/octo-fiesta/Models/Settings/DeezerSettings.cs @@ -1,4 +1,4 @@ -namespace octo_fiesta.Models; +namespace octo_fiesta.Models.Settings; /// /// Configuration for the Deezer downloader and metadata service diff --git a/octo-fiesta/Models/QobuzSettings.cs b/octo-fiesta/Models/Settings/QobuzSettings.cs similarity index 94% rename from octo-fiesta/Models/QobuzSettings.cs rename to octo-fiesta/Models/Settings/QobuzSettings.cs index 977ac5e..b1c9956 100644 --- a/octo-fiesta/Models/QobuzSettings.cs +++ b/octo-fiesta/Models/Settings/QobuzSettings.cs @@ -1,4 +1,4 @@ -namespace octo_fiesta.Models; +namespace octo_fiesta.Models.Settings; /// /// Configuration for the Qobuz downloader and metadata service diff --git a/octo-fiesta/Models/SubsonicSettings.cs b/octo-fiesta/Models/Settings/SubsonicSettings.cs similarity index 98% rename from octo-fiesta/Models/SubsonicSettings.cs rename to octo-fiesta/Models/Settings/SubsonicSettings.cs index c04dca4..6a8cb0d 100644 --- a/octo-fiesta/Models/SubsonicSettings.cs +++ b/octo-fiesta/Models/Settings/SubsonicSettings.cs @@ -1,4 +1,4 @@ -namespace octo_fiesta.Models; +namespace octo_fiesta.Models.Settings; /// /// Download mode for tracks diff --git a/octo-fiesta/Models/Subsonic/ScanStatus.cs b/octo-fiesta/Models/Subsonic/ScanStatus.cs new file mode 100644 index 0000000..03b3343 --- /dev/null +++ b/octo-fiesta/Models/Subsonic/ScanStatus.cs @@ -0,0 +1,10 @@ +namespace octo_fiesta.Models.Subsonic; + +/// +/// Subsonic library scan status +/// +public class ScanStatus +{ + public bool Scanning { get; set; } + public int? Count { get; set; } +} diff --git a/octo-fiesta/Program.cs b/octo-fiesta/Program.cs index c19611a..9a5bc51 100644 --- a/octo-fiesta/Program.cs +++ b/octo-fiesta/Program.cs @@ -1,4 +1,4 @@ -using octo_fiesta.Models; +using octo_fiesta.Models.Settings; using octo_fiesta.Services; using octo_fiesta.Services.Deezer; using octo_fiesta.Services.Qobuz; diff --git a/octo-fiesta/Services/Common/BaseDownloadService.cs b/octo-fiesta/Services/Common/BaseDownloadService.cs index 710bfe4..15b477e 100644 --- a/octo-fiesta/Services/Common/BaseDownloadService.cs +++ b/octo-fiesta/Services/Common/BaseDownloadService.cs @@ -1,4 +1,8 @@ -using octo_fiesta.Models; +using octo_fiesta.Models.Domain; +using octo_fiesta.Models.Settings; +using octo_fiesta.Models.Download; +using octo_fiesta.Models.Search; +using octo_fiesta.Models.Subsonic; using octo_fiesta.Services.Local; using octo_fiesta.Services.Deezer; using TagLib; diff --git a/octo-fiesta/Services/Deezer/DeezerDownloadService.cs b/octo-fiesta/Services/Deezer/DeezerDownloadService.cs index e0a2c9c..73a5e60 100644 --- a/octo-fiesta/Services/Deezer/DeezerDownloadService.cs +++ b/octo-fiesta/Services/Deezer/DeezerDownloadService.cs @@ -4,7 +4,11 @@ using System.Text.Json; using Org.BouncyCastle.Crypto.Engines; using Org.BouncyCastle.Crypto.Modes; using Org.BouncyCastle.Crypto.Parameters; -using octo_fiesta.Models; +using octo_fiesta.Models.Domain; +using octo_fiesta.Models.Settings; +using octo_fiesta.Models.Download; +using octo_fiesta.Models.Search; +using octo_fiesta.Models.Subsonic; using octo_fiesta.Services.Local; using octo_fiesta.Services.Common; using Microsoft.Extensions.Options; diff --git a/octo-fiesta/Services/Deezer/DeezerMetadataService.cs b/octo-fiesta/Services/Deezer/DeezerMetadataService.cs index 23cf5e0..60394cd 100644 --- a/octo-fiesta/Services/Deezer/DeezerMetadataService.cs +++ b/octo-fiesta/Services/Deezer/DeezerMetadataService.cs @@ -1,4 +1,8 @@ -using octo_fiesta.Models; +using octo_fiesta.Models.Domain; +using octo_fiesta.Models.Settings; +using octo_fiesta.Models.Download; +using octo_fiesta.Models.Search; +using octo_fiesta.Models.Subsonic; using System.Text.Json; using Microsoft.Extensions.Options; diff --git a/octo-fiesta/Services/Deezer/DeezerStartupValidator.cs b/octo-fiesta/Services/Deezer/DeezerStartupValidator.cs index 38233f6..0f3e4d1 100644 --- a/octo-fiesta/Services/Deezer/DeezerStartupValidator.cs +++ b/octo-fiesta/Services/Deezer/DeezerStartupValidator.cs @@ -1,7 +1,7 @@ using System.Text; using System.Text.Json; using Microsoft.Extensions.Options; -using octo_fiesta.Models; +using octo_fiesta.Models.Settings; using octo_fiesta.Services.Validation; namespace octo_fiesta.Services.Deezer; diff --git a/octo-fiesta/Services/IDownloadService.cs b/octo-fiesta/Services/IDownloadService.cs index 10de0f5..d53757c 100644 --- a/octo-fiesta/Services/IDownloadService.cs +++ b/octo-fiesta/Services/IDownloadService.cs @@ -1,4 +1,8 @@ -using octo_fiesta.Models; +using octo_fiesta.Models.Domain; +using octo_fiesta.Models.Settings; +using octo_fiesta.Models.Download; +using octo_fiesta.Models.Search; +using octo_fiesta.Models.Subsonic; namespace octo_fiesta.Services; diff --git a/octo-fiesta/Services/IMusicMetadataService.cs b/octo-fiesta/Services/IMusicMetadataService.cs index 8a9be13..fead3f6 100644 --- a/octo-fiesta/Services/IMusicMetadataService.cs +++ b/octo-fiesta/Services/IMusicMetadataService.cs @@ -1,4 +1,8 @@ -using octo_fiesta.Models; +using octo_fiesta.Models.Domain; +using octo_fiesta.Models.Settings; +using octo_fiesta.Models.Download; +using octo_fiesta.Models.Search; +using octo_fiesta.Models.Subsonic; namespace octo_fiesta.Services; diff --git a/octo-fiesta/Services/Local/ILocalLibraryService.cs b/octo-fiesta/Services/Local/ILocalLibraryService.cs index b973d40..ce45d81 100644 --- a/octo-fiesta/Services/Local/ILocalLibraryService.cs +++ b/octo-fiesta/Services/Local/ILocalLibraryService.cs @@ -1,4 +1,8 @@ -using octo_fiesta.Models; +using octo_fiesta.Models.Domain; +using octo_fiesta.Models.Settings; +using octo_fiesta.Models.Download; +using octo_fiesta.Models.Search; +using octo_fiesta.Models.Subsonic; namespace octo_fiesta.Services.Local; diff --git a/octo-fiesta/Services/Local/LocalLibraryService.cs b/octo-fiesta/Services/Local/LocalLibraryService.cs index 01baffa..ac6d57d 100644 --- a/octo-fiesta/Services/Local/LocalLibraryService.cs +++ b/octo-fiesta/Services/Local/LocalLibraryService.cs @@ -1,6 +1,10 @@ using System.Text.Json; using Microsoft.Extensions.Options; -using octo_fiesta.Models; +using octo_fiesta.Models.Domain; +using octo_fiesta.Models.Settings; +using octo_fiesta.Models.Download; +using octo_fiesta.Models.Search; +using octo_fiesta.Models.Subsonic; using octo_fiesta.Services; namespace octo_fiesta.Services.Local; diff --git a/octo-fiesta/Services/Qobuz/QobuzDownloadService.cs b/octo-fiesta/Services/Qobuz/QobuzDownloadService.cs index b5ac195..7e26ddc 100644 --- a/octo-fiesta/Services/Qobuz/QobuzDownloadService.cs +++ b/octo-fiesta/Services/Qobuz/QobuzDownloadService.cs @@ -1,7 +1,11 @@ using System.Security.Cryptography; using System.Text; using System.Text.Json; -using octo_fiesta.Models; +using octo_fiesta.Models.Domain; +using octo_fiesta.Models.Settings; +using octo_fiesta.Models.Download; +using octo_fiesta.Models.Search; +using octo_fiesta.Models.Subsonic; using octo_fiesta.Services.Local; using octo_fiesta.Services.Common; using octo_fiesta.Services.Deezer; diff --git a/octo-fiesta/Services/Qobuz/QobuzMetadataService.cs b/octo-fiesta/Services/Qobuz/QobuzMetadataService.cs index 2c5fb29..77b56ba 100644 --- a/octo-fiesta/Services/Qobuz/QobuzMetadataService.cs +++ b/octo-fiesta/Services/Qobuz/QobuzMetadataService.cs @@ -1,4 +1,8 @@ -using octo_fiesta.Models; +using octo_fiesta.Models.Domain; +using octo_fiesta.Models.Settings; +using octo_fiesta.Models.Download; +using octo_fiesta.Models.Search; +using octo_fiesta.Models.Subsonic; using System.Text.Json; using Microsoft.Extensions.Options; diff --git a/octo-fiesta/Services/Qobuz/QobuzStartupValidator.cs b/octo-fiesta/Services/Qobuz/QobuzStartupValidator.cs index dbaab08..6f8eb7f 100644 --- a/octo-fiesta/Services/Qobuz/QobuzStartupValidator.cs +++ b/octo-fiesta/Services/Qobuz/QobuzStartupValidator.cs @@ -1,5 +1,5 @@ using Microsoft.Extensions.Options; -using octo_fiesta.Models; +using octo_fiesta.Models.Settings; using octo_fiesta.Services.Validation; namespace octo_fiesta.Services.Qobuz; diff --git a/octo-fiesta/Services/StartupValidationService.cs b/octo-fiesta/Services/StartupValidationService.cs index a2ecc5b..c163603 100644 --- a/octo-fiesta/Services/StartupValidationService.cs +++ b/octo-fiesta/Services/StartupValidationService.cs @@ -1,5 +1,5 @@ using Microsoft.Extensions.Options; -using octo_fiesta.Models; +using octo_fiesta.Models.Settings; using octo_fiesta.Services.Deezer; using octo_fiesta.Services.Qobuz; diff --git a/octo-fiesta/Services/Validation/StartupValidationOrchestrator.cs b/octo-fiesta/Services/Validation/StartupValidationOrchestrator.cs index 0fb63a8..672b8be 100644 --- a/octo-fiesta/Services/Validation/StartupValidationOrchestrator.cs +++ b/octo-fiesta/Services/Validation/StartupValidationOrchestrator.cs @@ -1,5 +1,5 @@ using Microsoft.Extensions.Options; -using octo_fiesta.Models; +using octo_fiesta.Models.Settings; namespace octo_fiesta.Services.Validation; diff --git a/octo-fiesta/Services/Validation/SubsonicStartupValidator.cs b/octo-fiesta/Services/Validation/SubsonicStartupValidator.cs index ac16922..926613a 100644 --- a/octo-fiesta/Services/Validation/SubsonicStartupValidator.cs +++ b/octo-fiesta/Services/Validation/SubsonicStartupValidator.cs @@ -1,5 +1,5 @@ using Microsoft.Extensions.Options; -using octo_fiesta.Models; +using octo_fiesta.Models.Settings; namespace octo_fiesta.Services.Validation;