aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Entities
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Controller/Entities')
-rw-r--r--MediaBrowser.Controller/Entities/AggregateFolder.cs4
-rw-r--r--MediaBrowser.Controller/Entities/Audio/MusicArtist.cs2
-rw-r--r--MediaBrowser.Controller/Entities/BaseItem.cs49
-rw-r--r--MediaBrowser.Controller/Entities/Folder.cs37
-rw-r--r--MediaBrowser.Controller/Entities/TV/Episode.cs10
-rw-r--r--MediaBrowser.Controller/Entities/TV/Season.cs4
-rw-r--r--MediaBrowser.Controller/Entities/UserView.cs8
-rw-r--r--MediaBrowser.Controller/Entities/UserViewBuilder.cs4
-rw-r--r--MediaBrowser.Controller/Entities/Video.cs2
9 files changed, 47 insertions, 73 deletions
diff --git a/MediaBrowser.Controller/Entities/AggregateFolder.cs b/MediaBrowser.Controller/Entities/AggregateFolder.cs
index 9589f5245..77a857b78 100644
--- a/MediaBrowser.Controller/Entities/AggregateFolder.cs
+++ b/MediaBrowser.Controller/Entities/AggregateFolder.cs
@@ -187,14 +187,14 @@ namespace MediaBrowser.Controller.Entities
/// <exception cref="ArgumentNullException">The id is empty.</exception>
public BaseItem FindVirtualChild(Guid id)
{
- if (id.Equals(Guid.Empty))
+ if (id.Equals(default))
{
throw new ArgumentNullException(nameof(id));
}
foreach (var child in _virtualChildren)
{
- if (child.Id == id)
+ if (child.Id.Equals(id))
{
return child;
}
diff --git a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs
index 11b95b94b..0f2d7e62d 100644
--- a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs
+++ b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs
@@ -24,7 +24,7 @@ namespace MediaBrowser.Controller.Entities.Audio
public class MusicArtist : Folder, IItemByName, IHasMusicGenres, IHasDualAccess, IHasLookupInfo<ArtistInfo>
{
[JsonIgnore]
- public bool IsAccessedByName => ParentId.Equals(Guid.Empty);
+ public bool IsAccessedByName => ParentId.Equals(default);
[JsonIgnore]
public override bool IsFolder => !IsAccessedByName;
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs
index 0f62e8e1e..2bb966d2c 100644
--- a/MediaBrowser.Controller/Entities/BaseItem.cs
+++ b/MediaBrowser.Controller/Entities/BaseItem.cs
@@ -231,7 +231,7 @@ namespace MediaBrowser.Controller.Entities
{
get
{
- if (!ChannelId.Equals(Guid.Empty))
+ if (!ChannelId.Equals(default))
{
return SourceType.Channel;
}
@@ -521,7 +521,7 @@ namespace MediaBrowser.Controller.Entities
get
{
var id = DisplayParentId;
- if (id.Equals(Guid.Empty))
+ if (id.Equals(default))
{
return null;
}
@@ -737,7 +737,7 @@ namespace MediaBrowser.Controller.Entities
public virtual bool StopRefreshIfLocalMetadataFound => true;
[JsonIgnore]
- protected virtual bool SupportsOwnedItems => !ParentId.Equals(Guid.Empty) && IsFileProtocol;
+ protected virtual bool SupportsOwnedItems => !ParentId.Equals(default) && IsFileProtocol;
[JsonIgnore]
public virtual bool SupportsPeople => false;
@@ -848,7 +848,7 @@ namespace MediaBrowser.Controller.Entities
public BaseItem GetOwner()
{
var ownerId = OwnerId;
- return ownerId.Equals(Guid.Empty) ? null : LibraryManager.GetItemById(ownerId);
+ return ownerId.Equals(default) ? null : LibraryManager.GetItemById(ownerId);
}
public bool CanDelete(User user, List<Folder> allCollectionFolders)
@@ -878,16 +878,13 @@ namespace MediaBrowser.Controller.Entities
return CanDownload() && IsAuthorizedToDownload(user);
}
- /// <summary>
- /// Returns a <see cref="string" /> that represents this instance.
- /// </summary>
- /// <returns>A <see cref="string" /> that represents this instance.</returns>
+ /// <inheritdoc />
public override string ToString()
{
return Name;
}
- public string GetInternalMetadataPath()
+ public virtual string GetInternalMetadataPath()
{
var basePath = ConfigurationManager.ApplicationPaths.InternalMetadataPath;
@@ -984,12 +981,12 @@ namespace MediaBrowser.Controller.Entities
public BaseItem GetParent()
{
var parentId = ParentId;
- if (!parentId.Equals(Guid.Empty))
+ if (parentId.Equals(default))
{
- return LibraryManager.GetItemById(parentId);
+ return null;
}
- return null;
+ return LibraryManager.GetItemById(parentId);
}
public IEnumerable<BaseItem> GetParents()
@@ -1397,7 +1394,7 @@ namespace MediaBrowser.Controller.Entities
var tasks = extras.Select(i =>
{
var subOptions = new MetadataRefreshOptions(options);
- if (i.OwnerId != ownerId || i.ParentId != Guid.Empty)
+ if (!i.OwnerId.Equals(ownerId) || !i.ParentId.Equals(default))
{
i.OwnerId = ownerId;
i.ParentId = Guid.Empty;
@@ -1595,23 +1592,6 @@ namespace MediaBrowser.Controller.Entities
return value.Value <= maxAllowedRating.Value;
}
- public int? GetParentalRatingValue()
- {
- var rating = CustomRating;
-
- if (string.IsNullOrEmpty(rating))
- {
- rating = OfficialRating;
- }
-
- if (string.IsNullOrEmpty(rating))
- {
- return null;
- }
-
- return LocalizationManager.GetRatingLevel(rating);
- }
-
public int? GetInheritedParentalRatingValue()
{
var rating = CustomRatingForComparison;
@@ -1652,11 +1632,6 @@ namespace MediaBrowser.Controller.Entities
return true;
}
- protected virtual bool IsAllowTagFilterEnforced()
- {
- return true;
- }
-
public virtual UnratedItem GetBlockUnratedType()
{
if (SourceType == SourceType.Channel)
@@ -1736,7 +1711,7 @@ namespace MediaBrowser.Controller.Entities
// First get using the cached Id
if (info.ItemId.HasValue)
{
- if (info.ItemId.Value.Equals(Guid.Empty))
+ if (info.ItemId.Value.Equals(default))
{
return null;
}
@@ -2657,7 +2632,7 @@ namespace MediaBrowser.Controller.Entities
}
/// <inheritdoc />
- public bool Equals(BaseItem other) => Id == other?.Id;
+ public bool Equals(BaseItem other) => other is not null && other.Id.Equals(Id);
/// <inheritdoc />
public override int GetHashCode() => HashCode.Combine(Id);
diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs
index 4d9aac6f9..b6983b73e 100644
--- a/MediaBrowser.Controller/Entities/Folder.cs
+++ b/MediaBrowser.Controller/Entities/Folder.cs
@@ -189,21 +189,6 @@ namespace MediaBrowser.Controller.Entities
return baseResult;
}
- protected override bool IsAllowTagFilterEnforced()
- {
- if (this is ICollectionFolder)
- {
- return false;
- }
-
- if (this is UserView)
- {
- return false;
- }
-
- return true;
- }
-
/// <summary>
/// Adds the child.
/// </summary>
@@ -213,7 +198,7 @@ namespace MediaBrowser.Controller.Entities
{
item.SetParent(this);
- if (item.Id.Equals(Guid.Empty))
+ if (item.Id.Equals(default))
{
item.Id = LibraryManager.GetNewItemId(item.Path, item.GetType());
}
@@ -730,7 +715,9 @@ namespace MediaBrowser.Controller.Entities
return PostFilterAndSort(items, query, true);
}
- if (this is not UserRootFolder && this is not AggregateFolder && query.ParentId == Guid.Empty)
+ if (this is not UserRootFolder
+ && this is not AggregateFolder
+ && query.ParentId.Equals(default))
{
query.Parent = this;
}
@@ -848,6 +835,18 @@ namespace MediaBrowser.Controller.Entities
return true;
}
+ if (query.HasThemeSong.HasValue)
+ {
+ Logger.LogDebug("Query requires post-filtering due to HasThemeSong");
+ return true;
+ }
+
+ if (query.HasThemeVideo.HasValue)
+ {
+ Logger.LogDebug("Query requires post-filtering due to HasThemeVideo");
+ return true;
+ }
+
// Filter by VideoType
if (query.VideoTypes.Length > 0)
{
@@ -1492,7 +1491,7 @@ namespace MediaBrowser.Controller.Entities
{
if (i.ItemId.HasValue)
{
- if (i.ItemId.Value == itemId)
+ if (i.ItemId.Value.Equals(itemId))
{
return true;
}
@@ -1502,7 +1501,7 @@ namespace MediaBrowser.Controller.Entities
var child = GetLinkedChild(i);
- if (child != null && child.Id == itemId)
+ if (child != null && child.Id.Equals(itemId))
{
return true;
}
diff --git a/MediaBrowser.Controller/Entities/TV/Episode.cs b/MediaBrowser.Controller/Entities/TV/Episode.cs
index c8a0e21eb..15b721fe6 100644
--- a/MediaBrowser.Controller/Entities/TV/Episode.cs
+++ b/MediaBrowser.Controller/Entities/TV/Episode.cs
@@ -74,12 +74,12 @@ namespace MediaBrowser.Controller.Entities.TV
get
{
var seriesId = SeriesId;
- if (seriesId.Equals(Guid.Empty))
+ if (seriesId.Equals(default))
{
seriesId = FindSeriesId();
}
- return !seriesId.Equals(Guid.Empty) ? (LibraryManager.GetItemById(seriesId) as Series) : null;
+ return seriesId.Equals(default) ? null : (LibraryManager.GetItemById(seriesId) as Series);
}
}
@@ -89,12 +89,12 @@ namespace MediaBrowser.Controller.Entities.TV
get
{
var seasonId = SeasonId;
- if (seasonId.Equals(Guid.Empty))
+ if (seasonId.Equals(default))
{
seasonId = FindSeasonId();
}
- return !seasonId.Equals(Guid.Empty) ? (LibraryManager.GetItemById(seasonId) as Season) : null;
+ return seasonId.Equals(default) ? null : (LibraryManager.GetItemById(seasonId) as Season);
}
}
@@ -271,7 +271,7 @@ namespace MediaBrowser.Controller.Entities.TV
var seasonId = SeasonId;
- if (!seasonId.Equals(Guid.Empty) && !list.Contains(seasonId))
+ if (!seasonId.Equals(default) && !list.Contains(seasonId))
{
list.Add(seasonId);
}
diff --git a/MediaBrowser.Controller/Entities/TV/Season.cs b/MediaBrowser.Controller/Entities/TV/Season.cs
index 926c7b045..bd8df2fac 100644
--- a/MediaBrowser.Controller/Entities/TV/Season.cs
+++ b/MediaBrowser.Controller/Entities/TV/Season.cs
@@ -48,12 +48,12 @@ namespace MediaBrowser.Controller.Entities.TV
get
{
var seriesId = SeriesId;
- if (seriesId == Guid.Empty)
+ if (seriesId.Equals(default))
{
seriesId = FindSeriesId();
}
- return seriesId == Guid.Empty ? null : (LibraryManager.GetItemById(seriesId) as Series);
+ return seriesId.Equals(default) ? null : (LibraryManager.GetItemById(seriesId) as Series);
}
}
diff --git a/MediaBrowser.Controller/Entities/UserView.cs b/MediaBrowser.Controller/Entities/UserView.cs
index 5c9be7337..47432ee93 100644
--- a/MediaBrowser.Controller/Entities/UserView.cs
+++ b/MediaBrowser.Controller/Entities/UserView.cs
@@ -69,11 +69,11 @@ namespace MediaBrowser.Controller.Entities
/// <inheritdoc />
public override IEnumerable<Guid> GetIdsForAncestorQuery()
{
- if (!DisplayParentId.Equals(Guid.Empty))
+ if (!DisplayParentId.Equals(default))
{
yield return DisplayParentId;
}
- else if (!ParentId.Equals(Guid.Empty))
+ else if (!ParentId.Equals(default))
{
yield return ParentId;
}
@@ -94,11 +94,11 @@ namespace MediaBrowser.Controller.Entities
{
var parent = this as Folder;
- if (!DisplayParentId.Equals(Guid.Empty))
+ if (!DisplayParentId.Equals(default))
{
parent = LibraryManager.GetItemById(DisplayParentId) as Folder ?? parent;
}
- else if (!ParentId.Equals(Guid.Empty))
+ else if (!ParentId.Equals(default))
{
parent = LibraryManager.GetItemById(ParentId) as Folder ?? parent;
}
diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs
index 279206da4..2996104e7 100644
--- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs
+++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs
@@ -988,7 +988,7 @@ namespace MediaBrowser.Controller.Entities
public static IEnumerable<BaseItem> FilterForAdjacency(List<BaseItem> list, string adjacentToId)
{
var adjacentToIdGuid = new Guid(adjacentToId);
- var adjacentToItem = list.FirstOrDefault(i => i.Id == adjacentToIdGuid);
+ var adjacentToItem = list.FirstOrDefault(i => i.Id.Equals(adjacentToIdGuid));
var index = list.IndexOf(adjacentToItem);
@@ -1005,7 +1005,7 @@ namespace MediaBrowser.Controller.Entities
nextId = list[index + 1].Id;
}
- return list.Where(i => i.Id == previousId || i.Id == nextId || i.Id == adjacentToIdGuid);
+ return list.Where(i => i.Id.Equals(previousId) || i.Id.Equals(nextId) || i.Id.Equals(adjacentToIdGuid));
}
}
}
diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs
index 5ab7808c3..5de2e0f50 100644
--- a/MediaBrowser.Controller/Entities/Video.cs
+++ b/MediaBrowser.Controller/Entities/Video.cs
@@ -455,7 +455,7 @@ namespace MediaBrowser.Controller.Entities
foreach (var child in LinkedAlternateVersions)
{
// Reset the cached value
- if (child.ItemId.HasValue && child.ItemId.Value.Equals(Guid.Empty))
+ if (child.ItemId.HasValue && child.ItemId.Value.Equals(default))
{
child.ItemId = null;
}