| | | 1 | | #nullable disable |
| | | 2 | | |
| | | 3 | | #pragma warning disable CS1591 |
| | | 4 | | |
| | | 5 | | using System; |
| | | 6 | | using System.Collections.Generic; |
| | | 7 | | using System.Globalization; |
| | | 8 | | using System.Linq; |
| | | 9 | | using System.Text.Json.Serialization; |
| | | 10 | | using Jellyfin.Data.Enums; |
| | | 11 | | using MediaBrowser.Controller.Providers; |
| | | 12 | | using MediaBrowser.Model.Entities; |
| | | 13 | | using MediaBrowser.Model.Providers; |
| | | 14 | | |
| | | 15 | | namespace MediaBrowser.Controller.Entities.Movies |
| | | 16 | | { |
| | | 17 | | /// <summary> |
| | | 18 | | /// Class Movie. |
| | | 19 | | /// </summary> |
| | | 20 | | public class Movie : Video, IHasSpecialFeatures, IHasTrailers, IHasLookupInfo<MovieInfo>, ISupportsBoxSetGrouping |
| | | 21 | | { |
| | | 22 | | /// <inheritdoc /> |
| | | 23 | | [JsonIgnore] |
| | 0 | 24 | | public IReadOnlyList<Guid> SpecialFeatureIds => GetExtras() |
| | 0 | 25 | | .Where(extra => extra.ExtraType is not null && extra is Video) |
| | 0 | 26 | | .Select(extra => extra.Id) |
| | 0 | 27 | | .ToArray(); |
| | | 28 | | |
| | | 29 | | /// <inheritdoc /> |
| | | 30 | | [JsonIgnore] |
| | 0 | 31 | | public IReadOnlyList<BaseItem> LocalTrailers => GetExtras() |
| | 0 | 32 | | .Where(extra => extra.ExtraType == Model.Entities.ExtraType.Trailer) |
| | 0 | 33 | | .ToArray(); |
| | | 34 | | |
| | | 35 | | /// <summary> |
| | | 36 | | /// Gets or sets the name of the TMDb collection. |
| | | 37 | | /// </summary> |
| | | 38 | | /// <value>The name of the TMDb collection.</value> |
| | | 39 | | public string TmdbCollectionName { get; set; } |
| | | 40 | | |
| | | 41 | | [JsonIgnore] |
| | | 42 | | public string CollectionName |
| | | 43 | | { |
| | 2 | 44 | | get => TmdbCollectionName; |
| | 3 | 45 | | set => TmdbCollectionName = value; |
| | | 46 | | } |
| | | 47 | | |
| | | 48 | | public override double GetDefaultPrimaryImageAspectRatio() |
| | | 49 | | { |
| | | 50 | | // hack for tv plugins |
| | 0 | 51 | | if (SourceType == SourceType.Channel) |
| | | 52 | | { |
| | 0 | 53 | | return 0; |
| | | 54 | | } |
| | | 55 | | |
| | 0 | 56 | | return 2.0 / 3; |
| | | 57 | | } |
| | | 58 | | |
| | | 59 | | /// <inheritdoc /> |
| | | 60 | | public override UnratedItem GetBlockUnratedType() |
| | | 61 | | { |
| | 0 | 62 | | return UnratedItem.Movie; |
| | | 63 | | } |
| | | 64 | | |
| | | 65 | | public MovieInfo GetLookupInfo() |
| | | 66 | | { |
| | 0 | 67 | | var info = GetItemLookupInfo<MovieInfo>(); |
| | | 68 | | |
| | 0 | 69 | | if (!IsInMixedFolder) |
| | | 70 | | { |
| | 0 | 71 | | var name = System.IO.Path.GetFileName(ContainingFolderPath); |
| | | 72 | | |
| | 0 | 73 | | if (VideoType == VideoType.VideoFile || VideoType == VideoType.Iso) |
| | | 74 | | { |
| | 0 | 75 | | if (string.Equals(name, System.IO.Path.GetFileName(Path), StringComparison.OrdinalIgnoreCase)) |
| | | 76 | | { |
| | | 77 | | // if the folder has the file extension, strip it |
| | 0 | 78 | | name = System.IO.Path.GetFileNameWithoutExtension(name); |
| | | 79 | | } |
| | | 80 | | } |
| | | 81 | | |
| | 0 | 82 | | info.Name = name; |
| | | 83 | | } |
| | | 84 | | |
| | 0 | 85 | | return info; |
| | | 86 | | } |
| | | 87 | | |
| | | 88 | | /// <inheritdoc /> |
| | | 89 | | public override bool BeforeMetadataRefresh(bool replaceAllMetadata) |
| | | 90 | | { |
| | 0 | 91 | | var hasChanges = base.BeforeMetadataRefresh(replaceAllMetadata); |
| | | 92 | | |
| | 0 | 93 | | if (!ProductionYear.HasValue) |
| | | 94 | | { |
| | 0 | 95 | | var info = LibraryManager.ParseName(Name); |
| | | 96 | | |
| | 0 | 97 | | var yearInName = info.Year; |
| | | 98 | | |
| | 0 | 99 | | if (yearInName.HasValue) |
| | | 100 | | { |
| | 0 | 101 | | ProductionYear = yearInName; |
| | 0 | 102 | | hasChanges = true; |
| | | 103 | | } |
| | | 104 | | else |
| | | 105 | | { |
| | | 106 | | // Try to get the year from the folder name |
| | 0 | 107 | | if (!IsInMixedFolder) |
| | | 108 | | { |
| | 0 | 109 | | info = LibraryManager.ParseName(System.IO.Path.GetFileName(ContainingFolderPath)); |
| | | 110 | | |
| | 0 | 111 | | yearInName = info.Year; |
| | | 112 | | |
| | 0 | 113 | | if (yearInName.HasValue) |
| | | 114 | | { |
| | 0 | 115 | | ProductionYear = yearInName; |
| | 0 | 116 | | hasChanges = true; |
| | | 117 | | } |
| | | 118 | | } |
| | | 119 | | } |
| | | 120 | | } |
| | | 121 | | |
| | 0 | 122 | | return hasChanges; |
| | | 123 | | } |
| | | 124 | | } |
| | | 125 | | } |