add new streambuilder options

This commit is contained in:
Luke Pulverenti
2016-07-09 13:39:04 -04:00
parent afaf7f7c5b
commit 959c6a397c
7 changed files with 190 additions and 57 deletions

View File

@@ -33,6 +33,7 @@ using System.Net;
using System.Threading;
using System.Threading.Tasks;
using CommonIO;
using MediaBrowser.Controller.Channels;
using MediaBrowser.Model.Channels;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Extensions;
@@ -353,10 +354,6 @@ namespace MediaBrowser.Server.Implementations.Library
private void RegisterItem(Guid id, BaseItem item)
{
if (item.SourceType != SourceType.Library)
{
return;
}
if (item is IItemByName)
{
if (!(item is MusicArtist))
@@ -364,14 +361,26 @@ namespace MediaBrowser.Server.Implementations.Library
return;
}
}
if (item is Photo)
{
return;
}
if (!(item is Folder))
if (item.IsFolder)
{
if (!(item is ICollectionFolder) && !(item is UserView) && !(item is Channel))
{
if (item.SourceType != SourceType.Library)
{
return;
}
}
}
else
{
return;
if (item is Photo)
{
return;
}
}
LibraryItemsCache.AddOrUpdate(id, item, delegate { return item; });
}
@@ -782,19 +791,19 @@ namespace MediaBrowser.Server.Implementations.Library
public BaseItem FindByPath(string path, bool? isFolder)
{
var query = new InternalItemsQuery
{
Path = path,
IsFolder = isFolder
};
// 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
return GetItemIds(query)
.Select(GetItemById)
.Where(i => i != null)
.OrderByDescending(i => i.DateCreated)
var query = new InternalItemsQuery
{
Path = path,
IsFolder = isFolder,
SortBy = new[] { ItemSortBy.DateCreated },
SortOrder = SortOrder.Descending,
Limit = 1
};
return GetItemList(query)
.FirstOrDefault();
}
@@ -1258,6 +1267,8 @@ namespace MediaBrowser.Server.Implementations.Library
item = RetrieveItem(id);
//_logger.Debug("GetitemById {0}", id);
if (item != null)
{
RegisterItem(item);
@@ -1508,7 +1519,7 @@ namespace MediaBrowser.Server.Implementations.Library
UserId = user.Id.ToString("N")
}, CancellationToken.None).Result;
return channelResult.Items;
}

View File

@@ -30,22 +30,24 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
return null;
}
var season = parent as Season;
// Just in case the user decided to nest episodes.
// Not officially supported but in some cases we can handle it.
if (season == null)
{
season = parent.GetParents().OfType<Season>().FirstOrDefault();
}
// If the parent is a Season or Series, then this is an Episode if the VideoResolver returns something
// Also handle flat tv folders
if (string.Equals(args.GetCollectionType(), CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
if (season != null ||
string.Equals(args.GetCollectionType(), CollectionType.TvShows, StringComparison.OrdinalIgnoreCase) ||
args.HasParent<Series>())
{
var episode = ResolveVideo<Episode>(args, false);
if (episode != null)
{
var season = parent as Season;
// Just in case the user decided to nest episodes.
// Not officially supported but in some cases we can handle it.
if (season == null)
{
season = parent.GetParents().OfType<Season>().FirstOrDefault();
}
var series = parent as Series;
if (series == null)
{

View File

@@ -38,10 +38,12 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
if (args.Parent is Series && args.IsDirectory)
{
var namingOptions = ((LibraryManager)_libraryManager).GetNamingOptions();
var series = ((Series)args.Parent);
var season = new Season
{
IndexNumber = new SeasonPathParser(namingOptions, new RegexProvider()).Parse(args.Path, true, true).SeasonNumber
IndexNumber = new SeasonPathParser(namingOptions, new RegexProvider()).Parse(args.Path, true, true).SeasonNumber,
SeriesId = series.Id
};
if (season.IndexNumber.HasValue && season.IndexNumber.Value == 0)