update folder queries
This commit is contained in:
parent
ffb935700c
commit
da39d9a5bf
|
@ -470,7 +470,7 @@ namespace Emby.Server.Implementations.FileOrganization
|
||||||
return new List<string>();
|
return new List<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
var episodePaths = series.GetRecursiveChildren()
|
var episodePaths = series.GetRecursiveChildren(i => i is Episode)
|
||||||
.OfType<Episode>()
|
.OfType<Episode>()
|
||||||
.Where(i =>
|
.Where(i =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,6 +5,7 @@ using MediaBrowser.Controller.Playlists;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using MediaBrowser.Model.Querying;
|
||||||
|
|
||||||
namespace Emby.Server.Implementations.Library
|
namespace Emby.Server.Implementations.Library
|
||||||
{
|
{
|
||||||
|
@ -27,53 +28,17 @@ namespace Emby.Server.Implementations.Library
|
||||||
return list.Concat(GetInstantMixFromGenres(item.Genres, user));
|
return list.Concat(GetInstantMixFromGenres(item.Genres, user));
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Audio> GetInstantMixFromArtist(MusicArtist artist, User user)
|
public IEnumerable<Audio> GetInstantMixFromArtist(MusicArtist item, User user)
|
||||||
{
|
{
|
||||||
var genres = user.RootFolder
|
return GetInstantMixFromGenres(item.Genres, user);
|
||||||
.GetRecursiveChildren(user, new InternalItemsQuery(user)
|
|
||||||
{
|
|
||||||
IncludeItemTypes = new[] { typeof(Audio).Name }
|
|
||||||
})
|
|
||||||
.Cast<Audio>()
|
|
||||||
.Where(i => i.HasAnyArtist(artist.Name))
|
|
||||||
.SelectMany(i => i.Genres)
|
|
||||||
.Concat(artist.Genres)
|
|
||||||
.Distinct(StringComparer.OrdinalIgnoreCase);
|
|
||||||
|
|
||||||
return GetInstantMixFromGenres(genres, user);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Audio> GetInstantMixFromAlbum(MusicAlbum item, User user)
|
public IEnumerable<Audio> GetInstantMixFromAlbum(MusicAlbum item, User user)
|
||||||
{
|
{
|
||||||
var genres = item
|
return GetInstantMixFromGenres(item.Genres, user);
|
||||||
.GetRecursiveChildren(user, new InternalItemsQuery(user)
|
|
||||||
{
|
|
||||||
IncludeItemTypes = new[] { typeof(Audio).Name }
|
|
||||||
})
|
|
||||||
.Cast<Audio>()
|
|
||||||
.SelectMany(i => i.Genres)
|
|
||||||
.Concat(item.Genres)
|
|
||||||
.DistinctNames();
|
|
||||||
|
|
||||||
return GetInstantMixFromGenres(genres, user);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Audio> GetInstantMixFromFolder(Folder item, User user)
|
public IEnumerable<Audio> GetInstantMixFromFolder(Folder item, User user)
|
||||||
{
|
|
||||||
var genres = item
|
|
||||||
.GetRecursiveChildren(user, new InternalItemsQuery(user)
|
|
||||||
{
|
|
||||||
IncludeItemTypes = new[] {typeof(Audio).Name}
|
|
||||||
})
|
|
||||||
.Cast<Audio>()
|
|
||||||
.SelectMany(i => i.Genres)
|
|
||||||
.Concat(item.Genres)
|
|
||||||
.DistinctNames();
|
|
||||||
|
|
||||||
return GetInstantMixFromGenres(genres, user);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Audio> GetInstantMixFromPlaylist(Playlist item, User user)
|
|
||||||
{
|
{
|
||||||
var genres = item
|
var genres = item
|
||||||
.GetRecursiveChildren(user, new InternalItemsQuery(user)
|
.GetRecursiveChildren(user, new InternalItemsQuery(user)
|
||||||
|
@ -88,28 +53,42 @@ namespace Emby.Server.Implementations.Library
|
||||||
return GetInstantMixFromGenres(genres, user);
|
return GetInstantMixFromGenres(genres, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Audio> GetInstantMixFromPlaylist(Playlist item, User user)
|
||||||
|
{
|
||||||
|
return GetInstantMixFromGenres(item.Genres, user);
|
||||||
|
}
|
||||||
|
|
||||||
public IEnumerable<Audio> GetInstantMixFromGenres(IEnumerable<string> genres, User user)
|
public IEnumerable<Audio> GetInstantMixFromGenres(IEnumerable<string> genres, User user)
|
||||||
{
|
{
|
||||||
var genreList = genres.ToList();
|
var genreIds = genres.DistinctNames().Select(i =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _libraryManager.GetMusicGenre(i).Id.ToString("N");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
var inputItems = _libraryManager.GetItemList(new InternalItemsQuery(user)
|
}).Where(i => i != null);
|
||||||
|
|
||||||
|
return GetInstantMixFromGenreIds(genreIds, user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Audio> GetInstantMixFromGenreIds(IEnumerable<string> genreIds, User user)
|
||||||
|
{
|
||||||
|
return _libraryManager.GetItemList(new InternalItemsQuery(user)
|
||||||
{
|
{
|
||||||
IncludeItemTypes = new[] { typeof(Audio).Name },
|
IncludeItemTypes = new[] { typeof(Audio).Name },
|
||||||
|
|
||||||
Genres = genreList.ToArray()
|
GenreIds = genreIds.ToArray(),
|
||||||
|
|
||||||
});
|
Limit = 200,
|
||||||
|
|
||||||
var genresDictionary = genreList.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);
|
SortBy = new[] { ItemSortBy.Random }
|
||||||
|
|
||||||
return inputItems
|
}).Cast<Audio>();
|
||||||
.Cast<Audio>()
|
|
||||||
.Select(i => new Tuple<Audio, int>(i, i.Genres.Count(genresDictionary.ContainsKey)))
|
|
||||||
.OrderByDescending(i => i.Item2)
|
|
||||||
.ThenBy(i => Guid.NewGuid())
|
|
||||||
.Select(i => i.Item1)
|
|
||||||
.Take(200)
|
|
||||||
.OrderBy(i => Guid.NewGuid());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Audio> GetInstantMixFromItem(BaseItem item, User user)
|
public IEnumerable<Audio> GetInstantMixFromItem(BaseItem item, User user)
|
||||||
|
@ -117,7 +96,7 @@ namespace Emby.Server.Implementations.Library
|
||||||
var genre = item as MusicGenre;
|
var genre = item as MusicGenre;
|
||||||
if (genre != null)
|
if (genre != null)
|
||||||
{
|
{
|
||||||
return GetInstantMixFromGenres(new[] { item.Name }, user);
|
return GetInstantMixFromGenreIds(new[] { item.Id.ToString("N") }, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
var playlist = item as Playlist;
|
var playlist = item as Playlist;
|
||||||
|
|
|
@ -112,7 +112,7 @@ namespace MediaBrowser.Controller.Entities.Audio
|
||||||
|
|
||||||
public IEnumerable<BaseItem> GetTaggedItems(InternalItemsQuery query)
|
public IEnumerable<BaseItem> GetTaggedItems(InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
query.Genres = new[] { Name };
|
query.GenreIds = new[] { Id.ToString("N") };
|
||||||
query.IncludeItemTypes = 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);
|
return LibraryManager.GetItemList(query);
|
||||||
|
|
|
@ -81,7 +81,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
public IEnumerable<BaseItem> GetTaggedItems(InternalItemsQuery query)
|
public IEnumerable<BaseItem> GetTaggedItems(InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
query.Genres = new[] { Name };
|
query.GenreIds = new[] { Id.ToString("N") };
|
||||||
query.IncludeItemTypes = new[] { typeof(Game).Name };
|
query.IncludeItemTypes = new[] { typeof(Game).Name };
|
||||||
|
|
||||||
return LibraryManager.GetItemList(query);
|
return LibraryManager.GetItemList(query);
|
||||||
|
|
|
@ -93,7 +93,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
public IEnumerable<BaseItem> GetTaggedItems(InternalItemsQuery query)
|
public IEnumerable<BaseItem> GetTaggedItems(InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
query.Genres = new[] { Name };
|
query.GenreIds = new[] { Id.ToString("N") };
|
||||||
query.ExcludeItemTypes = new[] { typeof(Game).Name, typeof(MusicVideo).Name, typeof(Audio.Audio).Name, typeof(MusicAlbum).Name, typeof(MusicArtist).Name };
|
query.ExcludeItemTypes = new[] { typeof(Game).Name, typeof(MusicVideo).Name, typeof(Audio.Audio).Name, typeof(MusicAlbum).Name, typeof(MusicArtist).Name };
|
||||||
|
|
||||||
return LibraryManager.GetItemList(query);
|
return LibraryManager.GetItemList(query);
|
||||||
|
|
|
@ -152,9 +152,7 @@ namespace MediaBrowser.Controller.Entities.Movies
|
||||||
var currentOfficialRating = OfficialRating;
|
var currentOfficialRating = OfficialRating;
|
||||||
|
|
||||||
// Gather all possible ratings
|
// Gather all possible ratings
|
||||||
var ratings = GetRecursiveChildren()
|
var ratings = GetRecursiveChildren(i => i is Movie || i is Series || i is MusicAlbum || i is Game)
|
||||||
.Concat(GetLinkedChildren())
|
|
||||||
.Where(i => i is Movie || i is Series || i is MusicAlbum || i is Game)
|
|
||||||
.Select(i => i.OfficialRating)
|
.Select(i => i.OfficialRating)
|
||||||
.Where(i => !string.IsNullOrEmpty(i))
|
.Where(i => !string.IsNullOrEmpty(i))
|
||||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||||
|
|
|
@ -586,7 +586,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
query.Recursive = true;
|
query.Recursive = true;
|
||||||
query.ParentId = queryParent.Id;
|
query.ParentId = queryParent.Id;
|
||||||
query.Genres = new[] { displayParent.Name };
|
query.GenreIds = new[] { displayParent.Id.ToString("N") };
|
||||||
query.SetUser(user);
|
query.SetUser(user);
|
||||||
|
|
||||||
query.IncludeItemTypes = new[] { typeof(Movie).Name };
|
query.IncludeItemTypes = new[] { typeof(Movie).Name };
|
||||||
|
@ -729,7 +729,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
query.Recursive = true;
|
query.Recursive = true;
|
||||||
query.ParentId = queryParent.Id;
|
query.ParentId = queryParent.Id;
|
||||||
query.Genres = new[] { displayParent.Name };
|
query.GenreIds = new[] { displayParent.Id.ToString("N") };
|
||||||
query.SetUser(user);
|
query.SetUser(user);
|
||||||
|
|
||||||
query.IncludeItemTypes = new[] { typeof(Series).Name };
|
query.IncludeItemTypes = new[] { typeof(Series).Name };
|
||||||
|
@ -905,6 +905,11 @@ namespace MediaBrowser.Controller.Entities
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (request.GenreIds.Length > 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (request.HasImdbId.HasValue)
|
if (request.HasImdbId.HasValue)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -1768,26 +1773,6 @@ namespace MediaBrowser.Controller.Entities
|
||||||
return new List<Folder> { parent };
|
return new List<Folder> { parent };
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<BaseItem> GetRecursiveChildren(Folder parent, User user, IEnumerable<string> viewTypes)
|
|
||||||
{
|
|
||||||
if (parent == null || parent is UserView)
|
|
||||||
{
|
|
||||||
if (user == null)
|
|
||||||
{
|
|
||||||
return GetMediaFolders(null, viewTypes).SelectMany(i => i.GetRecursiveChildren());
|
|
||||||
}
|
|
||||||
|
|
||||||
return GetMediaFolders(user, viewTypes).SelectMany(i => i.GetRecursiveChildren(user));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (user == null)
|
|
||||||
{
|
|
||||||
return parent.GetRecursiveChildren();
|
|
||||||
}
|
|
||||||
|
|
||||||
return parent.GetRecursiveChildren(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task<QueryResult<BaseItem>> GetLiveTvView(Folder queryParent, User user, InternalItemsQuery query)
|
private async Task<QueryResult<BaseItem>> GetLiveTvView(Folder queryParent, User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
if (query.Recursive)
|
if (query.Recursive)
|
||||||
|
|
|
@ -134,34 +134,27 @@ namespace MediaBrowser.Controller.Playlists
|
||||||
var musicGenre = item as MusicGenre;
|
var musicGenre = item as MusicGenre;
|
||||||
if (musicGenre != null)
|
if (musicGenre != null)
|
||||||
{
|
{
|
||||||
var items = LibraryManager.GetItemList(new InternalItemsQuery(user)
|
return LibraryManager.GetItemList(new InternalItemsQuery(user)
|
||||||
{
|
{
|
||||||
Recursive = true,
|
Recursive = true,
|
||||||
IncludeItemTypes = new[] { typeof(Audio).Name },
|
IncludeItemTypes = new[] { typeof(Audio).Name },
|
||||||
Genres = new[] { musicGenre.Name }
|
GenreIds = new[] { musicGenre.Id.ToString("N") },
|
||||||
|
SortBy = new[] { ItemSortBy.AlbumArtist, ItemSortBy.Album, ItemSortBy.SortName },
|
||||||
|
SortOrder = SortOrder.Ascending
|
||||||
});
|
});
|
||||||
|
|
||||||
return LibraryManager.Sort(items, user, new[] { ItemSortBy.AlbumArtist, ItemSortBy.Album, ItemSortBy.SortName }, SortOrder.Ascending);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var musicArtist = item as MusicArtist;
|
var musicArtist = item as MusicArtist;
|
||||||
if (musicArtist != null)
|
if (musicArtist != null)
|
||||||
{
|
{
|
||||||
Func<BaseItem, bool> filter = i =>
|
return LibraryManager.GetItemList(new InternalItemsQuery(user)
|
||||||
{
|
{
|
||||||
var audio = i as Audio;
|
Recursive = true,
|
||||||
return audio != null && audio.HasAnyArtist(musicArtist.Name);
|
IncludeItemTypes = new[] { typeof(Audio).Name },
|
||||||
};
|
ArtistIds = new[] { musicArtist.Id.ToString("N") },
|
||||||
|
SortBy = new[] { ItemSortBy.AlbumArtist, ItemSortBy.Album, ItemSortBy.SortName },
|
||||||
var items = user == null
|
SortOrder = SortOrder.Ascending
|
||||||
? LibraryManager.RootFolder.GetRecursiveChildren(filter)
|
});
|
||||||
: user.RootFolder.GetRecursiveChildren(user, new InternalItemsQuery(user)
|
|
||||||
{
|
|
||||||
IncludeItemTypes = new[] { typeof(Audio).Name },
|
|
||||||
ArtistIds = new[] { musicArtist.Id.ToString("N") }
|
|
||||||
});
|
|
||||||
|
|
||||||
return LibraryManager.Sort(items, user, new[] { ItemSortBy.AlbumArtist, ItemSortBy.Album, ItemSortBy.SortName }, SortOrder.Ascending);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var folder = item as Folder;
|
var folder = item as Folder;
|
||||||
|
|
|
@ -41,8 +41,6 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||||
|
|
||||||
public string ItemType { get; set; }
|
public string ItemType { get; set; }
|
||||||
|
|
||||||
public string AlbumCoverPath { get; set; }
|
|
||||||
|
|
||||||
public string GetMimeType(string outputPath)
|
public string GetMimeType(string outputPath)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(MimeType))
|
if (!string.IsNullOrEmpty(MimeType))
|
||||||
|
|
|
@ -20,8 +20,7 @@ namespace MediaBrowser.Providers.Music
|
||||||
{
|
{
|
||||||
var album = (MusicAlbum)item;
|
var album = (MusicAlbum)item;
|
||||||
|
|
||||||
var image = album.GetRecursiveChildren()
|
var image = album.GetRecursiveChildren(i => !i.IsFolder)
|
||||||
.OfType<Audio>()
|
|
||||||
.Select(i => i.GetImageInfo(type, 0))
|
.Select(i => i.GetImageInfo(type, 0))
|
||||||
.FirstOrDefault(i => i != null && i.IsLocalFile);
|
.FirstOrDefault(i => i != null && i.IsLocalFile);
|
||||||
|
|
||||||
|
|
|
@ -53,8 +53,8 @@ namespace MediaBrowser.Providers.TV
|
||||||
|
|
||||||
private async Task<bool> AddDummySeasonFolders(Series series, CancellationToken cancellationToken)
|
private async Task<bool> AddDummySeasonFolders(Series series, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var episodesInSeriesFolder = series.GetRecursiveChildren()
|
var episodesInSeriesFolder = series.GetRecursiveChildren(i => i is Episode)
|
||||||
.OfType<Episode>()
|
.Cast<Episode>()
|
||||||
.Where(i => !i.IsInSeasonFolder)
|
.Where(i => !i.IsInSeasonFolder)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
|
|
|
@ -203,7 +203,7 @@ namespace MediaBrowser.Providers.TV
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var existingEpisodes = (from s in series
|
var existingEpisodes = (from s in series
|
||||||
from c in s.GetRecursiveChildren().OfType<Episode>()
|
from c in s.GetRecursiveChildren(i => i is Episode).Cast<Episode>()
|
||||||
select new Tuple<int, Episode>((c.ParentIndexNumber ?? 0) , c))
|
select new Tuple<int, Episode>((c.ParentIndexNumber ?? 0) , c))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
|
@ -275,13 +275,16 @@ namespace MediaBrowser.Providers.TV
|
||||||
return hasChanges;
|
return hasChanges;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Series DetermineAppropriateSeries(IEnumerable<Series> series, int seasonNumber)
|
private Series DetermineAppropriateSeries(List<Series> series, int seasonNumber)
|
||||||
{
|
{
|
||||||
var seriesAndOffsets = series.ToList();
|
if (series.Count == 1)
|
||||||
|
{
|
||||||
|
return series[0];
|
||||||
|
}
|
||||||
|
|
||||||
return seriesAndOffsets.FirstOrDefault(s => s.GetRecursiveChildren().OfType<Season>().Any(season => (season.IndexNumber) == seasonNumber)) ??
|
return series.FirstOrDefault(s => s.GetRecursiveChildren(i => i is Season).Any(season => (season.IndexNumber) == seasonNumber)) ??
|
||||||
seriesAndOffsets.FirstOrDefault(s => s.GetRecursiveChildren().OfType<Season>().Any(season => (season.IndexNumber) == 1)) ??
|
series.FirstOrDefault(s => s.GetRecursiveChildren(i => i is Season).Any(season => (season.IndexNumber) == 1)) ??
|
||||||
seriesAndOffsets.OrderBy(s => s.GetRecursiveChildren().OfType<Season>().Select(season => season.IndexNumber).Min()).First();
|
series.OrderBy(s => s.GetRecursiveChildren(i => i is Season).Select(season => season.IndexNumber).Min()).First();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -292,7 +295,7 @@ namespace MediaBrowser.Providers.TV
|
||||||
bool allowMissingEpisodes)
|
bool allowMissingEpisodes)
|
||||||
{
|
{
|
||||||
var existingEpisodes = (from s in series
|
var existingEpisodes = (from s in series
|
||||||
from c in s.GetRecursiveChildren().OfType<Episode>()
|
from c in s.GetRecursiveChildren(i => i is Episode).Cast<Episode>()
|
||||||
select new { Episode = c })
|
select new { Episode = c })
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
|
@ -402,7 +405,7 @@ namespace MediaBrowser.Providers.TV
|
||||||
|
|
||||||
// Season does not have a number
|
// Season does not have a number
|
||||||
// Remove if there are no episodes directly in series without a season number
|
// Remove if there are no episodes directly in series without a season number
|
||||||
return i.Series.GetRecursiveChildren().OfType<Episode>().All(s => s.ParentIndexNumber.HasValue || s.IsInSeasonFolder);
|
return i.Series.GetRecursiveChildren(e => e is Episode).Cast<Episode>().All(s => s.ParentIndexNumber.HasValue || s.IsInSeasonFolder);
|
||||||
})
|
})
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user