mirror of
https://github.com/Radarr/Radarr
synced 2026-04-28 22:01:16 +02:00
refactor(core): create MediaItem abstract base class (#117)
* feat(db): add MediaType discriminator to Movies table Adds foundation for multi-media support by: - Adding MediaType column to Movies table (migration 244) - Adding MediaType property to Movie entity, defaulting to Movie Existing movies will have MediaType=1 (Movie) after migration. This prepares for future Book and Audiobook media types. Addresses Issue #1 * refactor(core): create MediaItem abstract base class Extracts common properties from Movie into a new MediaItem base class: - MediaType, Monitored, QualityProfileId - Path, RootFolderPath, Added, Tags, LastSearchTime Movie now inherits from MediaItem and implements abstract methods GetTitle() and GetYear() while maintaining backward-compatible Title/Year property accessors. This prepares for Book and Audiobook entities that will share the same base structure. Addresses Issue #1 --------- Co-authored-by: admin <admin@ardentleatherworks.com>
This commit is contained in:
parent
841128caee
commit
10c333a7d3
2 changed files with 42 additions and 22 deletions
27
src/NzbDrone.Core/MediaItems/MediaItem.cs
Normal file
27
src/NzbDrone.Core/MediaItems/MediaItem.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.MediaTypes;
|
||||
|
||||
namespace NzbDrone.Core.MediaItems
|
||||
{
|
||||
public abstract class MediaItem : ModelBase
|
||||
{
|
||||
protected MediaItem()
|
||||
{
|
||||
Tags = new HashSet<int>();
|
||||
}
|
||||
|
||||
public MediaType MediaType { get; set; }
|
||||
public bool Monitored { get; set; }
|
||||
public int QualityProfileId { get; set; }
|
||||
public string Path { get; set; }
|
||||
public string RootFolderPath { get; set; }
|
||||
public DateTime Added { get; set; }
|
||||
public HashSet<int> Tags { get; set; }
|
||||
public DateTime? LastSearchTime { get; set; }
|
||||
|
||||
public abstract string GetTitle();
|
||||
public abstract int GetYear();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,50 +1,49 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.MediaItems;
|
||||
using NzbDrone.Core.MediaTypes;
|
||||
using NzbDrone.Core.Profiles.Qualities;
|
||||
|
||||
namespace NzbDrone.Core.Movies
|
||||
{
|
||||
public class Movie : ModelBase
|
||||
public class Movie : MediaItem
|
||||
{
|
||||
public Movie()
|
||||
{
|
||||
Tags = new HashSet<int>();
|
||||
MovieMetadata = new MovieMetadata();
|
||||
MediaType = MediaType.Movie;
|
||||
}
|
||||
|
||||
public int MovieMetadataId { get; set; }
|
||||
public MediaType MediaType { get; set; }
|
||||
|
||||
public bool Monitored { get; set; }
|
||||
public MovieStatusType MinimumAvailability { get; set; }
|
||||
public int QualityProfileId { get; set; }
|
||||
|
||||
public string Path { get; set; }
|
||||
|
||||
public LazyLoaded<MovieMetadata> MovieMetadata { get; set; }
|
||||
|
||||
public string RootFolderPath { get; set; }
|
||||
public DateTime Added { get; set; }
|
||||
public QualityProfile QualityProfile { get; set; }
|
||||
public HashSet<int> Tags { get; set; }
|
||||
public AddMovieOptions AddOptions { get; set; }
|
||||
public DateTime? LastSearchTime { get; set; }
|
||||
public MovieFile MovieFile { get; set; }
|
||||
public int MovieFileId { get; set; }
|
||||
|
||||
public bool HasFile => MovieFileId > 0;
|
||||
|
||||
// compatibility properties
|
||||
// MediaItem abstract method implementations
|
||||
public override string GetTitle() => MovieMetadata.Value.Title;
|
||||
public override int GetYear() => MovieMetadata.Value.Year;
|
||||
|
||||
// Backward-compatible property accessors
|
||||
public string Title
|
||||
{
|
||||
get { return MovieMetadata.Value.Title; }
|
||||
set { MovieMetadata.Value.Title = value; }
|
||||
get => MovieMetadata.Value.Title;
|
||||
set => MovieMetadata.Value.Title = value;
|
||||
}
|
||||
|
||||
public int Year
|
||||
{
|
||||
get => MovieMetadata.Value.Year;
|
||||
set => MovieMetadata.Value.Year = value;
|
||||
}
|
||||
|
||||
public int TmdbId
|
||||
|
|
@ -59,12 +58,6 @@ public string ImdbId
|
|||
set { MovieMetadata.Value.ImdbId = value; }
|
||||
}
|
||||
|
||||
public int Year
|
||||
{
|
||||
get { return MovieMetadata.Value.Year; }
|
||||
set { MovieMetadata.Value.Year = value; }
|
||||
}
|
||||
|
||||
public string FolderName()
|
||||
{
|
||||
if (Path.IsNullOrWhiteSpace())
|
||||
|
|
|
|||
Loading…
Reference in a new issue