@ -27,6 +27,7 @@ using MediaBrowser.Server.Implementations.Library.Validators;
using MediaBrowser.Server.Implementations.Logging ;
using MediaBrowser.Server.Implementations.Logging ;
using MediaBrowser.Server.Implementations.ScheduledTasks ;
using MediaBrowser.Server.Implementations.ScheduledTasks ;
using System ;
using System ;
using System.Collections ;
using System.Collections.Concurrent ;
using System.Collections.Concurrent ;
using System.Collections.Generic ;
using System.Collections.Generic ;
using System.Globalization ;
using System.Globalization ;
@ -37,6 +38,7 @@ using System.Threading;
using System.Threading.Tasks ;
using System.Threading.Tasks ;
using CommonIO ;
using CommonIO ;
using MediaBrowser.Model.Extensions ;
using MediaBrowser.Model.Extensions ;
using MediaBrowser.Model.Library ;
using MediaBrowser.Model.Net ;
using MediaBrowser.Model.Net ;
using MoreLinq ;
using MoreLinq ;
using SortOrder = MediaBrowser . Model . Entities . SortOrder ;
using SortOrder = MediaBrowser . Model . Entities . SortOrder ;
@ -142,6 +144,7 @@ namespace MediaBrowser.Server.Implementations.Library
private readonly Func < ILibraryMonitor > _libraryMonitorFactory ;
private readonly Func < ILibraryMonitor > _libraryMonitorFactory ;
private readonly Func < IProviderManager > _providerManagerFactory ;
private readonly Func < IProviderManager > _providerManagerFactory ;
private readonly Func < IUserViewManager > _userviewManager ;
/// <summary>
/// <summary>
/// The _library items cache
/// The _library items cache
@ -169,7 +172,7 @@ namespace MediaBrowser.Server.Implementations.Library
/// <param name="userManager">The user manager.</param>
/// <param name="userManager">The user manager.</param>
/// <param name="configurationManager">The configuration manager.</param>
/// <param name="configurationManager">The configuration manager.</param>
/// <param name="userDataRepository">The user data repository.</param>
/// <param name="userDataRepository">The user data repository.</param>
public LibraryManager ( ILogger logger , ITaskManager taskManager , IUserManager userManager , IServerConfigurationManager configurationManager , IUserDataManager userDataRepository , Func < ILibraryMonitor > libraryMonitorFactory , IFileSystem fileSystem , Func < IProviderManager > providerManagerFactory )
public LibraryManager ( ILogger logger , ITaskManager taskManager , IUserManager userManager , IServerConfigurationManager configurationManager , IUserDataManager userDataRepository , Func < ILibraryMonitor > libraryMonitorFactory , IFileSystem fileSystem , Func < IProviderManager > providerManagerFactory , Func < IUserViewManager > userviewManager )
{
{
_logger = logger ;
_logger = logger ;
_taskManager = taskManager ;
_taskManager = taskManager ;
@ -179,6 +182,7 @@ namespace MediaBrowser.Server.Implementations.Library
_libraryMonitorFactory = libraryMonitorFactory ;
_libraryMonitorFactory = libraryMonitorFactory ;
_fileSystem = fileSystem ;
_fileSystem = fileSystem ;
_providerManagerFactory = providerManagerFactory ;
_providerManagerFactory = providerManagerFactory ;
_userviewManager = userviewManager ;
ByReferenceItems = new ConcurrentDictionary < Guid , BaseItem > ( ) ;
ByReferenceItems = new ConcurrentDictionary < Guid , BaseItem > ( ) ;
_libraryItemsCache = new ConcurrentDictionary < Guid , BaseItem > ( ) ;
_libraryItemsCache = new ConcurrentDictionary < Guid , BaseItem > ( ) ;
@ -403,12 +407,12 @@ namespace MediaBrowser.Server.Implementations.Library
{
{
foreach ( var path in item . GetDeletePaths ( ) . ToList ( ) )
foreach ( var path in item . GetDeletePaths ( ) . ToList ( ) )
{
{
if ( _fileSystem . DirectoryExists ( path ) )
if ( _fileSystem . DirectoryExists ( path ) )
{
{
_logger . Debug ( "Deleting path {0}" , path ) ;
_logger . Debug ( "Deleting path {0}" , path ) ;
_fileSystem . DeleteDirectory ( path , true ) ;
_fileSystem . DeleteDirectory ( path , true ) ;
}
}
else if ( _fileSystem . FileExists ( path ) )
else if ( _fileSystem . FileExists ( path ) )
{
{
_logger . Debug ( "Deleting path {0}" , path ) ;
_logger . Debug ( "Deleting path {0}" , path ) ;
_fileSystem . DeleteFile ( path ) ;
_fileSystem . DeleteFile ( path ) ;
@ -582,7 +586,7 @@ namespace MediaBrowser.Server.Implementations.Library
} ;
} ;
// Return null if ignore rules deem that we should do so
// Return null if ignore rules deem that we should do so
if ( EntityResolutionIgnoreRules. Any ( r = > r . ShouldIgnore ( args ) ) )
if ( IgnoreFile( args . FileInfo , args . Parent ) )
{
{
return null ;
return null ;
}
}
@ -618,6 +622,11 @@ namespace MediaBrowser.Server.Implementations.Library
return ResolveItem ( args ) ;
return ResolveItem ( args ) ;
}
}
public bool IgnoreFile ( FileSystemMetadata file , BaseItem parent )
{
return EntityResolutionIgnoreRules . Any ( r = > r . ShouldIgnore ( file , parent ) ) ;
}
public IEnumerable < FileSystemMetadata > NormalizeRootPathList ( IEnumerable < FileSystemMetadata > paths )
public IEnumerable < FileSystemMetadata > NormalizeRootPathList ( IEnumerable < FileSystemMetadata > paths )
{
{
var originalList = paths . ToList ( ) ;
var originalList = paths . ToList ( ) ;
@ -653,7 +662,7 @@ namespace MediaBrowser.Server.Implementations.Library
public IEnumerable < BaseItem > ResolvePaths ( IEnumerable < FileSystemMetadata > files , IDirectoryService directoryService , Folder parent , string collectionType )
public IEnumerable < BaseItem > ResolvePaths ( IEnumerable < FileSystemMetadata > files , IDirectoryService directoryService , Folder parent , string collectionType )
{
{
var fileList = files . ToList( ) ;
var fileList = files . Where( i = > ! IgnoreFile ( i , parent ) ) . ToList( ) ;
if ( parent ! = null )
if ( parent ! = null )
{
{
@ -704,7 +713,7 @@ namespace MediaBrowser.Server.Implementations.Library
{
{
var rootFolderPath = ConfigurationManager . ApplicationPaths . RootFolderPath ;
var rootFolderPath = ConfigurationManager . ApplicationPaths . RootFolderPath ;
_fileSystem . CreateDirectory ( rootFolderPath ) ;
_fileSystem . CreateDirectory ( rootFolderPath ) ;
var rootFolder = GetItemById ( GetNewItemId ( rootFolderPath , typeof ( AggregateFolder ) ) ) as AggregateFolder ? ? ( AggregateFolder ) ResolvePath ( _fileSystem . GetDirectoryInfo ( rootFolderPath ) ) ;
var rootFolder = GetItemById ( GetNewItemId ( rootFolderPath , typeof ( AggregateFolder ) ) ) as AggregateFolder ? ? ( AggregateFolder ) ResolvePath ( _fileSystem . GetDirectoryInfo ( rootFolderPath ) ) ;
@ -734,6 +743,13 @@ namespace MediaBrowser.Server.Implementations.Library
folder = dbItem ;
folder = dbItem ;
}
}
if ( folder . ParentId ! = rootFolder . Id )
{
folder . ParentId = rootFolder . Id ;
var task = folder . UpdateToRepository ( ItemUpdateType . MetadataImport , CancellationToken . None ) ;
Task . WaitAll ( task ) ;
}
rootFolder . AddVirtualChild ( folder ) ;
rootFolder . AddVirtualChild ( folder ) ;
RegisterItem ( folder ) ;
RegisterItem ( folder ) ;
@ -755,7 +771,7 @@ namespace MediaBrowser.Server.Implementations.Library
{
{
var userRootPath = ConfigurationManager . ApplicationPaths . DefaultUserViewsPath ;
var userRootPath = ConfigurationManager . ApplicationPaths . DefaultUserViewsPath ;
_fileSystem . CreateDirectory ( userRootPath ) ;
_fileSystem . CreateDirectory ( userRootPath ) ;
var tmpItem = GetItemById ( GetNewItemId ( userRootPath , typeof ( UserRootFolder ) ) ) as UserRootFolder ;
var tmpItem = GetItemById ( GetNewItemId ( userRootPath , typeof ( UserRootFolder ) ) ) as UserRootFolder ;
@ -1007,9 +1023,9 @@ namespace MediaBrowser.Server.Implementations.Library
private void SetPropertiesFromSongs ( MusicArtist artist , IEnumerable < IHasMetadata > items )
private void SetPropertiesFromSongs ( MusicArtist artist , IEnumerable < IHasMetadata > items )
{
{
}
}
/// <summary>
/// <summary>
/// Validate and refresh the People sub-set of the IBN.
/// Validate and refresh the People sub-set of the IBN.
/// The items are stored in the db but not loaded into memory until actually requested by an operation.
/// The items are stored in the db but not loaded into memory until actually requested by an operation.
@ -1020,7 +1036,7 @@ namespace MediaBrowser.Server.Implementations.Library
public Task ValidatePeople ( CancellationToken cancellationToken , IProgress < double > progress )
public Task ValidatePeople ( CancellationToken cancellationToken , IProgress < double > progress )
{
{
// Ensure the location is available.
// Ensure the location is available.
_fileSystem . CreateDirectory ( ConfigurationManager . ApplicationPaths . PeoplePath ) ;
_fileSystem . CreateDirectory ( ConfigurationManager . ApplicationPaths . PeoplePath ) ;
return new PeopleValidator ( this , _logger , ConfigurationManager , _fileSystem ) . ValidatePeople ( cancellationToken , progress ) ;
return new PeopleValidator ( this , _logger , ConfigurationManager , _fileSystem ) . ValidatePeople ( cancellationToken , progress ) ;
}
}
@ -1267,6 +1283,11 @@ namespace MediaBrowser.Server.Implementations.Library
public QueryResult < BaseItem > GetItems ( InternalItemsQuery query )
public QueryResult < BaseItem > GetItems ( InternalItemsQuery query )
{
{
if ( query . User ! = null )
{
AddUserToQuery ( query , query . User ) ;
}
var result = ItemRepository . GetItemIdsList ( query ) ;
var result = ItemRepository . GetItemIdsList ( query ) ;
var items = result . Select ( GetItemById ) . Where ( i = > i ! = null ) . ToArray ( ) ;
var items = result . Select ( GetItemById ) . Where ( i = > i ! = null ) . ToArray ( ) ;
@ -1279,14 +1300,140 @@ namespace MediaBrowser.Server.Implementations.Library
public QueryResult < BaseItem > QueryItems ( InternalItemsQuery query )
public QueryResult < BaseItem > QueryItems ( InternalItemsQuery query )
{
{
if ( query . User ! = null )
{
AddUserToQuery ( query , query . User ) ;
}
return ItemRepository . GetItems ( query ) ;
return ItemRepository . GetItems ( query ) ;
}
}
public List < Guid > GetItemIds ( InternalItemsQuery query )
public List < Guid > GetItemIds ( InternalItemsQuery query )
{
{
if ( query . User ! = null )
{
AddUserToQuery ( query , query . User ) ;
}
return ItemRepository . GetItemIdsList ( query ) ;
return ItemRepository . GetItemIdsList ( query ) ;
}
}
public IEnumerable < BaseItem > GetItems ( InternalItemsQuery query , IEnumerable < string > parentIds )
{
var parents = parentIds . Select ( i = > GetItemById ( new Guid ( i ) ) ) . Where ( i = > i ! = null ) . ToList ( ) ;
SetTopParentIdsOrAncestors ( query , parents ) ;
return GetItemIds ( query ) . Select ( GetItemById ) ;
}
public QueryResult < BaseItem > GetItemsResult ( InternalItemsQuery query , IEnumerable < string > parentIds )
{
var parents = parentIds . Select ( i = > GetItemById ( new Guid ( i ) ) ) . Where ( i = > i ! = null ) . ToList ( ) ;
SetTopParentIdsOrAncestors ( query , parents ) ;
return GetItems ( query ) ;
}
private void SetTopParentIdsOrAncestors ( InternalItemsQuery query , List < BaseItem > parents )
{
if ( parents . All ( i = >
{
if ( ( i is ICollectionFolder ) | | ( i is UserView ) )
{
return true ;
}
_logger . Debug ( "Query requires ancestor query due to type: " + i . GetType ( ) . Name ) ;
return false ;
} ) )
{
// Optimize by querying against top level views
query . TopParentIds = parents . SelectMany ( i = > GetTopParentsForQuery ( i , query . User ) ) . Select ( i = > i . Id . ToString ( "N" ) ) . ToArray ( ) ;
}
else
{
// We need to be able to query from any arbitrary ancestor up the tree
query . AncestorIds = parents . SelectMany ( i = > i . GetIdsForAncestorQuery ( ) ) . Select ( i = > i . ToString ( "N" ) ) . ToArray ( ) ;
}
}
private void AddUserToQuery ( InternalItemsQuery query , User user )
{
if ( query . AncestorIds . Length = = 0 & & ! query . ParentId . HasValue & & query . ChannelIds . Length = = 0 & & query . TopParentIds . Length = = 0 )
{
var userViews = _userviewManager ( ) . GetUserViews ( new UserViewQuery
{
UserId = user . Id . ToString ( "N" ) ,
IncludeHidden = true
} , CancellationToken . None ) . Result . ToList ( ) ;
query . TopParentIds = userViews . SelectMany ( i = > GetTopParentsForQuery ( i , user ) ) . Select ( i = > i . Id . ToString ( "N" ) ) . ToArray ( ) ;
}
}
private IEnumerable < BaseItem > GetTopParentsForQuery ( BaseItem item , User user )
{
var view = item as UserView ;
if ( view ! = null )
{
if ( string . Equals ( view . ViewType , CollectionType . LiveTv ) )
{
return new [ ] { view } ;
}
if ( string . Equals ( view . ViewType , CollectionType . Channels ) )
{
// TODO: Return channels
return new [ ] { view } ;
}
// Translate view into folders
if ( view . DisplayParentId ! = Guid . Empty )
{
var displayParent = GetItemById ( view . DisplayParentId ) ;
if ( displayParent ! = null )
{
return GetTopParentsForQuery ( displayParent , user ) ;
}
return new BaseItem [ ] { } ;
}
if ( view . ParentId ! = Guid . Empty )
{
var displayParent = GetItemById ( view . ParentId ) ;
if ( displayParent ! = null )
{
return GetTopParentsForQuery ( displayParent , user ) ;
}
return new BaseItem [ ] { } ;
}
// Handle grouping
if ( user ! = null & & ! string . IsNullOrWhiteSpace ( view . ViewType ) & & UserView . IsEligibleForGrouping ( view . ViewType ) )
{
var collectionFolders = user . RootFolder . GetChildren ( user , true ) . OfType < CollectionFolder > ( ) . Where ( i = > string . IsNullOrWhiteSpace ( i . CollectionType ) | | string . Equals ( i . CollectionType , view . ViewType , StringComparison . OrdinalIgnoreCase ) ) ;
return collectionFolders . SelectMany ( i = > GetTopParentsForQuery ( i , user ) ) ;
}
return new BaseItem [ ] { } ;
}
var collectionFolder = item as CollectionFolder ;
if ( collectionFolder ! = null )
{
return collectionFolder . GetPhysicalParents ( ) ;
}
var topParent = item . GetTopParent ( ) ;
if ( topParent ! = null )
{
return new [ ] { topParent } ;
}
return new BaseItem [ ] { } ;
}
/// <summary>
/// <summary>
/// Gets the intros.
/// Gets the intros.
/// </summary>
/// </summary>
@ -1579,9 +1726,9 @@ namespace MediaBrowser.Server.Implementations.Library
public IEnumerable < Folder > GetCollectionFolders ( BaseItem item )
public IEnumerable < Folder > GetCollectionFolders ( BaseItem item )
{
{
while ( ! ( item . Parent is AggregateFolder ) & & item . Parent ! = null )
while ( ! ( item . Get Parent( ) is AggregateFolder ) & & item . Get Parent( ) ! = null )
{
{
item = item . Parent;
item = item . Get Parent( ) ;
}
}
if ( item = = null )
if ( item = = null )
@ -1618,7 +1765,7 @@ namespace MediaBrowser.Server.Implementations.Library
return type ;
return type ;
}
}
return item . Parents
return item . Get Parents( )
. Select ( GetConfiguredContentType )
. Select ( GetConfiguredContentType )
. LastOrDefault ( i = > ! string . IsNullOrWhiteSpace ( i ) ) ;
. LastOrDefault ( i = > ! string . IsNullOrWhiteSpace ( i ) ) ;
}
}
@ -1655,14 +1802,14 @@ namespace MediaBrowser.Server.Implementations.Library
private string GetTopFolderContentType ( BaseItem item )
private string GetTopFolderContentType ( BaseItem item )
{
{
while ( ! ( item . Parent is AggregateFolder ) & & item . Parent ! = null )
if ( item = = null )
{
{
item = item . Parent ;
return null ;
}
}
if ( item = = null )
while ( ! ( item . GetParent ( ) is AggregateFolder ) & & item . GetParent ( ) ! = null )
{
{
return null ;
item = item . GetParent ( ) ;
}
}
return GetUserRootFolder ( ) . Children
return GetUserRootFolder ( ) . Children
@ -1681,7 +1828,7 @@ namespace MediaBrowser.Server.Implementations.Library
string sortName ,
string sortName ,
CancellationToken cancellationToken )
CancellationToken cancellationToken )
{
{
return GetNamedView Internal ( user , name , null , viewType , sortName , null , cancellationToken ) ;
return GetNamedView ( user , name , null , viewType , sortName , cancellationToken ) ;
}
}
public async Task < UserView > GetNamedView ( string name ,
public async Task < UserView > GetNamedView ( string name ,
@ -1699,10 +1846,9 @@ namespace MediaBrowser.Server.Implementations.Library
var refresh = false ;
var refresh = false ;
if ( item = = null | |
if ( item = = null | | ! string . Equals ( item . Path , path , StringComparison . OrdinalIgnoreCase ) )
! string . Equals ( item . Path , path , StringComparison . OrdinalIgnoreCase ) )
{
{
_fileSystem . CreateDirectory ( path ) ;
_fileSystem . CreateDirectory ( path ) ;
item = new UserView
item = new UserView
{
{
@ -1719,12 +1865,6 @@ namespace MediaBrowser.Server.Implementations.Library
refresh = true ;
refresh = true ;
}
}
if ( ! string . Equals ( viewType , item . ViewType , StringComparison . OrdinalIgnoreCase ) )
{
item . ViewType = viewType ;
await item . UpdateToRepository ( ItemUpdateType . MetadataEdit , cancellationToken ) . ConfigureAwait ( false ) ;
}
if ( ! refresh )
if ( ! refresh )
{
{
refresh = ( DateTime . UtcNow - item . DateLastRefreshed ) > = _viewRefreshInterval ;
refresh = ( DateTime . UtcNow - item . DateLastRefreshed ) > = _viewRefreshInterval ;
@ -1750,40 +1890,14 @@ namespace MediaBrowser.Server.Implementations.Library
return item ;
return item ;
}
}
public Task < UserView > GetNamedView ( User user ,
public async Task < UserView > GetNamedView ( User user ,
string name ,
string name ,
string parentId ,
string parentId ,
string viewType ,
string viewType ,
string sortName ,
string sortName ,
string uniqueId ,
CancellationToken cancellationToken )
CancellationToken cancellationToken )
{
{
if ( string . IsNullOrWhiteSpace ( parentId ) )
var idValues = "38_namedview_" + name + user . Id . ToString ( "N" ) + ( parentId ? ? string . Empty ) + ( viewType ? ? string . Empty ) ;
{
throw new ArgumentNullException ( "parentId" ) ;
}
return GetNamedViewInternal ( user , name , parentId , viewType , sortName , uniqueId , cancellationToken ) ;
}
private async Task < UserView > GetNamedViewInternal ( User user ,
string name ,
string parentId ,
string viewType ,
string sortName ,
string uniqueId ,
CancellationToken cancellationToken )
{
if ( string . IsNullOrWhiteSpace ( name ) )
{
throw new ArgumentNullException ( "name" ) ;
}
var idValues = "37_namedview_" + name + user . Id . ToString ( "N" ) + ( parentId ? ? string . Empty ) ;
if ( ! string . IsNullOrWhiteSpace ( uniqueId ) )
{
idValues + = uniqueId ;
}
var id = GetNewItemId ( idValues , typeof ( UserView ) ) ;
var id = GetNewItemId ( idValues , typeof ( UserView ) ) ;
@ -1795,7 +1909,7 @@ namespace MediaBrowser.Server.Implementations.Library
if ( item = = null )
if ( item = = null )
{
{
_fileSystem . CreateDirectory ( path ) ;
_fileSystem . CreateDirectory ( path ) ;
item = new UserView
item = new UserView
{
{
@ -1818,18 +1932,6 @@ namespace MediaBrowser.Server.Implementations.Library
isNew = true ;
isNew = true ;
}
}
if ( ! item . UserId . HasValue )
{
item . UserId = user . Id ;
await item . UpdateToRepository ( ItemUpdateType . MetadataEdit , cancellationToken ) . ConfigureAwait ( false ) ;
}
if ( ! string . Equals ( viewType , item . ViewType , StringComparison . OrdinalIgnoreCase ) )
{
item . ViewType = viewType ;
await item . UpdateToRepository ( ItemUpdateType . MetadataEdit , cancellationToken ) . ConfigureAwait ( false ) ;
}
var refresh = isNew | | ( DateTime . UtcNow - item . DateLastRefreshed ) > = _viewRefreshInterval ;
var refresh = isNew | | ( DateTime . UtcNow - item . DateLastRefreshed ) > = _viewRefreshInterval ;
if ( ! refresh & & item . DisplayParentId ! = Guid . Empty )
if ( ! refresh & & item . DisplayParentId ! = Guid . Empty )
@ -1853,7 +1955,6 @@ namespace MediaBrowser.Server.Implementations.Library
public async Task < UserView > GetShadowView ( BaseItem parent ,
public async Task < UserView > GetShadowView ( BaseItem parent ,
string viewType ,
string viewType ,
string sortName ,
string sortName ,
string uniqueId ,
CancellationToken cancellationToken )
CancellationToken cancellationToken )
{
{
if ( parent = = null )
if ( parent = = null )
@ -1864,11 +1965,7 @@ namespace MediaBrowser.Server.Implementations.Library
var name = parent . Name ;
var name = parent . Name ;
var parentId = parent . Id ;
var parentId = parent . Id ;
var idValues = "37_namedview_" + name + parentId + ( viewType ? ? string . Empty ) ;
var idValues = "38_namedview_" + name + parentId + ( viewType ? ? string . Empty ) ;
if ( ! string . IsNullOrWhiteSpace ( uniqueId ) )
{
idValues + = uniqueId ;
}
var id = GetNewItemId ( idValues , typeof ( UserView ) ) ;
var id = GetNewItemId ( idValues , typeof ( UserView ) ) ;
@ -1899,12 +1996,6 @@ namespace MediaBrowser.Server.Implementations.Library
isNew = true ;
isNew = true ;
}
}
if ( ! string . Equals ( viewType , item . ViewType , StringComparison . OrdinalIgnoreCase ) )
{
item . ViewType = viewType ;
await item . UpdateToRepository ( ItemUpdateType . MetadataEdit , cancellationToken ) . ConfigureAwait ( false ) ;
}
var refresh = isNew | | ( DateTime . UtcNow - item . DateLastRefreshed ) > = _viewRefreshInterval ;
var refresh = isNew | | ( DateTime . UtcNow - item . DateLastRefreshed ) > = _viewRefreshInterval ;
if ( ! refresh & & item . DisplayParentId ! = Guid . Empty )
if ( ! refresh & & item . DisplayParentId ! = Guid . Empty )
@ -1924,7 +2015,7 @@ namespace MediaBrowser.Server.Implementations.Library
return item ;
return item ;
}
}
public async Task < UserView > GetNamedView ( string name ,
public async Task < UserView > GetNamedView ( string name ,
string parentId ,
string parentId ,
string viewType ,
string viewType ,
@ -1953,7 +2044,7 @@ namespace MediaBrowser.Server.Implementations.Library
if ( item = = null )
if ( item = = null )
{
{
_fileSystem . CreateDirectory ( path ) ;
_fileSystem . CreateDirectory ( path ) ;
item = new UserView
item = new UserView
{
{
@ -2200,21 +2291,21 @@ namespace MediaBrowser.Server.Implementations.Library
return ResolvePaths ( files , directoryService , null , null )
return ResolvePaths ( files , directoryService , null , null )
. OfType < Video > ( )
. OfType < Video > ( )
. Select ( video = >
. Select ( video = >
{
// Try to retrieve it from the db. If we don't find it, use the resolved version
var dbItem = GetItemById ( video . Id ) as Video ;
if ( dbItem ! = null )
{
{
video = dbItem ;
// Try to retrieve it from the db. If we don't find it, use the resolved version
}
var dbItem = GetItemById ( video . Id ) as Video ;
video . ExtraType = ExtraType . Trailer ;
if ( dbItem ! = null )
{
video = dbItem ;
}
return video ;
video . ExtraType = ExtraType . Trailer ;
// Sort them so that the list can be easily compared for changes
return video ;
} ) . OrderBy ( i = > i . Path ) . ToList ( ) ;
// Sort them so that the list can be easily compared for changes
} ) . OrderBy ( i = > i . Path ) . ToList ( ) ;
}
}
public IEnumerable < Video > FindExtras ( BaseItem owner , List < FileSystemMetadata > fileSystemChildren , IDirectoryService directoryService )
public IEnumerable < Video > FindExtras ( BaseItem owner , List < FileSystemMetadata > fileSystemChildren , IDirectoryService directoryService )
@ -2386,7 +2477,7 @@ namespace MediaBrowser.Server.Implementations.Library
return ItemRepository . UpdatePeople ( item . Id , people ) ;
return ItemRepository . UpdatePeople ( item . Id , people ) ;
}
}
private readonly SemaphoreSlim _dynamicImageResourcePool = new SemaphoreSlim ( 1 , 1 ) ;
private readonly SemaphoreSlim _dynamicImageResourcePool = new SemaphoreSlim ( 1 , 1 ) ;
public async Task < ItemImageInfo > ConvertImageToLocal ( IHasImages item , ItemImageInfo image , int imageIndex )
public async Task < ItemImageInfo > ConvertImageToLocal ( IHasImages item , ItemImageInfo image , int imageIndex )
{
{
foreach ( var url in image . Path . Split ( '|' ) )
foreach ( var url in image . Path . Split ( '|' ) )
@ -2425,4 +2516,4 @@ namespace MediaBrowser.Server.Implementations.Library
throw new InvalidOperationException ( ) ;
throw new InvalidOperationException ( ) ;
}
}
}
}
}
}