mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-22 10:06:40 +00:00
update season queries
This commit is contained in:
@@ -955,20 +955,23 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||
dto.Genres = item.Genres;
|
||||
}
|
||||
|
||||
dto.ImageTags = new Dictionary<ImageType, string>();
|
||||
|
||||
// Prevent implicitly captured closure
|
||||
var currentItem = item;
|
||||
foreach (var image in currentItem.ImageInfos.Where(i => !currentItem.AllowsMultipleImages(i.Type))
|
||||
.ToList())
|
||||
if (options.EnableImages)
|
||||
{
|
||||
if (options.GetImageLimit(image.Type) > 0)
|
||||
{
|
||||
var tag = GetImageCacheTag(item, image);
|
||||
dto.ImageTags = new Dictionary<ImageType, string>();
|
||||
|
||||
if (tag != null)
|
||||
// Prevent implicitly captured closure
|
||||
var currentItem = item;
|
||||
foreach (var image in currentItem.ImageInfos.Where(i => !currentItem.AllowsMultipleImages(i.Type))
|
||||
.ToList())
|
||||
{
|
||||
if (options.GetImageLimit(image.Type) > 0)
|
||||
{
|
||||
dto.ImageTags[image.Type] = tag;
|
||||
var tag = GetImageCacheTag(item, image);
|
||||
|
||||
if (tag != null)
|
||||
{
|
||||
dto.ImageTags[image.Type] = tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1527,97 +1530,6 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Since it can be slow to make all of these calculations independently, this method will provide a way to do them all at once
|
||||
/// </summary>
|
||||
/// <param name="folder">The folder.</param>
|
||||
/// <param name="user">The user.</param>
|
||||
/// <param name="dto">The dto.</param>
|
||||
/// <param name="fields">The fields.</param>
|
||||
/// <param name="syncProgress">The synchronize progress.</param>
|
||||
/// <returns>Task.</returns>
|
||||
private async Task SetSpecialCounts(Folder folder, User user, BaseItemDto dto, List<ItemFields> fields, Dictionary<string, SyncJobItemStatus> syncProgress)
|
||||
{
|
||||
var recursiveItemCount = 0;
|
||||
var unplayed = 0;
|
||||
|
||||
double totalPercentPlayed = 0;
|
||||
double totalSyncPercent = 0;
|
||||
|
||||
var children = await folder.GetItems(new InternalItemsQuery
|
||||
{
|
||||
IsFolder = false,
|
||||
Recursive = true,
|
||||
ExcludeLocationTypes = new[] { LocationType.Virtual },
|
||||
User = user
|
||||
|
||||
}).ConfigureAwait(false);
|
||||
|
||||
// Loop through each recursive child
|
||||
foreach (var child in children.Items)
|
||||
{
|
||||
var userdata = _userDataRepository.GetUserData(user, child);
|
||||
|
||||
recursiveItemCount++;
|
||||
|
||||
var isUnplayed = true;
|
||||
|
||||
// Incrememt totalPercentPlayed
|
||||
if (userdata != null)
|
||||
{
|
||||
if (userdata.Played)
|
||||
{
|
||||
totalPercentPlayed += 100;
|
||||
|
||||
isUnplayed = false;
|
||||
}
|
||||
else if (userdata.PlaybackPositionTicks > 0 && child.RunTimeTicks.HasValue && child.RunTimeTicks.Value > 0)
|
||||
{
|
||||
double itemPercent = userdata.PlaybackPositionTicks;
|
||||
itemPercent /= child.RunTimeTicks.Value;
|
||||
totalPercentPlayed += itemPercent;
|
||||
}
|
||||
}
|
||||
|
||||
if (isUnplayed)
|
||||
{
|
||||
unplayed++;
|
||||
}
|
||||
|
||||
double percent = 0;
|
||||
SyncJobItemStatus syncItemProgress;
|
||||
if (syncProgress.TryGetValue(child.Id.ToString("N"), out syncItemProgress))
|
||||
{
|
||||
switch (syncItemProgress)
|
||||
{
|
||||
case SyncJobItemStatus.Synced:
|
||||
percent = 100;
|
||||
break;
|
||||
case SyncJobItemStatus.Converting:
|
||||
case SyncJobItemStatus.ReadyToTransfer:
|
||||
case SyncJobItemStatus.Transferring:
|
||||
percent = 50;
|
||||
break;
|
||||
}
|
||||
}
|
||||
totalSyncPercent += percent;
|
||||
}
|
||||
|
||||
dto.RecursiveItemCount = recursiveItemCount;
|
||||
dto.UserData.UnplayedItemCount = unplayed;
|
||||
|
||||
if (recursiveItemCount > 0)
|
||||
{
|
||||
dto.UserData.PlayedPercentage = totalPercentPlayed / recursiveItemCount;
|
||||
|
||||
var pct = totalSyncPercent / recursiveItemCount;
|
||||
if (pct > 0)
|
||||
{
|
||||
dto.SyncPercent = pct;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attaches the primary image aspect ratio.
|
||||
/// </summary>
|
||||
|
||||
@@ -829,7 +829,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
/// <returns>Task{Person}.</returns>
|
||||
public Person GetPerson(string name)
|
||||
{
|
||||
return GetItemByName<Person>(ConfigurationManager.ApplicationPaths.PeoplePath, name);
|
||||
return CreateItemByName<Person>(Person.GetPath(name), name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -839,7 +839,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
/// <returns>Task{Studio}.</returns>
|
||||
public Studio GetStudio(string name)
|
||||
{
|
||||
return GetItemByName<Studio>(ConfigurationManager.ApplicationPaths.StudioPath, name);
|
||||
return CreateItemByName<Studio>(Studio.GetPath(name), name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -849,7 +849,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
/// <returns>Task{Genre}.</returns>
|
||||
public Genre GetGenre(string name)
|
||||
{
|
||||
return GetItemByName<Genre>(ConfigurationManager.ApplicationPaths.GenrePath, name);
|
||||
return CreateItemByName<Genre>(Genre.GetPath(name), name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -859,7 +859,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
/// <returns>Task{MusicGenre}.</returns>
|
||||
public MusicGenre GetMusicGenre(string name)
|
||||
{
|
||||
return GetItemByName<MusicGenre>(ConfigurationManager.ApplicationPaths.MusicGenrePath, name);
|
||||
return CreateItemByName<MusicGenre>(MusicGenre.GetPath(name), name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -869,14 +869,9 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
/// <returns>Task{GameGenre}.</returns>
|
||||
public GameGenre GetGameGenre(string name)
|
||||
{
|
||||
return GetItemByName<GameGenre>(ConfigurationManager.ApplicationPaths.GameGenrePath, name);
|
||||
return CreateItemByName<GameGenre>(GameGenre.GetPath(name), name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The us culture
|
||||
/// </summary>
|
||||
private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a Year
|
||||
/// </summary>
|
||||
@@ -890,19 +885,9 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
throw new ArgumentOutOfRangeException("Years less than or equal to 0 are invalid.");
|
||||
}
|
||||
|
||||
return GetItemByName<Year>(ConfigurationManager.ApplicationPaths.YearPath, value.ToString(UsCulture));
|
||||
}
|
||||
var name = value.ToString(CultureInfo.InvariantCulture);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the artists path.
|
||||
/// </summary>
|
||||
/// <value>The artists path.</value>
|
||||
public string ArtistsPath
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.Combine(ConfigurationManager.ApplicationPaths.ItemsByNamePath, "artists");
|
||||
}
|
||||
return CreateItemByName<Year>(Year.GetPath(name), name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -912,48 +897,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
/// <returns>Task{Genre}.</returns>
|
||||
public MusicArtist GetArtist(string name)
|
||||
{
|
||||
return GetItemByName<MusicArtist>(ArtistsPath, name);
|
||||
}
|
||||
|
||||
private T GetItemByName<T>(string path, string name)
|
||||
where T : BaseItem, new()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(path))
|
||||
{
|
||||
throw new ArgumentNullException("path");
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
throw new ArgumentNullException("name");
|
||||
}
|
||||
|
||||
// Trim the period at the end because windows will have a hard time with that
|
||||
var validFilename = _fileSystem.GetValidFilename(name)
|
||||
.Trim()
|
||||
.TrimEnd('.');
|
||||
|
||||
string subFolderPrefix = null;
|
||||
|
||||
var type = typeof(T);
|
||||
|
||||
if (type == typeof(Person))
|
||||
{
|
||||
foreach (char c in validFilename)
|
||||
{
|
||||
if (char.IsLetterOrDigit(c))
|
||||
{
|
||||
subFolderPrefix = c.ToString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var fullPath = string.IsNullOrEmpty(subFolderPrefix) ?
|
||||
Path.Combine(path, validFilename) :
|
||||
Path.Combine(path, subFolderPrefix, validFilename);
|
||||
|
||||
return CreateItemByName<T>(fullPath, name);
|
||||
return CreateItemByName<MusicArtist>(MusicArtist.GetPath(name), name);
|
||||
}
|
||||
|
||||
private T CreateItemByName<T>(string path, string name)
|
||||
|
||||
@@ -166,12 +166,12 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
ExcludeItemTypes = excludeItemTypes.ToArray(),
|
||||
IncludeItemTypes = includeItemTypes.ToArray(),
|
||||
Limit = query.Limit,
|
||||
IncludeItemsByName = true
|
||||
|
||||
IncludeItemsByName = true,
|
||||
IsVirtualItem = false
|
||||
});
|
||||
|
||||
// Add search hints based on item name
|
||||
hints.AddRange(mediaItems.Where(IncludeInSearch).Select(item =>
|
||||
hints.AddRange(mediaItems.Select(item =>
|
||||
{
|
||||
var index = GetIndex(item.Name, searchTerm, terms);
|
||||
|
||||
@@ -187,20 +187,6 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
return Task.FromResult(returnValue);
|
||||
}
|
||||
|
||||
private bool IncludeInSearch(BaseItem item)
|
||||
{
|
||||
var episode = item as Episode;
|
||||
|
||||
if (episode != null)
|
||||
{
|
||||
if (episode.IsMissingEpisode)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the index.
|
||||
/// </summary>
|
||||
|
||||
@@ -3095,6 +3095,17 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
whereClauses.Add("LocationType<>'Virtual'");
|
||||
}
|
||||
}
|
||||
if (query.IsSpecialSeason.HasValue)
|
||||
{
|
||||
if (query.IsSpecialSeason.Value)
|
||||
{
|
||||
whereClauses.Add("IndexNumber = 0");
|
||||
}
|
||||
else
|
||||
{
|
||||
whereClauses.Add("IndexNumber <> 0");
|
||||
}
|
||||
}
|
||||
if (query.IsUnaired.HasValue)
|
||||
{
|
||||
if (query.IsUnaired.Value)
|
||||
|
||||
@@ -88,6 +88,14 @@ namespace MediaBrowser.Server.Implementations
|
||||
}
|
||||
}
|
||||
|
||||
public string ArtistsPath
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.Combine(ItemsByNamePath, "artists");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path to the Genre directory
|
||||
/// </summary>
|
||||
|
||||
@@ -1001,7 +1001,8 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
var series = episode.Series;
|
||||
if (series != null)
|
||||
{
|
||||
var episodes = series.GetEpisodes(user, false, false)
|
||||
var episodes = series.GetEpisodes(user)
|
||||
.Where(i => !i.IsVirtualItem)
|
||||
.SkipWhile(i => i.Id != episode.Id)
|
||||
.ToList();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user