Files
jellyfin/src/Jellyfin.Database/Jellyfin.Database.Implementations/Entities/Libraries/ItemMetadata.cs
Erik W e1e18e8da0 Add OriginalLanguage as option to PreferredAudioLanguage (#12579)
* Add OriginalLanguage as option to PreferredAudioLanguage

* Support for multiple original languages

* Add original audio stream indicator

* Fetch OriginalLanguage from TMDB

* Adapt to EFCore refactor

* Fix PlayDefaultAudioTrack OriginalLanguage behavior

* Fix better PlayDefaultAudioTrack OriginalLanguage behavior

* Add comment to ItemFields

* Improved PlayDefaultAudioTrack behavior

* Add migration for original language

* Use sting.Equals for string comparisons

* Always set dto OriginalLanguage

* Remove OriginalLanguage from ItemFields

---------

Co-authored-by: Lampan-git <lampan-git@users.noreply.github.com>
2026-05-07 20:07:23 +02:00

152 lines
4.5 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Database.Implementations.Interfaces;
namespace Jellyfin.Database.Implementations.Entities.Libraries
{
/// <summary>
/// An abstract class that holds metadata.
/// </summary>
public abstract class ItemMetadata : IHasArtwork, IHasConcurrencyToken
{
/// <summary>
/// Initializes a new instance of the <see cref="ItemMetadata"/> class.
/// </summary>
/// <param name="title">The title or name of the object.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param>
protected ItemMetadata(string title, string language)
{
ArgumentException.ThrowIfNullOrEmpty(title);
ArgumentException.ThrowIfNullOrEmpty(language);
Title = title;
Language = language;
DateAdded = DateTime.UtcNow;
DateModified = DateAdded;
PersonRoles = new HashSet<PersonRole>();
Genres = new HashSet<Genre>();
Artwork = new HashSet<Artwork>();
Ratings = new HashSet<Rating>();
Sources = new HashSet<MetadataProviderId>();
}
/// <summary>
/// Gets the id.
/// </summary>
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
/// <summary>
/// Gets or sets the title.
/// </summary>
/// <remarks>
/// Required, Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string Title { get; set; }
/// <summary>
/// Gets or sets the original title.
/// </summary>
/// <remarks>
/// Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string? OriginalTitle { get; set; }
/// <summary>
/// Gets or sets the original language.
/// </summary>
/// <remarks>
/// Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string? OriginalLanguage { get; set; }
/// <summary>
/// Gets or sets the sort title.
/// </summary>
/// <remarks>
/// Max length = 1024.
/// </remarks>
[MaxLength(1024)]
[StringLength(1024)]
public string? SortTitle { get; set; }
/// <summary>
/// Gets or sets the language.
/// </summary>
/// <remarks>
/// Required, Min length = 3, Max length = 3.
/// ISO-639-3 3-character language codes.
/// </remarks>
[MinLength(3)]
[MaxLength(3)]
[StringLength(3)]
public string Language { get; set; }
/// <summary>
/// Gets or sets the release date.
/// </summary>
public DateTimeOffset? ReleaseDate { get; set; }
/// <summary>
/// Gets the date added.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public DateTime DateAdded { get; private set; }
/// <summary>
/// Gets or sets the date modified.
/// </summary>
/// <remarks>
/// Required.
/// </remarks>
public DateTime DateModified { get; set; }
/// <inheritdoc />
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
/// <summary>
/// Gets a collection containing the person roles for this item.
/// </summary>
public virtual ICollection<PersonRole> PersonRoles { get; private set; }
/// <summary>
/// Gets a collection containing the genres for this item.
/// </summary>
public virtual ICollection<Genre> Genres { get; private set; }
/// <inheritdoc />
public virtual ICollection<Artwork> Artwork { get; private set; }
/// <summary>
/// Gets a collection containing the ratings for this item.
/// </summary>
public virtual ICollection<Rating> Ratings { get; private set; }
/// <summary>
/// Gets a collection containing the metadata sources for this item.
/// </summary>
public virtual ICollection<MetadataProviderId> Sources { get; private set; }
/// <inheritdoc />
public void OnSavingChanges()
{
RowVersion++;
}
}
}