mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
update search
This commit is contained in:
parent
4307c67b5e
commit
de133cb8aa
@ -485,6 +485,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
/// Gets or sets the parent.
|
/// Gets or sets the parent.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The parent.</value>
|
/// <value>The parent.</value>
|
||||||
|
[IgnoreDataMember]
|
||||||
public Folder Parent
|
public Folder Parent
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -30,6 +30,12 @@ namespace MediaBrowser.Controller.LiveTv
|
|||||||
return GetClientTypeName() + "-" + Name;
|
return GetClientTypeName() + "-" + Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the etag.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The etag.</value>
|
||||||
|
public string Etag { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Id of the program.
|
/// Id of the program.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -180,6 +180,11 @@ namespace MediaBrowser.Controller.LiveTv
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The episode number.</value>
|
/// <value>The episode number.</value>
|
||||||
public int? EpisodeNumber { get; set; }
|
public int? EpisodeNumber { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the etag.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The etag.</value>
|
||||||
|
public string Etag { get; set; }
|
||||||
|
|
||||||
public ProgramInfo()
|
public ProgramInfo()
|
||||||
{
|
{
|
||||||
|
@ -33,26 +33,17 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||||||
|
|
||||||
public async Task<QueryResult<SearchHintInfo>> GetSearchHints(SearchQuery query)
|
public async Task<QueryResult<SearchHintInfo>> GetSearchHints(SearchQuery query)
|
||||||
{
|
{
|
||||||
IEnumerable<BaseItem> inputItems;
|
|
||||||
|
|
||||||
Func<BaseItem, bool> filter = i => !(i is ICollectionFolder);
|
|
||||||
|
|
||||||
User user = null;
|
User user = null;
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(query.UserId))
|
if (string.IsNullOrWhiteSpace(query.UserId))
|
||||||
{
|
{
|
||||||
inputItems = _libraryManager.RootFolder.GetRecursiveChildren(filter);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
user = _userManager.GetUserById(query.UserId);
|
user = _userManager.GetUserById(query.UserId);
|
||||||
|
|
||||||
inputItems = user.RootFolder.GetRecursiveChildren(user, filter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inputItems = _libraryManager.ReplaceVideosWithPrimaryVersions(inputItems);
|
var results = await GetSearchHints(query, user).ConfigureAwait(false);
|
||||||
|
|
||||||
var results = await GetSearchHints(inputItems, query, user).ConfigureAwait(false);
|
|
||||||
|
|
||||||
var searchResultArray = results.ToArray();
|
var searchResultArray = results.ToArray();
|
||||||
results = searchResultArray;
|
results = searchResultArray;
|
||||||
@ -77,15 +68,22 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AddIfMissing(List<string> list, string value)
|
||||||
|
{
|
||||||
|
if (!list.Contains(value, StringComparer.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
list.Add(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the search hints.
|
/// Gets the search hints.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="inputItems">The input items.</param>
|
|
||||||
/// <param name="query">The query.</param>
|
/// <param name="query">The query.</param>
|
||||||
/// <param name="user">The user.</param>
|
/// <param name="user">The user.</param>
|
||||||
/// <returns>IEnumerable{SearchHintResult}.</returns>
|
/// <returns>IEnumerable{SearchHintResult}.</returns>
|
||||||
/// <exception cref="System.ArgumentNullException">searchTerm</exception>
|
/// <exception cref="System.ArgumentNullException">searchTerm</exception>
|
||||||
private Task<IEnumerable<SearchHintInfo>> GetSearchHints(IEnumerable<BaseItem> inputItems, SearchQuery query, User user)
|
private Task<IEnumerable<SearchHintInfo>> GetSearchHints(SearchQuery query, User user)
|
||||||
{
|
{
|
||||||
var searchTerm = query.SearchTerm;
|
var searchTerm = query.SearchTerm;
|
||||||
|
|
||||||
@ -100,207 +98,80 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||||||
|
|
||||||
var hints = new List<Tuple<BaseItem, string, int>>();
|
var hints = new List<Tuple<BaseItem, string, int>>();
|
||||||
|
|
||||||
var items = inputItems.Where(i => !(i is MusicArtist)).ToList();
|
var excludeItemTypes = new List<string>();
|
||||||
|
var includeItemTypes = (query.IncludeItemTypes ?? new string[] { }).ToList();
|
||||||
|
|
||||||
if (query.IncludeMedia)
|
excludeItemTypes.Add(typeof(Year).Name);
|
||||||
|
|
||||||
|
if (query.IncludeGenres && (includeItemTypes.Count == 0 || includeItemTypes.Contains("Genre", StringComparer.OrdinalIgnoreCase)))
|
||||||
{
|
{
|
||||||
var mediaItems = _libraryManager.GetItems(new InternalItemsQuery
|
if (!query.IncludeMedia)
|
||||||
{
|
{
|
||||||
NameContains = searchTerm,
|
AddIfMissing(includeItemTypes, typeof(Genre).Name);
|
||||||
ExcludeItemTypes = new[]
|
AddIfMissing(includeItemTypes, typeof(GameGenre).Name);
|
||||||
{
|
AddIfMissing(includeItemTypes, typeof(MusicGenre).Name);
|
||||||
typeof (Person).Name,
|
|
||||||
typeof (Genre).Name,
|
|
||||||
typeof (MusicArtist).Name,
|
|
||||||
typeof (GameGenre).Name,
|
|
||||||
typeof (MusicGenre).Name,
|
|
||||||
typeof (Year).Name,
|
|
||||||
typeof (Studio).Name
|
|
||||||
},
|
|
||||||
IncludeItemTypes = query.IncludeItemTypes
|
|
||||||
|
|
||||||
}).Items;
|
|
||||||
|
|
||||||
// Add search hints based on item name
|
|
||||||
hints.AddRange(mediaItems.Where(i => IncludeInSearch(i) && (user == null || i.IsVisibleStandalone(user)) && !(i is CollectionFolder)).Select(item =>
|
|
||||||
{
|
|
||||||
var index = GetIndex(item.Name, searchTerm, terms);
|
|
||||||
|
|
||||||
return new Tuple<BaseItem, string, int>(item, index.Item1, index.Item2);
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (query.IncludeArtists && (query.IncludeItemTypes.Length == 0 || query.IncludeItemTypes.Contains("MusicArtist", StringComparer.OrdinalIgnoreCase)))
|
|
||||||
{
|
|
||||||
// Find artists
|
|
||||||
var artists = items.OfType<Audio>()
|
|
||||||
.SelectMany(i => i.AllArtists)
|
|
||||||
.Where(i => !string.IsNullOrWhiteSpace(i))
|
|
||||||
.DistinctNames()
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
foreach (var item in artists)
|
|
||||||
{
|
|
||||||
var index = GetIndex(item, searchTerm, terms);
|
|
||||||
|
|
||||||
if (index.Item2 != -1)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var artist = _libraryManager.GetArtist(item);
|
|
||||||
|
|
||||||
hints.Add(new Tuple<BaseItem, string, int>(artist, index.Item1, index.Item2));
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.ErrorException("Error getting {0}", ex, item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (query.IncludeGenres && (query.IncludeItemTypes.Length == 0 || query.IncludeItemTypes.Contains("Genre", StringComparer.OrdinalIgnoreCase)))
|
|
||||||
{
|
{
|
||||||
// Find genres, from non-audio items
|
AddIfMissing(excludeItemTypes, typeof(Genre).Name);
|
||||||
var genres = items.Where(i => !(i is IHasMusicGenres) && !(i is Game))
|
AddIfMissing(excludeItemTypes, typeof(GameGenre).Name);
|
||||||
.SelectMany(i => i.Genres)
|
AddIfMissing(excludeItemTypes, typeof(MusicGenre).Name);
|
||||||
.Where(i => !string.IsNullOrWhiteSpace(i))
|
|
||||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
foreach (var item in genres)
|
|
||||||
{
|
|
||||||
var index = GetIndex(item, searchTerm, terms);
|
|
||||||
|
|
||||||
if (index.Item2 != -1)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var genre = _libraryManager.GetGenre(item);
|
|
||||||
|
|
||||||
hints.Add(new Tuple<BaseItem, string, int>(genre, index.Item1, index.Item2));
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.ErrorException("Error getting {0}", ex, item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find music genres
|
|
||||||
var musicGenres = items.Where(i => i is IHasMusicGenres)
|
|
||||||
.SelectMany(i => i.Genres)
|
|
||||||
.Where(i => !string.IsNullOrWhiteSpace(i))
|
|
||||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
foreach (var item in musicGenres)
|
|
||||||
{
|
|
||||||
var index = GetIndex(item, searchTerm, terms);
|
|
||||||
|
|
||||||
if (index.Item2 != -1)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var genre = _libraryManager.GetMusicGenre(item);
|
|
||||||
|
|
||||||
hints.Add(new Tuple<BaseItem, string, int>(genre, index.Item1, index.Item2));
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.ErrorException("Error getting {0}", ex, item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find music genres
|
|
||||||
var gameGenres = items.OfType<Game>()
|
|
||||||
.SelectMany(i => i.Genres)
|
|
||||||
.Where(i => !string.IsNullOrWhiteSpace(i))
|
|
||||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
foreach (var item in gameGenres)
|
|
||||||
{
|
|
||||||
var index = GetIndex(item, searchTerm, terms);
|
|
||||||
|
|
||||||
if (index.Item2 != -1)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var genre = _libraryManager.GetGameGenre(item);
|
|
||||||
|
|
||||||
hints.Add(new Tuple<BaseItem, string, int>(genre, index.Item1, index.Item2));
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.ErrorException("Error getting {0}", ex, item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (query.IncludeStudios && (query.IncludeItemTypes.Length == 0 || query.IncludeItemTypes.Contains("Studio", StringComparer.OrdinalIgnoreCase)))
|
if (query.IncludePeople && (includeItemTypes.Count == 0 || includeItemTypes.Contains("People", StringComparer.OrdinalIgnoreCase)))
|
||||||
{
|
{
|
||||||
// Find studios
|
if (!query.IncludeMedia)
|
||||||
var studios = items.SelectMany(i => i.Studios)
|
|
||||||
.Where(i => !string.IsNullOrWhiteSpace(i))
|
|
||||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
foreach (var item in studios)
|
|
||||||
{
|
{
|
||||||
var index = GetIndex(item, searchTerm, terms);
|
AddIfMissing(includeItemTypes, typeof(Person).Name);
|
||||||
|
|
||||||
if (index.Item2 != -1)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var studio = _libraryManager.GetStudio(item);
|
|
||||||
|
|
||||||
hints.Add(new Tuple<BaseItem, string, int>(studio, index.Item1, index.Item2));
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.ErrorException("Error getting {0}", ex, item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (query.IncludePeople && (query.IncludeItemTypes.Length == 0 || query.IncludeItemTypes.Contains("Person", StringComparer.OrdinalIgnoreCase)))
|
|
||||||
{
|
{
|
||||||
var itemIds = items.Select(i => i.Id).ToList();
|
AddIfMissing(excludeItemTypes, typeof(Person).Name);
|
||||||
|
}
|
||||||
|
|
||||||
// Find persons
|
if (query.IncludeStudios && (includeItemTypes.Count == 0 || includeItemTypes.Contains("Studio", StringComparer.OrdinalIgnoreCase)))
|
||||||
var persons = _libraryManager.GetPeople(new InternalPeopleQuery
|
{
|
||||||
|
if (!query.IncludeMedia)
|
||||||
{
|
{
|
||||||
NameContains = searchTerm
|
AddIfMissing(includeItemTypes, typeof(Studio).Name);
|
||||||
})
|
|
||||||
.Where(i => itemIds.Contains(i.ItemId))
|
|
||||||
.Select(i => i.Name)
|
|
||||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
foreach (var item in persons)
|
|
||||||
{
|
|
||||||
var index = GetIndex(item, searchTerm, terms);
|
|
||||||
|
|
||||||
if (index.Item2 != -1)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var person = _libraryManager.GetPerson(item);
|
|
||||||
|
|
||||||
hints.Add(new Tuple<BaseItem, string, int>(person, index.Item1, index.Item2));
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.ErrorException("Error getting {0}", ex, item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddIfMissing(excludeItemTypes, typeof(Studio).Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (query.IncludeArtists && (includeItemTypes.Count == 0 || includeItemTypes.Contains("MusicArtist", StringComparer.OrdinalIgnoreCase)))
|
||||||
|
{
|
||||||
|
if (!query.IncludeMedia)
|
||||||
|
{
|
||||||
|
AddIfMissing(includeItemTypes, typeof(MusicArtist).Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddIfMissing(excludeItemTypes, typeof(MusicArtist).Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
var mediaItems = _libraryManager.GetItems(new InternalItemsQuery
|
||||||
|
{
|
||||||
|
NameContains = searchTerm,
|
||||||
|
ExcludeItemTypes = excludeItemTypes.ToArray(),
|
||||||
|
IncludeItemTypes = includeItemTypes.ToArray(),
|
||||||
|
MaxParentalRating = user == null ? null : user.Policy.MaxParentalRating,
|
||||||
|
Limit = query.Limit.HasValue ? query.Limit * 3 : null
|
||||||
|
|
||||||
|
}).Items;
|
||||||
|
|
||||||
|
// Add search hints based on item name
|
||||||
|
hints.AddRange(mediaItems.Where(i => IncludeInSearch(i) && IsVisible(i, user) && !(i is CollectionFolder)).Select(item =>
|
||||||
|
{
|
||||||
|
var index = GetIndex(item.Name, searchTerm, terms);
|
||||||
|
|
||||||
|
return new Tuple<BaseItem, string, int>(item, index.Item1, index.Item2);
|
||||||
|
}));
|
||||||
|
|
||||||
var returnValue = hints.Where(i => i.Item3 >= 0).OrderBy(i => i.Item3).Select(i => new SearchHintInfo
|
var returnValue = hints.Where(i => i.Item3 >= 0).OrderBy(i => i.Item3).Select(i => new SearchHintInfo
|
||||||
{
|
{
|
||||||
@ -311,13 +182,32 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||||||
return Task.FromResult(returnValue);
|
return Task.FromResult(returnValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool IsVisible(BaseItem item, User user)
|
||||||
|
{
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item is IItemByName)
|
||||||
|
{
|
||||||
|
var dual = item as IHasDualAccess;
|
||||||
|
if (dual == null || dual.IsAccessedByName)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return item.IsVisibleStandalone(user);
|
||||||
|
}
|
||||||
|
|
||||||
private bool IncludeInSearch(BaseItem item)
|
private bool IncludeInSearch(BaseItem item)
|
||||||
{
|
{
|
||||||
var episode = item as Episode;
|
var episode = item as Episode;
|
||||||
|
|
||||||
if (episode != null)
|
if (episode != null)
|
||||||
{
|
{
|
||||||
if (episode.IsVirtualUnaired || episode.IsMissingEpisode)
|
if (episode.IsMissingEpisode)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using MediaBrowser.Controller.Entities;
|
using System.Collections.Generic;
|
||||||
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
using System;
|
using System;
|
||||||
@ -42,12 +43,16 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
|||||||
var numComplete = 0;
|
var numComplete = 0;
|
||||||
var count = items.Count;
|
var count = items.Count;
|
||||||
|
|
||||||
|
var validIds = new List<Guid>();
|
||||||
|
|
||||||
foreach (var name in items)
|
foreach (var name in items)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var itemByName = _libraryManager.GetGameGenre(name);
|
var itemByName = _libraryManager.GetGameGenre(name);
|
||||||
|
|
||||||
|
validIds.Add(itemByName.Id);
|
||||||
|
|
||||||
await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
|
await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException)
|
catch (OperationCanceledException)
|
||||||
@ -68,6 +73,26 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
|||||||
progress.Report(percent);
|
progress.Report(percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var allIds = _libraryManager.GetItemIds(new InternalItemsQuery
|
||||||
|
{
|
||||||
|
IncludeItemTypes = new[] { typeof(GameGenre).Name }
|
||||||
|
});
|
||||||
|
|
||||||
|
var invalidIds = allIds
|
||||||
|
.Except(validIds)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
foreach (var id in invalidIds)
|
||||||
|
{
|
||||||
|
var item = _libraryManager.GetItemById(id);
|
||||||
|
|
||||||
|
await _libraryManager.DeleteItem(item, new DeleteOptions
|
||||||
|
{
|
||||||
|
DeleteFileLocation = false
|
||||||
|
|
||||||
|
}).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
progress.Report(100);
|
progress.Report(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using MediaBrowser.Controller.Entities;
|
using System.Collections.Generic;
|
||||||
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Entities.Audio;
|
using MediaBrowser.Controller.Entities.Audio;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
@ -43,12 +44,16 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
|||||||
var numComplete = 0;
|
var numComplete = 0;
|
||||||
var count = items.Count;
|
var count = items.Count;
|
||||||
|
|
||||||
|
var validIds = new List<Guid>();
|
||||||
|
|
||||||
foreach (var name in items)
|
foreach (var name in items)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var itemByName = _libraryManager.GetGenre(name);
|
var itemByName = _libraryManager.GetGenre(name);
|
||||||
|
|
||||||
|
validIds.Add(itemByName.Id);
|
||||||
|
|
||||||
await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
|
await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException)
|
catch (OperationCanceledException)
|
||||||
@ -69,6 +74,26 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
|||||||
progress.Report(percent);
|
progress.Report(percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var allIds = _libraryManager.GetItemIds(new InternalItemsQuery
|
||||||
|
{
|
||||||
|
IncludeItemTypes = new[] { typeof(Genre).Name }
|
||||||
|
});
|
||||||
|
|
||||||
|
var invalidIds = allIds
|
||||||
|
.Except(validIds)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
foreach (var id in invalidIds)
|
||||||
|
{
|
||||||
|
var item = _libraryManager.GetItemById(id);
|
||||||
|
|
||||||
|
await _libraryManager.DeleteItem(item, new DeleteOptions
|
||||||
|
{
|
||||||
|
DeleteFileLocation = false
|
||||||
|
|
||||||
|
}).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
progress.Report(100);
|
progress.Report(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
using MediaBrowser.Controller.Entities.Audio;
|
using System.Collections.Generic;
|
||||||
|
using MediaBrowser.Controller.Entities;
|
||||||
|
using MediaBrowser.Controller.Entities.Audio;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
using System;
|
using System;
|
||||||
@ -42,12 +44,16 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
|||||||
var numComplete = 0;
|
var numComplete = 0;
|
||||||
var count = items.Count;
|
var count = items.Count;
|
||||||
|
|
||||||
|
var validIds = new List<Guid>();
|
||||||
|
|
||||||
foreach (var name in items)
|
foreach (var name in items)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var itemByName = _libraryManager.GetMusicGenre(name);
|
var itemByName = _libraryManager.GetMusicGenre(name);
|
||||||
|
|
||||||
|
validIds.Add(itemByName.Id);
|
||||||
|
|
||||||
await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
|
await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException)
|
catch (OperationCanceledException)
|
||||||
@ -68,6 +74,26 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
|||||||
progress.Report(percent);
|
progress.Report(percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var allIds = _libraryManager.GetItemIds(new InternalItemsQuery
|
||||||
|
{
|
||||||
|
IncludeItemTypes = new[] { typeof(MusicGenre).Name }
|
||||||
|
});
|
||||||
|
|
||||||
|
var invalidIds = allIds
|
||||||
|
.Except(validIds)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
foreach (var id in invalidIds)
|
||||||
|
{
|
||||||
|
var item = _libraryManager.GetItemById(id);
|
||||||
|
|
||||||
|
await _libraryManager.DeleteItem(item, new DeleteOptions
|
||||||
|
{
|
||||||
|
DeleteFileLocation = false
|
||||||
|
|
||||||
|
}).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
progress.Report(100);
|
progress.Report(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Entities;
|
||||||
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -41,12 +43,16 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
|||||||
var numComplete = 0;
|
var numComplete = 0;
|
||||||
var count = items.Count;
|
var count = items.Count;
|
||||||
|
|
||||||
|
var validIds = new List<Guid>();
|
||||||
|
|
||||||
foreach (var name in items)
|
foreach (var name in items)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var itemByName = _libraryManager.GetStudio(name);
|
var itemByName = _libraryManager.GetStudio(name);
|
||||||
|
|
||||||
|
validIds.Add(itemByName.Id);
|
||||||
|
|
||||||
await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
|
await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException)
|
catch (OperationCanceledException)
|
||||||
@ -67,6 +73,26 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
|||||||
progress.Report(percent);
|
progress.Report(percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var allIds = _libraryManager.GetItemIds(new InternalItemsQuery
|
||||||
|
{
|
||||||
|
IncludeItemTypes = new[] { typeof(Studio).Name }
|
||||||
|
});
|
||||||
|
|
||||||
|
var invalidIds = allIds
|
||||||
|
.Except(validIds)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
foreach (var id in invalidIds)
|
||||||
|
{
|
||||||
|
var item = _libraryManager.GetItemById(id);
|
||||||
|
|
||||||
|
await _libraryManager.DeleteItem(item, new DeleteOptions
|
||||||
|
{
|
||||||
|
DeleteFileLocation = false
|
||||||
|
|
||||||
|
}).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
progress.Report(100);
|
progress.Report(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -627,31 +627,17 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
|||||||
|
|
||||||
private async Task UpdateTimersForSeriesTimer(List<ProgramInfo> epgData, SeriesTimerInfo seriesTimer)
|
private async Task UpdateTimersForSeriesTimer(List<ProgramInfo> epgData, SeriesTimerInfo seriesTimer)
|
||||||
{
|
{
|
||||||
var newTimers = GetTimersForSeries(seriesTimer, epgData, _recordingProvider.GetAll()).ToList();
|
|
||||||
|
|
||||||
var existingTimers = _timerProvider.GetAll()
|
|
||||||
.Where(i => string.Equals(i.SeriesTimerId, seriesTimer.Id, StringComparison.OrdinalIgnoreCase))
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
var registration = await GetRegistrationInfo("seriesrecordings").ConfigureAwait(false);
|
var registration = await GetRegistrationInfo("seriesrecordings").ConfigureAwait(false);
|
||||||
|
|
||||||
if (registration.IsValid)
|
if (registration.IsValid)
|
||||||
{
|
{
|
||||||
|
var newTimers = GetTimersForSeries(seriesTimer, epgData, _recordingProvider.GetAll()).ToList();
|
||||||
|
|
||||||
foreach (var timer in newTimers)
|
foreach (var timer in newTimers)
|
||||||
{
|
{
|
||||||
_timerProvider.AddOrUpdate(timer);
|
_timerProvider.AddOrUpdate(timer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var newTimerIds = newTimers.Select(i => i.Id).ToList();
|
|
||||||
|
|
||||||
foreach (var timer in existingTimers)
|
|
||||||
{
|
|
||||||
if (!newTimerIds.Contains(timer.Id, StringComparer.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
CancelTimerInternal(timer.Id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<TimerInfo> GetTimersForSeries(SeriesTimerInfo seriesTimer, IEnumerable<ProgramInfo> allPrograms, IReadOnlyList<RecordingInfo> currentRecordings)
|
private IEnumerable<TimerInfo> GetTimersForSeries(SeriesTimerInfo seriesTimer, IEnumerable<ProgramInfo> allPrograms, IReadOnlyList<RecordingInfo> currentRecordings)
|
||||||
|
@ -304,7 +304,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
|
|||||||
IsKids = string.Equals(details.audience, "children", StringComparison.OrdinalIgnoreCase),
|
IsKids = string.Equals(details.audience, "children", StringComparison.OrdinalIgnoreCase),
|
||||||
IsSports = showType.IndexOf("sports", StringComparison.OrdinalIgnoreCase) != -1,
|
IsSports = showType.IndexOf("sports", StringComparison.OrdinalIgnoreCase) != -1,
|
||||||
IsMovie = showType.IndexOf("movie", StringComparison.OrdinalIgnoreCase) != -1 || showType.IndexOf("film", StringComparison.OrdinalIgnoreCase) != -1,
|
IsMovie = showType.IndexOf("movie", StringComparison.OrdinalIgnoreCase) != -1 || showType.IndexOf("film", StringComparison.OrdinalIgnoreCase) != -1,
|
||||||
ShowId = programInfo.programID
|
ShowId = programInfo.programID,
|
||||||
|
Etag = programInfo.md5
|
||||||
};
|
};
|
||||||
|
|
||||||
if (programInfo.videoProperties != null)
|
if (programInfo.videoProperties != null)
|
||||||
@ -408,7 +409,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
|
|||||||
;
|
;
|
||||||
});
|
});
|
||||||
imageIdString = imageIdString.TrimEnd(',') + "]";
|
imageIdString = imageIdString.TrimEnd(',') + "]";
|
||||||
_logger.Debug("Json for show images = " + imageIdString);
|
|
||||||
var httpOptions = new HttpRequestOptions()
|
var httpOptions = new HttpRequestOptions()
|
||||||
{
|
{
|
||||||
Url = ApiUrl + "/metadata/programs",
|
Url = ApiUrl + "/metadata/programs",
|
||||||
|
@ -593,7 +593,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
|||||||
Name = info.Name,
|
Name = info.Name,
|
||||||
Id = id,
|
Id = id,
|
||||||
DateCreated = DateTime.UtcNow,
|
DateCreated = DateTime.UtcNow,
|
||||||
DateModified = DateTime.UtcNow
|
DateModified = DateTime.UtcNow,
|
||||||
|
Etag = info.Etag
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -639,7 +640,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await _libraryManager.UpdateItem(item, ItemUpdateType.MetadataImport, cancellationToken).ConfigureAwait(false);
|
if (string.IsNullOrWhiteSpace(info.Etag) || !string.Equals(info.Etag, item.Etag, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
item.Etag = info.Etag;
|
||||||
|
await _libraryManager.UpdateItem(item, ItemUpdateType.MetadataImport, cancellationToken).ConfigureAwait(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_providerManager.QueueRefresh(item.Id, new MetadataRefreshOptions());
|
_providerManager.QueueRefresh(item.Id, new MetadataRefreshOptions());
|
||||||
|
@ -61,7 +61,7 @@ namespace MediaBrowser.WebDashboard.Api
|
|||||||
// jQuery ajax doesn't seem to handle if-modified-since correctly
|
// jQuery ajax doesn't seem to handle if-modified-since correctly
|
||||||
if (IsFormat(path, "html"))
|
if (IsFormat(path, "html"))
|
||||||
{
|
{
|
||||||
if (IsCoreHtml(path))
|
if (IsCoreHtml(path) && path.IndexOf(".template.html", StringComparison.OrdinalIgnoreCase) == -1)
|
||||||
{
|
{
|
||||||
resourceStream = await ModifyHtml(resourceStream, mode, appVersion, localizationCulture, enableMinification).ConfigureAwait(false);
|
resourceStream = await ModifyHtml(resourceStream, mode, appVersion, localizationCulture, enableMinification).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
@ -186,9 +186,6 @@
|
|||||||
<Content Include="dashboard-ui\css\nowplayingbar.css">
|
<Content Include="dashboard-ui\css\nowplayingbar.css">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="dashboard-ui\livetvguideprovider-scd.html">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</Content>
|
|
||||||
<Content Include="dashboard-ui\livetvguideprovider.html">
|
<Content Include="dashboard-ui\livetvguideprovider.html">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
@ -222,9 +219,6 @@
|
|||||||
<Content Include="dashboard-ui\scripts\homeupcoming.js">
|
<Content Include="dashboard-ui\scripts\homeupcoming.js">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="dashboard-ui\scripts\livetvguideprovider-scd.js">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</Content>
|
|
||||||
<Content Include="dashboard-ui\scripts\livetvguideprovider.js">
|
<Content Include="dashboard-ui\scripts\livetvguideprovider.js">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
@ -264,6 +258,9 @@
|
|||||||
<Content Include="dashboard-ui\scripts\slideshow.js">
|
<Content Include="dashboard-ui\scripts\slideshow.js">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="dashboard-ui\scripts\wizardlivetvguide.js">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="dashboard-ui\scripts\wizardlivetvtuner.js">
|
<Content Include="dashboard-ui\scripts\wizardlivetvtuner.js">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
@ -377,6 +374,12 @@
|
|||||||
<Content Include="dashboard-ui\thirdparty\viblast\worker.html">
|
<Content Include="dashboard-ui\thirdparty\viblast\worker.html">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="dashboard-ui\tvproviders\schedulesdirect.js">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="dashboard-ui\tvproviders\schedulesdirect.template.html">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="dashboard-ui\voice\voice.css">
|
<Content Include="dashboard-ui\voice\voice.css">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
@ -1786,6 +1789,9 @@
|
|||||||
<Content Include="dashboard-ui\wizardagreement.html">
|
<Content Include="dashboard-ui\wizardagreement.html">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="dashboard-ui\wizardlivetvguide.html">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="dashboard-ui\wizardlivetvtuner.html">
|
<Content Include="dashboard-ui\wizardlivetvtuner.html">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user