mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-19 04:34:18 +01:00
Merge branch 'master' into minor
This commit is contained in:
@@ -198,6 +198,7 @@ namespace MediaBrowser.Controller.Entities.Audio
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return base.RequiresRefresh();
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
/// <summary>
|
||||
/// Class BaseItem
|
||||
/// </summary>
|
||||
public abstract class BaseItem : IHasProviderIds, IHasLookupInfo<ItemLookupInfo>
|
||||
public abstract class BaseItem : IHasProviderIds, IHasLookupInfo<ItemLookupInfo>, IEquatable<BaseItem>
|
||||
{
|
||||
/// <summary>
|
||||
/// The supported image extensions
|
||||
@@ -178,6 +178,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
|
||||
[JsonIgnore]
|
||||
public int? TotalBitrate { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public ExtraType? ExtraType { get; set; }
|
||||
|
||||
@@ -387,15 +388,12 @@ namespace MediaBrowser.Controller.Entities
|
||||
|
||||
while (thisMarker < s1.Length)
|
||||
{
|
||||
if (thisMarker >= s1.Length)
|
||||
{
|
||||
break;
|
||||
}
|
||||
char thisCh = s1[thisMarker];
|
||||
|
||||
var thisChunk = new StringBuilder();
|
||||
bool isNumeric = char.IsDigit(thisCh);
|
||||
|
||||
while ((thisMarker < s1.Length) && (thisChunk.Length == 0 || SortHelper.InChunk(thisCh, thisChunk[0])))
|
||||
while (thisMarker < s1.Length && char.IsDigit(thisCh) == isNumeric)
|
||||
{
|
||||
thisChunk.Append(thisCh);
|
||||
thisMarker++;
|
||||
@@ -406,7 +404,6 @@ namespace MediaBrowser.Controller.Entities
|
||||
}
|
||||
}
|
||||
|
||||
var isNumeric = thisChunk.Length > 0 && char.IsDigit(thisChunk[0]);
|
||||
list.Add(new Tuple<StringBuilder, bool>(thisChunk, isNumeric));
|
||||
}
|
||||
|
||||
@@ -2194,13 +2191,9 @@ namespace MediaBrowser.Controller.Entities
|
||||
/// <summary>
|
||||
/// Do whatever refreshing is necessary when the filesystem pertaining to this item has changed.
|
||||
/// </summary>
|
||||
/// <returns>Task.</returns>
|
||||
public virtual void ChangedExternally()
|
||||
{
|
||||
ProviderManager.QueueRefresh(Id, new MetadataRefreshOptions(new DirectoryService(FileSystem))
|
||||
{
|
||||
|
||||
}, RefreshPriority.High);
|
||||
ProviderManager.QueueRefresh(Id, new MetadataRefreshOptions(new DirectoryService(FileSystem)), RefreshPriority.High);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2231,7 +2224,6 @@ namespace MediaBrowser.Controller.Entities
|
||||
existingImage.Width = image.Width;
|
||||
existingImage.Height = image.Height;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
var current = ImageInfos;
|
||||
@@ -2274,7 +2266,6 @@ namespace MediaBrowser.Controller.Entities
|
||||
/// </summary>
|
||||
/// <param name="type">The type.</param>
|
||||
/// <param name="index">The index.</param>
|
||||
/// <returns>Task.</returns>
|
||||
public void DeleteImage(ImageType type, int index)
|
||||
{
|
||||
var info = GetImageInfo(type, index);
|
||||
@@ -2312,7 +2303,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates that images within the item are still on the file system
|
||||
/// Validates that images within the item are still on the filesystem.
|
||||
/// </summary>
|
||||
public bool ValidateImages(IDirectoryService directoryService)
|
||||
{
|
||||
@@ -2606,7 +2597,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is called before any metadata refresh and returns true or false indicating if changes were made
|
||||
/// This is called before any metadata refresh and returns true if changes were made.
|
||||
/// </summary>
|
||||
public virtual bool BeforeMetadataRefresh(bool replaceAllMetdata)
|
||||
{
|
||||
@@ -2666,36 +2657,43 @@ namespace MediaBrowser.Controller.Entities
|
||||
newOptions.ForceSave = true;
|
||||
ownedItem.Genres = item.Genres;
|
||||
}
|
||||
|
||||
if (!item.Studios.SequenceEqual(ownedItem.Studios, StringComparer.Ordinal))
|
||||
{
|
||||
newOptions.ForceSave = true;
|
||||
ownedItem.Studios = item.Studios;
|
||||
}
|
||||
|
||||
if (!item.ProductionLocations.SequenceEqual(ownedItem.ProductionLocations, StringComparer.Ordinal))
|
||||
{
|
||||
newOptions.ForceSave = true;
|
||||
ownedItem.ProductionLocations = item.ProductionLocations;
|
||||
}
|
||||
|
||||
if (item.CommunityRating != ownedItem.CommunityRating)
|
||||
{
|
||||
ownedItem.CommunityRating = item.CommunityRating;
|
||||
newOptions.ForceSave = true;
|
||||
}
|
||||
|
||||
if (item.CriticRating != ownedItem.CriticRating)
|
||||
{
|
||||
ownedItem.CriticRating = item.CriticRating;
|
||||
newOptions.ForceSave = true;
|
||||
}
|
||||
|
||||
if (!string.Equals(item.Overview, ownedItem.Overview, StringComparison.Ordinal))
|
||||
{
|
||||
ownedItem.Overview = item.Overview;
|
||||
newOptions.ForceSave = true;
|
||||
}
|
||||
|
||||
if (!string.Equals(item.OfficialRating, ownedItem.OfficialRating, StringComparison.Ordinal))
|
||||
{
|
||||
ownedItem.OfficialRating = item.OfficialRating;
|
||||
newOptions.ForceSave = true;
|
||||
}
|
||||
|
||||
if (!string.Equals(item.CustomRating, ownedItem.CustomRating, StringComparison.Ordinal))
|
||||
{
|
||||
ownedItem.CustomRating = item.CustomRating;
|
||||
@@ -2887,7 +2885,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
|
||||
public IEnumerable<BaseItem> GetExtras(IReadOnlyCollection<ExtraType> extraTypes)
|
||||
{
|
||||
return ExtraIds.Select(LibraryManager.GetItemById).Where(i => i != null && extraTypes.Contains(i.ExtraType.Value));
|
||||
return ExtraIds.Select(LibraryManager.GetItemById).Where(i => i?.ExtraType != null && extraTypes.Contains(i.ExtraType.Value));
|
||||
}
|
||||
|
||||
public IEnumerable<BaseItem> GetTrailers()
|
||||
@@ -2904,11 +2902,17 @@ namespace MediaBrowser.Controller.Entities
|
||||
}
|
||||
|
||||
public virtual bool IsHD => Height >= 720;
|
||||
|
||||
public bool IsShortcut { get; set; }
|
||||
|
||||
public string ShortcutPath { get; set; }
|
||||
|
||||
public int Width { get; set; }
|
||||
|
||||
public int Height { get; set; }
|
||||
|
||||
public Guid[] ExtraIds { get; set; }
|
||||
|
||||
public virtual long GetRunTimeTicksForPlayState()
|
||||
{
|
||||
return RunTimeTicks ?? 0;
|
||||
@@ -2918,5 +2922,17 @@ namespace MediaBrowser.Controller.Entities
|
||||
public static readonly IReadOnlyCollection<ExtraType> DisplayExtraTypes = new[] { Model.Entities.ExtraType.BehindTheScenes, Model.Entities.ExtraType.Clip, Model.Entities.ExtraType.DeletedScene, Model.Entities.ExtraType.Interview, Model.Entities.ExtraType.Sample, Model.Entities.ExtraType.Scene };
|
||||
|
||||
public virtual bool SupportsExternalTransfer => false;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is BaseItem baseItem && this.Equals(baseItem);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Equals(BaseItem item) => Object.Equals(Id, item?.Id);
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int GetHashCode() => HashCode.Combine(Id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,10 @@ namespace MediaBrowser.Controller.Entities
|
||||
|
||||
[JsonIgnore]
|
||||
public string SeriesPresentationUniqueKey { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public string SeriesName { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public Guid SeriesId { get; set; }
|
||||
|
||||
@@ -22,10 +24,12 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
return SeriesName;
|
||||
}
|
||||
|
||||
public string FindSeriesName()
|
||||
{
|
||||
return SeriesName;
|
||||
}
|
||||
|
||||
public string FindSeriesPresentationUniqueKey()
|
||||
{
|
||||
return SeriesPresentationUniqueKey;
|
||||
|
||||
@@ -324,10 +324,10 @@ namespace MediaBrowser.Controller.Entities
|
||||
ProviderManager.OnRefreshProgress(this, 5);
|
||||
}
|
||||
|
||||
//build a dictionary of the current children we have now by Id so we can compare quickly and easily
|
||||
// Build a dictionary of the current children we have now by Id so we can compare quickly and easily
|
||||
var currentChildren = GetActualChildrenDictionary();
|
||||
|
||||
//create a list for our validated children
|
||||
// Create a list for our validated children
|
||||
var newItems = new List<BaseItem>();
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
@@ -393,7 +393,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
var folder = this;
|
||||
innerProgress.RegisterAction(p =>
|
||||
{
|
||||
double newPct = .80 * p + 10;
|
||||
double newPct = 0.80 * p + 10;
|
||||
progress.Report(newPct);
|
||||
ProviderManager.OnRefreshProgress(folder, newPct);
|
||||
});
|
||||
@@ -423,7 +423,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
var folder = this;
|
||||
innerProgress.RegisterAction(p =>
|
||||
{
|
||||
double newPct = .10 * p + 90;
|
||||
double newPct = 0.10 * p + 90;
|
||||
progress.Report(newPct);
|
||||
if (recursive)
|
||||
{
|
||||
@@ -808,11 +808,45 @@ namespace MediaBrowser.Controller.Entities
|
||||
return false;
|
||||
}
|
||||
|
||||
private static BaseItem[] SortItemsByRequest(InternalItemsQuery query, IReadOnlyList<BaseItem> items)
|
||||
{
|
||||
var ids = query.ItemIds;
|
||||
int size = items.Count;
|
||||
|
||||
// ids can potentially contain non-unique guids, but query result cannot,
|
||||
// so we include only first occurrence of each guid
|
||||
var positions = new Dictionary<Guid, int>(size);
|
||||
int index = 0;
|
||||
for (int i = 0; i < ids.Length; i++)
|
||||
{
|
||||
if (positions.TryAdd(ids[i], index))
|
||||
{
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
var newItems = new BaseItem[size];
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
var item = items[i];
|
||||
newItems[positions[item.Id]] = item;
|
||||
}
|
||||
|
||||
return newItems;
|
||||
}
|
||||
|
||||
public QueryResult<BaseItem> GetItems(InternalItemsQuery query)
|
||||
{
|
||||
if (query.ItemIds.Length > 0)
|
||||
{
|
||||
return LibraryManager.GetItemsResult(query);
|
||||
var result = LibraryManager.GetItemsResult(query);
|
||||
|
||||
if (query.OrderBy.Count == 0 && query.ItemIds.Length > 1)
|
||||
{
|
||||
result.Items = SortItemsByRequest(query, result.Items);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return GetItemsInternal(query);
|
||||
@@ -824,7 +858,14 @@ namespace MediaBrowser.Controller.Entities
|
||||
|
||||
if (query.ItemIds.Length > 0)
|
||||
{
|
||||
return LibraryManager.GetItemList(query);
|
||||
var result = LibraryManager.GetItemList(query);
|
||||
|
||||
if (query.OrderBy.Count == 0 && query.ItemIds.Length > 1)
|
||||
{
|
||||
return SortItemsByRequest(query, result);
|
||||
}
|
||||
|
||||
return result.ToArray();
|
||||
}
|
||||
|
||||
return GetItemsInternal(query).Items;
|
||||
|
||||
Reference in New Issue
Block a user