mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 11:34:57 +02:00
commit
67d6dbadb0
7 changed files with 53 additions and 86 deletions
|
@ -83,7 +83,7 @@ namespace MediaBrowser.Controller.Entities.Audio
|
|||
public IEnumerable<BaseItem> GetTaggedItems(InternalItemsQuery query)
|
||||
{
|
||||
query.Genres = new[] { Name };
|
||||
query.ExcludeItemTypes = new[] { typeof(MusicVideo).Name, typeof(Audio).Name, typeof(MusicAlbum).Name, typeof(MusicArtist).Name };
|
||||
query.IncludeItemTypes = new[] { typeof(MusicVideo).Name, typeof(Audio).Name, typeof(MusicAlbum).Name, typeof(MusicArtist).Name };
|
||||
|
||||
return LibraryManager.GetItemList(query);
|
||||
}
|
||||
|
|
|
@ -1571,35 +1571,6 @@ namespace MediaBrowser.Controller.Entities
|
|||
await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds an item by path, recursively
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns>BaseItem.</returns>
|
||||
/// <exception cref="System.ArgumentNullException"></exception>
|
||||
public BaseItem FindByPath(string path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
throw new ArgumentNullException();
|
||||
}
|
||||
|
||||
if (string.Equals(Path, path, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
if (PhysicalLocations.Contains(path, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
return GetRecursiveChildren(i => string.Equals(i.Path, path, StringComparison.OrdinalIgnoreCase) ||
|
||||
(!i.IsFolder && !i.IsInMixedFolder && string.Equals(i.ContainingFolderPath, path, StringComparison.OrdinalIgnoreCase)) ||
|
||||
i.PhysicalLocations.Contains(path, StringComparer.OrdinalIgnoreCase))
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
public override bool IsPlayed(User user)
|
||||
{
|
||||
var itemsResult = GetItems(new InternalItemsQuery(user)
|
||||
|
|
|
@ -194,24 +194,13 @@ namespace MediaBrowser.Server.Implementations.Dto
|
|||
|
||||
private List<BaseItem> GetTaggedItems(IItemByName byName, User user)
|
||||
{
|
||||
var person = byName as Person;
|
||||
|
||||
if (person != null)
|
||||
var items = byName.GetTaggedItems(new InternalItemsQuery(user)
|
||||
{
|
||||
var items = _libraryManager.GetItemList(new InternalItemsQuery(user)
|
||||
{
|
||||
Person = byName.Name
|
||||
Recursive = true
|
||||
|
||||
}, new string[] { });
|
||||
}).ToList();
|
||||
|
||||
return items.ToList();
|
||||
}
|
||||
|
||||
var itemFilter = byName.GetItemFilter();
|
||||
|
||||
return user != null ?
|
||||
user.RootFolder.GetRecursiveChildren(user, itemFilter).ToList() :
|
||||
_libraryManager.RootFolder.GetRecursiveChildren(itemFilter).ToList();
|
||||
return items;
|
||||
}
|
||||
|
||||
private SyncedItemProgress[] GetSyncedItemProgress(DtoOptions options)
|
||||
|
@ -501,7 +490,7 @@ namespace MediaBrowser.Server.Implementations.Dto
|
|||
|
||||
if (fields.Contains(ItemFields.CumulativeRunTimeTicks))
|
||||
{
|
||||
dto.CumulativeRunTimeTicks = dto.RunTimeTicks;
|
||||
dto.CumulativeRunTimeTicks = item.RunTimeTicks;
|
||||
}
|
||||
|
||||
if (fields.Contains(ItemFields.DateLastMediaAdded))
|
||||
|
|
|
@ -306,9 +306,14 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
/// <returns>Task.</returns>
|
||||
private async Task UpdateSeasonZeroNames(string newName, CancellationToken cancellationToken)
|
||||
{
|
||||
var seasons = RootFolder.GetRecursiveChildren(i => i is Season)
|
||||
.Cast<Season>()
|
||||
.Where(i => i.IndexNumber.HasValue && i.IndexNumber.Value == 0 && !string.Equals(i.Name, newName, StringComparison.Ordinal))
|
||||
var seasons = GetItemList(new InternalItemsQuery
|
||||
{
|
||||
IncludeItemTypes = new[] { typeof(Season).Name },
|
||||
Recursive = true,
|
||||
IndexNumber = 0
|
||||
|
||||
}).Cast<Season>()
|
||||
.Where(i => !string.Equals(i.Name, newName, StringComparison.Ordinal))
|
||||
.ToList();
|
||||
|
||||
foreach (var season in seasons)
|
||||
|
@ -787,20 +792,14 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
IsFolder = isFolder
|
||||
};
|
||||
|
||||
// Only use the database result if there's exactly one item, otherwise we run the risk of returning old data that hasn't been cleaned yet.
|
||||
var items = GetItemIds(query).Select(GetItemById).Where(i => i != null).ToArray();
|
||||
// If this returns multiple items it could be tricky figuring out which one is correct.
|
||||
// In most cases, the newest one will be and the others obsolete but not yet cleaned up
|
||||
|
||||
if (items.Length == 1)
|
||||
{
|
||||
return items[0];
|
||||
}
|
||||
|
||||
if (items.Length == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return RootFolder.FindByPath(path);
|
||||
return GetItemIds(query)
|
||||
.Select(GetItemById)
|
||||
.Where(i => i != null)
|
||||
.OrderByDescending(i => i.DateCreated)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -6,6 +6,8 @@ using System;
|
|||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Library
|
||||
{
|
||||
|
@ -22,10 +24,12 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
|
||||
public async Task Run(IProgress<double> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
var items = _libraryManager.RootFolder
|
||||
.GetRecursiveChildren(i => i is IHasTrailers)
|
||||
.Cast<IHasTrailers>()
|
||||
.ToList();
|
||||
var items = _libraryManager.GetItemList(new InternalItemsQuery
|
||||
{
|
||||
IncludeItemTypes = new[] { typeof(BoxSet).Name, typeof(Game).Name, typeof(Movie).Name, typeof(Series).Name },
|
||||
Recursive = true
|
||||
|
||||
}).OfType<IHasTrailers>().ToList();
|
||||
|
||||
var trailerTypes = Enum.GetNames(typeof(TrailerType))
|
||||
.Select(i => (TrailerType)Enum.Parse(typeof(TrailerType), i, true))
|
||||
|
@ -35,7 +39,8 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
var trailers = _libraryManager.GetItemList(new InternalItemsQuery
|
||||
{
|
||||
IncludeItemTypes = new[] { typeof(Trailer).Name },
|
||||
TrailerTypes = trailerTypes
|
||||
TrailerTypes = trailerTypes,
|
||||
Recursive = true
|
||||
|
||||
}).ToArray();
|
||||
|
||||
|
|
|
@ -20,16 +20,12 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
|||
|
||||
public async Task Run(IProgress<double> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
var allYears = _libraryManager.RootFolder.GetRecursiveChildren(i => i.ProductionYear.HasValue)
|
||||
.Select(i => i.ProductionYear ?? -1)
|
||||
.Where(i => i > 0)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
|
||||
var count = allYears.Count;
|
||||
var yearNumber = 1900;
|
||||
var maxYear = DateTime.UtcNow.Year + 3;
|
||||
var count = maxYear - yearNumber + 1;
|
||||
var numComplete = 0;
|
||||
|
||||
foreach (var yearNumber in allYears)
|
||||
while (yearNumber < DateTime.UtcNow.Year + 3)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
@ -1304,6 +1304,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
{
|
||||
throw new ArgumentNullException("id");
|
||||
}
|
||||
var list = new List<ChapterInfo>();
|
||||
|
||||
using (var cmd = _connection.CreateCommand())
|
||||
{
|
||||
|
@ -1315,10 +1316,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
yield return GetChapter(reader);
|
||||
list.Add(GetChapter(reader));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1632,9 +1635,9 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
|
||||
using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult))
|
||||
{
|
||||
Logger.Debug("GetItemList query time: {0}ms. Query: {1}",
|
||||
Convert.ToInt32((DateTime.UtcNow - now).TotalMilliseconds),
|
||||
cmd.CommandText);
|
||||
//Logger.Debug("GetItemList query time: {0}ms. Query: {1}",
|
||||
// Convert.ToInt32((DateTime.UtcNow - now).TotalMilliseconds),
|
||||
// cmd.CommandText);
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
|
@ -1717,9 +1720,9 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
|
||||
using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess))
|
||||
{
|
||||
Logger.Debug("GetItems query time: {0}ms. Query: {1}",
|
||||
Convert.ToInt32((DateTime.UtcNow - now).TotalMilliseconds),
|
||||
cmd.CommandText);
|
||||
//Logger.Debug("GetItems query time: {0}ms. Query: {1}",
|
||||
// Convert.ToInt32((DateTime.UtcNow - now).TotalMilliseconds),
|
||||
// cmd.CommandText);
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
|
@ -2029,9 +2032,9 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
|
||||
using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess))
|
||||
{
|
||||
Logger.Debug("GetItemIds query time: {0}ms. Query: {1}",
|
||||
Convert.ToInt32((DateTime.UtcNow - now).TotalMilliseconds),
|
||||
cmd.CommandText);
|
||||
//Logger.Debug("GetItemIds query time: {0}ms. Query: {1}",
|
||||
// Convert.ToInt32((DateTime.UtcNow - now).TotalMilliseconds),
|
||||
// cmd.CommandText);
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
|
@ -3288,6 +3291,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
throw new ArgumentNullException("query");
|
||||
}
|
||||
|
||||
var list = new List<MediaStream>();
|
||||
|
||||
using (var cmd = _connection.CreateCommand())
|
||||
{
|
||||
var cmdText = "select " + string.Join(",", _mediaStreamSaveColumns) + " from mediastreams where";
|
||||
|
@ -3315,10 +3320,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
yield return GetMediaStream(reader);
|
||||
list.Add(GetMediaStream(reader));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public async Task SaveMediaStreams(Guid id, IEnumerable<MediaStream> streams, CancellationToken cancellationToken)
|
||||
|
|
Loading…
Reference in a new issue