Merge branch 'dev' into beta

This commit is contained in:
Luke Pulverenti 2016-05-23 00:51:57 -04:00
commit 6a2fef8b26
62 changed files with 251 additions and 870 deletions

View File

@ -143,7 +143,8 @@ namespace MediaBrowser.Api.Movies
} }
var parentIds = string.IsNullOrWhiteSpace(request.ParentId) ? new string[] { } : new[] { request.ParentId }; var parentIds = string.IsNullOrWhiteSpace(request.ParentId) ? new string[] { } : new[] { request.ParentId };
var movies = _libraryManager.GetItemList(query, parentIds); var movies = _libraryManager.GetItemList(query, parentIds)
.OrderBy(i => (int)i.SourceType);
var listEligibleForCategories = new List<BaseItem>(); var listEligibleForCategories = new List<BaseItem>();
var listEligibleForSuggestion = new List<BaseItem>(); var listEligibleForSuggestion = new List<BaseItem>();
@ -194,8 +195,8 @@ namespace MediaBrowser.Api.Movies
query.IncludeItemTypes = includeList.ToArray(); query.IncludeItemTypes = includeList.ToArray();
} }
var parentIds = new string[] { }; var list = _libraryManager.GetItemList(query)
var list = _libraryManager.GetItemList(query, parentIds) .OrderBy(i => (int)i.SourceType)
.DistinctBy(i => i.GetProviderId(MetadataProviders.Imdb) ?? Guid.NewGuid().ToString("N")) .DistinctBy(i => i.GetProviderId(MetadataProviders.Imdb) ?? Guid.NewGuid().ToString("N"))
.ToList(); .ToList();

View File

@ -96,7 +96,7 @@ namespace MediaBrowser.Api.Playback
public long? InputFileSize { get; set; } public long? InputFileSize { get; set; }
public string OutputAudioSync = "1"; public string OutputAudioSync = "1";
public string OutputVideoSync = "vfr"; public string OutputVideoSync = "-1";
public List<string> SupportedAudioCodecs { get; set; } public List<string> SupportedAudioCodecs { get; set; }

View File

@ -109,11 +109,10 @@ namespace MediaBrowser.Api
private void SetWizardFinishValues(ServerConfiguration config) private void SetWizardFinishValues(ServerConfiguration config)
{ {
config.EnableLocalizedGuids = true;
config.EnableCustomPathSubFolders = true; config.EnableCustomPathSubFolders = true;
config.EnableDateLastRefresh = true;
config.EnableStandaloneMusicKeys = true; config.EnableStandaloneMusicKeys = true;
config.EnableCaseSensitiveItemIds = true; config.EnableCaseSensitiveItemIds = true;
config.SchemaVersion = 79;
} }
public void Post(UpdateStartupConfiguration request) public void Post(UpdateStartupConfiguration request)

View File

@ -552,7 +552,7 @@ namespace MediaBrowser.Common.Implementations
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Error("Error creating {0}", ex, type.Name); Logger.ErrorException("Error creating {0}", ex, type.Name);
throw; throw;
} }
@ -571,7 +571,7 @@ namespace MediaBrowser.Common.Implementations
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Error("Error creating {0}", ex, type.Name); Logger.ErrorException("Error creating {0}", ex, type.Name);
// Don't blow up in release mode // Don't blow up in release mode
return null; return null;
} }

View File

@ -62,13 +62,6 @@ namespace MediaBrowser.Controller.Entities.Audio
query.ArtistNames = new[] { Name }; query.ArtistNames = new[] { Name };
} }
// Need this for now since the artist filter isn't yet supported by the db
if (ConfigurationManager.Configuration.SchemaVersion < 79)
{
var filter = GetItemFilter();
return LibraryManager.GetItemList(query).Where(filter);
}
return LibraryManager.GetItemList(query); return LibraryManager.GetItemList(query);
} }

View File

@ -773,53 +773,8 @@ namespace MediaBrowser.Controller.Entities
} }
} }
var supportsUserDataQueries = ConfigurationManager.Configuration.SchemaVersion >= 76;
if (query.SortBy != null && query.SortBy.Length > 0) if (query.SortBy != null && query.SortBy.Length > 0)
{ {
if (!supportsUserDataQueries)
{
if (query.SortBy.Contains(ItemSortBy.DatePlayed, StringComparer.OrdinalIgnoreCase))
{
Logger.Debug("Query requires post-filtering due to ItemSortBy.IsFavoriteOrLiked");
return true;
}
if (query.SortBy.Contains(ItemSortBy.PlayCount, StringComparer.OrdinalIgnoreCase))
{
Logger.Debug("Query requires post-filtering due to ItemSortBy.PlayCount");
return true;
}
if (query.SortBy.Contains(ItemSortBy.IsFavoriteOrLiked, StringComparer.OrdinalIgnoreCase))
{
Logger.Debug("Query requires post-filtering due to ItemSortBy.IsFavoriteOrLiked");
return true;
}
if (query.SortBy.Contains(ItemSortBy.IsPlayed, StringComparer.OrdinalIgnoreCase))
{
Logger.Debug("Query requires post-filtering due to ItemSortBy.IsPlayed");
return true;
}
if (query.SortBy.Contains(ItemSortBy.IsUnplayed, StringComparer.OrdinalIgnoreCase))
{
Logger.Debug("Query requires post-filtering due to ItemSortBy.IsUnplayed");
return true;
}
}
if (ConfigurationManager.Configuration.SchemaVersion < 79)
{
if (query.SortBy.Contains(ItemSortBy.AlbumArtist, StringComparer.OrdinalIgnoreCase))
{
Logger.Debug("Query requires post-filtering due to ItemSortBy.AlbumArtist");
return true;
}
if (query.SortBy.Contains(ItemSortBy.Artist, StringComparer.OrdinalIgnoreCase))
{
Logger.Debug("Query requires post-filtering due to ItemSortBy.Artist");
return true;
}
}
if (query.SortBy.Contains(ItemSortBy.AiredEpisodeOrder, StringComparer.OrdinalIgnoreCase)) if (query.SortBy.Contains(ItemSortBy.AiredEpisodeOrder, StringComparer.OrdinalIgnoreCase))
{ {
Logger.Debug("Query requires post-filtering due to ItemSortBy.AiredEpisodeOrder"); Logger.Debug("Query requires post-filtering due to ItemSortBy.AiredEpisodeOrder");
@ -884,39 +839,6 @@ namespace MediaBrowser.Controller.Entities
return true; return true;
} }
if (!supportsUserDataQueries)
{
if (query.IsLiked.HasValue)
{
Logger.Debug("Query requires post-filtering due to IsLiked");
return true;
}
if (query.IsFavoriteOrLiked.HasValue)
{
Logger.Debug("Query requires post-filtering due to IsFavoriteOrLiked");
return true;
}
if (query.IsFavorite.HasValue)
{
Logger.Debug("Query requires post-filtering due to IsFavorite");
return true;
}
if (query.IsResumable.HasValue)
{
Logger.Debug("Query requires post-filtering due to IsResumable");
return true;
}
if (query.IsPlayed.HasValue)
{
Logger.Debug("Query requires post-filtering due to IsPlayed");
return true;
}
}
if (query.IsInBoxSet.HasValue) if (query.IsInBoxSet.HasValue)
{ {
Logger.Debug("Query requires post-filtering due to IsInBoxSet"); Logger.Debug("Query requires post-filtering due to IsInBoxSet");
@ -1102,15 +1024,6 @@ namespace MediaBrowser.Controller.Entities
return true; return true;
} }
if (ConfigurationManager.Configuration.SchemaVersion < 79)
{
if (query.ArtistNames.Length > 0)
{
Logger.Debug("Query requires post-filtering due to ArtistNames");
return true;
}
}
return false; return false;
} }

View File

@ -297,7 +297,6 @@
<Compile Include="Providers\ImageRefreshMode.cs" /> <Compile Include="Providers\ImageRefreshMode.cs" />
<Compile Include="Providers\ImageRefreshOptions.cs" /> <Compile Include="Providers\ImageRefreshOptions.cs" />
<Compile Include="Providers\IPreRefreshProvider.cs" /> <Compile Include="Providers\IPreRefreshProvider.cs" />
<Compile Include="Providers\IProviderRepository.cs" />
<Compile Include="Providers\IRemoteImageProvider.cs" /> <Compile Include="Providers\IRemoteImageProvider.cs" />
<Compile Include="Providers\ILocalImageProvider.cs" /> <Compile Include="Providers\ILocalImageProvider.cs" />
<Compile Include="Providers\IMetadataProvider.cs" /> <Compile Include="Providers\IMetadataProvider.cs" />
@ -334,7 +333,6 @@
<Compile Include="Providers\ItemIdentities.cs" /> <Compile Include="Providers\ItemIdentities.cs" />
<Compile Include="Providers\ItemLookupInfo.cs" /> <Compile Include="Providers\ItemLookupInfo.cs" />
<Compile Include="Providers\MetadataRefreshOptions.cs" /> <Compile Include="Providers\MetadataRefreshOptions.cs" />
<Compile Include="Providers\MetadataStatus.cs" />
<Compile Include="Providers\ISeriesOrderManager.cs" /> <Compile Include="Providers\ISeriesOrderManager.cs" />
<Compile Include="Session\ISessionManager.cs" /> <Compile Include="Session\ISessionManager.cs" />
<Compile Include="Entities\AggregateFolder.cs" /> <Compile Include="Entities\AggregateFolder.cs" />

View File

@ -1,25 +0,0 @@
using MediaBrowser.Controller.Persistence;
using System;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Controller.Providers
{
public interface IProviderRepository : IRepository
{
/// <summary>
/// Gets the metadata status.
/// </summary>
/// <param name="itemId">The item identifier.</param>
/// <returns>MetadataStatus.</returns>
MetadataStatus GetMetadataStatus(Guid itemId);
/// <summary>
/// Saves the metadata status.
/// </summary>
/// <param name="status">The status.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
Task SaveMetadataStatus(MetadataStatus status, CancellationToken cancellationToken);
}
}

View File

@ -1,49 +0,0 @@
using System;
namespace MediaBrowser.Controller.Providers
{
public class MetadataStatus
{
/// <summary>
/// Gets or sets the item identifier.
/// </summary>
/// <value>The item identifier.</value>
public Guid ItemId { get; set; }
/// <summary>
/// Gets or sets the date last metadata refresh.
/// </summary>
/// <value>The date last metadata refresh.</value>
public DateTime? DateLastMetadataRefresh { get; set; }
/// <summary>
/// Gets or sets the date last images refresh.
/// </summary>
/// <value>The date last images refresh.</value>
public DateTime? DateLastImagesRefresh { get; set; }
public DateTime? ItemDateModified { get; set; }
public bool IsDirty { get; private set; }
public void SetDateLastMetadataRefresh(DateTime? date)
{
if (date != DateLastMetadataRefresh)
{
IsDirty = true;
}
DateLastMetadataRefresh = date;
}
public void SetDateLastImagesRefresh(DateTime? date)
{
if (date != DateLastImagesRefresh)
{
IsDirty = true;
}
DateLastImagesRefresh = date;
}
}
}

View File

@ -57,6 +57,10 @@ namespace MediaBrowser.Model.ApiClient
{ {
existing.RemoteAddress = server.RemoteAddress; existing.RemoteAddress = server.RemoteAddress;
} }
if (!string.IsNullOrEmpty(server.ConnectServerId))
{
existing.ConnectServerId = server.ConnectServerId;
}
if (!string.IsNullOrEmpty(server.LocalAddress)) if (!string.IsNullOrEmpty(server.LocalAddress))
{ {
existing.LocalAddress = server.LocalAddress; existing.LocalAddress = server.LocalAddress;

View File

@ -12,6 +12,7 @@ namespace MediaBrowser.Model.ApiClient
public String Name { get; set; } public String Name { get; set; }
public String Id { get; set; } public String Id { get; set; }
public String ConnectServerId { get; set; }
public String LocalAddress { get; set; } public String LocalAddress { get; set; }
public String RemoteAddress { get; set; } public String RemoteAddress { get; set; }
public String ManualAddress { get; set; } public String ManualAddress { get; set; }

View File

@ -86,12 +86,6 @@ namespace MediaBrowser.Model.Configuration
/// <value><c>true</c> if [save local meta]; otherwise, <c>false</c>.</value> /// <value><c>true</c> if [save local meta]; otherwise, <c>false</c>.</value>
public bool SaveLocalMeta { get; set; } public bool SaveLocalMeta { get; set; }
/// <summary>
/// Gets or sets a value indicating whether [enable localized guids].
/// </summary>
/// <value><c>true</c> if [enable localized guids]; otherwise, <c>false</c>.</value>
public bool EnableLocalizedGuids { get; set; }
/// <summary> /// <summary>
/// Gets or sets the preferred metadata language. /// Gets or sets the preferred metadata language.
/// </summary> /// </summary>
@ -196,8 +190,6 @@ namespace MediaBrowser.Model.Configuration
public int SharingExpirationDays { get; set; } public int SharingExpirationDays { get; set; }
public bool EnableDateLastRefresh { get; set; }
public string[] Migrations { get; set; } public string[] Migrations { get; set; }
public int MigrationVersion { get; set; } public int MigrationVersion { get; set; }
@ -215,7 +207,6 @@ namespace MediaBrowser.Model.Configuration
{ {
Migrations = new string[] { }; Migrations = new string[] { };
EnableLocalizedGuids = true;
EnableCustomPathSubFolders = true; EnableCustomPathSubFolders = true;
ImageSavingConvention = ImageSavingConvention.Compatible; ImageSavingConvention = ImageSavingConvention.Compatible;
@ -232,7 +223,6 @@ namespace MediaBrowser.Model.Configuration
DenyIFrameEmbedding = true; DenyIFrameEmbedding = true;
EnableUPnP = true; EnableUPnP = true;
SharingExpirationDays = 30; SharingExpirationDays = 30;
MinResumePct = 5; MinResumePct = 5;
MaxResumePct = 90; MaxResumePct = 90;

View File

@ -34,7 +34,6 @@ namespace MediaBrowser.Model.Configuration
public SubtitlePlaybackMode SubtitleMode { get; set; } public SubtitlePlaybackMode SubtitleMode { get; set; }
public bool DisplayCollectionsView { get; set; } public bool DisplayCollectionsView { get; set; }
public bool DisplayFoldersView { get; set; }
public bool EnableLocalPassword { get; set; } public bool EnableLocalPassword { get; set; }

View File

@ -335,7 +335,8 @@ namespace MediaBrowser.Model.Dlna
Name = stream.Language ?? "Unknown", Name = stream.Language ?? "Unknown",
Format = subtitleProfile.Format, Format = subtitleProfile.Format,
Index = stream.Index, Index = stream.Index,
DeliveryMethod = subtitleProfile.Method DeliveryMethod = subtitleProfile.Method,
DisplayTitle = stream.DisplayTitle
}; };
if (info.DeliveryMethod == SubtitleDeliveryMethod.External) if (info.DeliveryMethod == SubtitleDeliveryMethod.External)

View File

@ -7,6 +7,7 @@ namespace MediaBrowser.Model.Dlna
public string Name { get; set; } public string Name { get; set; }
public bool IsForced { get; set; } public bool IsForced { get; set; }
public string Format { get; set; } public string Format { get; set; }
public string DisplayTitle { get; set; }
public int Index { get; set; } public int Index { get; set; }
public SubtitleDeliveryMethod DeliveryMethod { get; set; } public SubtitleDeliveryMethod DeliveryMethod { get; set; }
public bool IsExternalUrl { get; set; } public bool IsExternalUrl { get; set; }

View File

@ -89,7 +89,7 @@ namespace MediaBrowser.Model.Entities
if (!string.IsNullOrEmpty(Language)) if (!string.IsNullOrEmpty(Language))
{ {
attributes.Add(Language); attributes.Add(StringHelper.FirstToUpper(Language));
} }
if (!string.IsNullOrEmpty(Codec)) if (!string.IsNullOrEmpty(Codec))
{ {

View File

@ -12,10 +12,6 @@ namespace MediaBrowser.Providers.Books
{ {
public class BookMetadataService : MetadataService<Book, BookInfo> public class BookMetadataService : MetadataService<Book, BookInfo>
{ {
public BookMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager)
{
}
protected override void MergeData(MetadataResult<Book> source, MetadataResult<Book> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings) protected override void MergeData(MetadataResult<Book> source, MetadataResult<Book> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings)
{ {
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings); ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
@ -25,5 +21,9 @@ namespace MediaBrowser.Providers.Books
target.Item.SeriesName = source.Item.SeriesName; target.Item.SeriesName = source.Item.SeriesName;
} }
} }
public BookMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
{
}
} }
} }

View File

@ -15,10 +15,6 @@ namespace MediaBrowser.Providers.BoxSets
{ {
public class BoxSetMetadataService : MetadataService<BoxSet, BoxSetInfo> public class BoxSetMetadataService : MetadataService<BoxSet, BoxSetInfo>
{ {
public BoxSetMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager)
{
}
protected override async Task<ItemUpdateType> BeforeSave(BoxSet item, bool isFullRefresh, ItemUpdateType currentUpdateType) protected override async Task<ItemUpdateType> BeforeSave(BoxSet item, bool isFullRefresh, ItemUpdateType currentUpdateType)
{ {
var updateType = await base.BeforeSave(item, isFullRefresh, currentUpdateType).ConfigureAwait(false); var updateType = await base.BeforeSave(item, isFullRefresh, currentUpdateType).ConfigureAwait(false);
@ -54,5 +50,9 @@ namespace MediaBrowser.Providers.BoxSets
targetItem.Shares = sourceItem.Shares; targetItem.Shares = sourceItem.Shares;
} }
} }
public BoxSetMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
{
}
} }
} }

View File

@ -12,13 +12,13 @@ namespace MediaBrowser.Providers.Channels
{ {
public class ChannelMetadataService : MetadataService<Channel, ItemLookupInfo> public class ChannelMetadataService : MetadataService<Channel, ItemLookupInfo>
{ {
public ChannelMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager)
{
}
protected override void MergeData(MetadataResult<Channel> source, MetadataResult<Channel> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings) protected override void MergeData(MetadataResult<Channel> source, MetadataResult<Channel> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings)
{ {
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings); ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
} }
public ChannelMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
{
}
} }
} }

View File

@ -16,14 +16,13 @@ namespace MediaBrowser.Providers.Folders
{ {
public class CollectionFolderMetadataService : MetadataService<CollectionFolder, ItemLookupInfo> public class CollectionFolderMetadataService : MetadataService<CollectionFolder, ItemLookupInfo>
{ {
public CollectionFolderMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager)
: base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager)
{
}
protected override void MergeData(MetadataResult<CollectionFolder> source, MetadataResult<CollectionFolder> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings) protected override void MergeData(MetadataResult<CollectionFolder> source, MetadataResult<CollectionFolder> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings)
{ {
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings); ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
} }
public CollectionFolderMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
{
}
} }
} }

View File

@ -12,10 +12,6 @@ namespace MediaBrowser.Providers.Folders
{ {
public class FolderMetadataService : MetadataService<Folder, ItemLookupInfo> public class FolderMetadataService : MetadataService<Folder, ItemLookupInfo>
{ {
public FolderMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager)
{
}
public override int Order public override int Order
{ {
get get
@ -29,5 +25,9 @@ namespace MediaBrowser.Providers.Folders
{ {
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings); ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
} }
public FolderMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
{
}
} }
} }

View File

@ -12,13 +12,13 @@ namespace MediaBrowser.Providers.Folders
{ {
public class UserViewMetadataService : MetadataService<UserView, ItemLookupInfo> public class UserViewMetadataService : MetadataService<UserView, ItemLookupInfo>
{ {
public UserViewMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager)
{
}
protected override void MergeData(MetadataResult<UserView> source, MetadataResult<UserView> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings) protected override void MergeData(MetadataResult<UserView> source, MetadataResult<UserView> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings)
{ {
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings); ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
} }
public UserViewMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
{
}
} }
} }

View File

@ -12,13 +12,13 @@ namespace MediaBrowser.Providers.GameGenres
{ {
public class GameGenreMetadataService : MetadataService<GameGenre, ItemLookupInfo> public class GameGenreMetadataService : MetadataService<GameGenre, ItemLookupInfo>
{ {
public GameGenreMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager)
{
}
protected override void MergeData(MetadataResult<GameGenre> source, MetadataResult<GameGenre> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings) protected override void MergeData(MetadataResult<GameGenre> source, MetadataResult<GameGenre> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings)
{ {
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings); ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
} }
public GameGenreMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
{
}
} }
} }

View File

@ -12,10 +12,6 @@ namespace MediaBrowser.Providers.Games
{ {
public class GameMetadataService : MetadataService<Game, GameInfo> public class GameMetadataService : MetadataService<Game, GameInfo>
{ {
public GameMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager)
{
}
protected override void MergeData(MetadataResult<Game> source, MetadataResult<Game> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings) protected override void MergeData(MetadataResult<Game> source, MetadataResult<Game> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings)
{ {
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings); ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
@ -33,5 +29,9 @@ namespace MediaBrowser.Providers.Games
targetItem.PlayersSupported = sourceItem.PlayersSupported; targetItem.PlayersSupported = sourceItem.PlayersSupported;
} }
} }
public GameMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
{
}
} }
} }

View File

@ -12,10 +12,6 @@ namespace MediaBrowser.Providers.Games
{ {
public class GameSystemMetadataService : MetadataService<GameSystem, GameSystemInfo> public class GameSystemMetadataService : MetadataService<GameSystem, GameSystemInfo>
{ {
public GameSystemMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager)
{
}
protected override void MergeData(MetadataResult<GameSystem> source, MetadataResult<GameSystem> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings) protected override void MergeData(MetadataResult<GameSystem> source, MetadataResult<GameSystem> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings)
{ {
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings); ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
@ -28,5 +24,9 @@ namespace MediaBrowser.Providers.Games
targetItem.GameSystemName = sourceItem.GameSystemName; targetItem.GameSystemName = sourceItem.GameSystemName;
} }
} }
public GameSystemMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
{
}
} }
} }

View File

@ -12,13 +12,13 @@ namespace MediaBrowser.Providers.Genres
{ {
public class GenreMetadataService : MetadataService<Genre, ItemLookupInfo> public class GenreMetadataService : MetadataService<Genre, ItemLookupInfo>
{ {
public GenreMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager)
{
}
protected override void MergeData(MetadataResult<Genre> source, MetadataResult<Genre> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings) protected override void MergeData(MetadataResult<Genre> source, MetadataResult<Genre> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings)
{ {
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings); ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
} }
public GenreMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
{
}
} }
} }

View File

@ -12,13 +12,13 @@ namespace MediaBrowser.Providers.LiveTv
{ {
public class AudioRecordingService : MetadataService<LiveTvAudioRecording, ItemLookupInfo> public class AudioRecordingService : MetadataService<LiveTvAudioRecording, ItemLookupInfo>
{ {
public AudioRecordingService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager)
{
}
protected override void MergeData(MetadataResult<LiveTvAudioRecording> source, MetadataResult<LiveTvAudioRecording> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings) protected override void MergeData(MetadataResult<LiveTvAudioRecording> source, MetadataResult<LiveTvAudioRecording> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings)
{ {
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings); ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
} }
public AudioRecordingService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
{
}
} }
} }

View File

@ -12,13 +12,13 @@ namespace MediaBrowser.Providers.LiveTv
{ {
public class ChannelMetadataService : MetadataService<LiveTvChannel, ItemLookupInfo> public class ChannelMetadataService : MetadataService<LiveTvChannel, ItemLookupInfo>
{ {
public ChannelMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager)
{
}
protected override void MergeData(MetadataResult<LiveTvChannel> source, MetadataResult<LiveTvChannel> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings) protected override void MergeData(MetadataResult<LiveTvChannel> source, MetadataResult<LiveTvChannel> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings)
{ {
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings); ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
} }
public ChannelMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
{
}
} }
} }

View File

@ -12,13 +12,13 @@ namespace MediaBrowser.Providers.LiveTv
{ {
public class ProgramMetadataService : MetadataService<LiveTvProgram, LiveTvProgramLookupInfo> public class ProgramMetadataService : MetadataService<LiveTvProgram, LiveTvProgramLookupInfo>
{ {
public ProgramMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager)
{
}
protected override void MergeData(MetadataResult<LiveTvProgram> source, MetadataResult<LiveTvProgram> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings) protected override void MergeData(MetadataResult<LiveTvProgram> source, MetadataResult<LiveTvProgram> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings)
{ {
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings); ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
} }
public ProgramMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
{
}
} }
} }

View File

@ -12,13 +12,13 @@ namespace MediaBrowser.Providers.LiveTv
{ {
public class VideoRecordingService : MetadataService<LiveTvVideoRecording, ItemLookupInfo> public class VideoRecordingService : MetadataService<LiveTvVideoRecording, ItemLookupInfo>
{ {
public VideoRecordingService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager)
{
}
protected override void MergeData(MetadataResult<LiveTvVideoRecording> source, MetadataResult<LiveTvVideoRecording> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings) protected override void MergeData(MetadataResult<LiveTvVideoRecording> source, MetadataResult<LiveTvVideoRecording> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings)
{ {
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings); ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
} }
public VideoRecordingService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
{
}
} }
} }

View File

@ -1,5 +1,4 @@
using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
@ -12,11 +11,6 @@ using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using CommonIO; using CommonIO;
using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Controller.Playlists;
using MediaBrowser.Model.Providers; using MediaBrowser.Model.Providers;
namespace MediaBrowser.Providers.Manager namespace MediaBrowser.Providers.Manager
@ -28,95 +22,26 @@ namespace MediaBrowser.Providers.Manager
protected readonly IServerConfigurationManager ServerConfigurationManager; protected readonly IServerConfigurationManager ServerConfigurationManager;
protected readonly ILogger Logger; protected readonly ILogger Logger;
protected readonly IProviderManager ProviderManager; protected readonly IProviderManager ProviderManager;
protected readonly IProviderRepository ProviderRepo;
protected readonly IFileSystem FileSystem; protected readonly IFileSystem FileSystem;
protected readonly IUserDataManager UserDataManager; protected readonly IUserDataManager UserDataManager;
protected readonly ILibraryManager LibraryManager; protected readonly ILibraryManager LibraryManager;
protected MetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) protected MetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager)
{ {
ServerConfigurationManager = serverConfigurationManager; ServerConfigurationManager = serverConfigurationManager;
Logger = logger; Logger = logger;
ProviderManager = providerManager; ProviderManager = providerManager;
ProviderRepo = providerRepo;
FileSystem = fileSystem; FileSystem = fileSystem;
UserDataManager = userDataManager; UserDataManager = userDataManager;
LibraryManager = libraryManager; LibraryManager = libraryManager;
} }
/// <summary>
/// Saves the provider result.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="result">The result.</param>
/// <param name="directoryService">The directory service.</param>
/// <returns>Task.</returns>
protected Task SaveProviderResult(TItemType item, MetadataStatus result, IDirectoryService directoryService)
{
result.ItemId = item.Id;
//var locationType = item.LocationType;
//if (locationType == LocationType.FileSystem || locationType == LocationType.Offline)
//{
// if (!string.IsNullOrWhiteSpace(item.Path))
// {
// var file = directoryService.GetFile(item.Path);
// if ((file.Attributes & FileAttributes.Directory) != FileAttributes.Directory && file.Exists)
// {
// result.ItemDateModified = FileSystem.GetLastWriteTimeUtc(file);
// }
// }
//}
result.ItemDateModified = item.DateModified;
if (EnableDateLastRefreshed(item))
{
return Task.FromResult(true);
}
return ProviderRepo.SaveMetadataStatus(result, CancellationToken.None);
}
/// <summary>
/// Gets the last result.
/// </summary>
/// <param name="item">The item.</param>
/// <returns>ProviderResult.</returns>
protected MetadataStatus GetLastResult(IHasMetadata item)
{
if (GetLastRefreshDate(item) == default(DateTime))
{
return new MetadataStatus { ItemId = item.Id };
}
if (EnableDateLastRefreshed(item) && item.DateModifiedDuringLastRefresh.HasValue)
{
return new MetadataStatus
{
ItemId = item.Id,
DateLastImagesRefresh = item.DateLastRefreshed,
DateLastMetadataRefresh = item.DateLastRefreshed,
ItemDateModified = item.DateModifiedDuringLastRefresh.Value
};
}
var result = ProviderRepo.GetMetadataStatus(item.Id) ?? new MetadataStatus { ItemId = item.Id };
item.DateModifiedDuringLastRefresh = result.ItemDateModified;
return result;
}
public async Task<ItemUpdateType> RefreshMetadata(IHasMetadata item, MetadataRefreshOptions refreshOptions, CancellationToken cancellationToken) public async Task<ItemUpdateType> RefreshMetadata(IHasMetadata item, MetadataRefreshOptions refreshOptions, CancellationToken cancellationToken)
{ {
var itemOfType = (TItemType)item; var itemOfType = (TItemType)item;
var config = ProviderManager.GetMetadataOptions(item); var config = ProviderManager.GetMetadataOptions(item);
var updateType = ItemUpdateType.None; var updateType = ItemUpdateType.None;
var refreshResult = GetLastResult(item);
var itemImageProvider = new ItemImageProvider(Logger, ProviderManager, ServerConfigurationManager, FileSystem); var itemImageProvider = new ItemImageProvider(Logger, ProviderManager, ServerConfigurationManager, FileSystem);
var localImagesFailed = false; var localImagesFailed = false;
@ -153,12 +78,10 @@ namespace MediaBrowser.Providers.Manager
// TODO: If this returns true, should we instead just change metadata refresh mode to Full? // TODO: If this returns true, should we instead just change metadata refresh mode to Full?
requiresRefresh = item.RequiresRefresh(); requiresRefresh = item.RequiresRefresh();
var providers = GetProviders(item, refreshResult, refreshOptions, requiresRefresh) var providers = GetProviders(item, refreshOptions, requiresRefresh)
.ToList(); .ToList();
var dateLastRefresh = EnableDateLastRefreshed(item) var dateLastRefresh = item.DateLastRefreshed;
? item.DateLastRefreshed
: refreshResult.DateLastMetadataRefresh ?? default(DateTime);
if (providers.Count > 0 || dateLastRefresh == default(DateTime)) if (providers.Count > 0 || dateLastRefresh == default(DateTime))
{ {
@ -185,13 +108,11 @@ namespace MediaBrowser.Providers.Manager
updateType = updateType | result.UpdateType; updateType = updateType | result.UpdateType;
if (result.Failures == 0) if (result.Failures == 0)
{ {
refreshResult.SetDateLastMetadataRefresh(DateTime.UtcNow);
hasRefreshedMetadata = true; hasRefreshedMetadata = true;
} }
else else
{ {
hasRefreshedMetadata = false; hasRefreshedMetadata = false;
refreshResult.SetDateLastMetadataRefresh(null);
} }
} }
} }
@ -199,7 +120,7 @@ namespace MediaBrowser.Providers.Manager
// Next run remote image providers, but only if local image providers didn't throw an exception // Next run remote image providers, but only if local image providers didn't throw an exception
if (!localImagesFailed && refreshOptions.ImageRefreshMode != ImageRefreshMode.ValidationOnly) if (!localImagesFailed && refreshOptions.ImageRefreshMode != ImageRefreshMode.ValidationOnly)
{ {
var providers = GetNonLocalImageProviders(item, allImageProviders, refreshResult, refreshOptions).ToList(); var providers = GetNonLocalImageProviders(item, allImageProviders, refreshOptions).ToList();
if (providers.Count > 0) if (providers.Count > 0)
{ {
@ -208,13 +129,11 @@ namespace MediaBrowser.Providers.Manager
updateType = updateType | result.UpdateType; updateType = updateType | result.UpdateType;
if (result.Failures == 0) if (result.Failures == 0)
{ {
refreshResult.SetDateLastImagesRefresh(DateTime.UtcNow);
hasRefreshedImages = true; hasRefreshedImages = true;
} }
else else
{ {
hasRefreshedImages = false; hasRefreshedImages = false;
refreshResult.SetDateLastImagesRefresh(null);
} }
} }
} }
@ -248,11 +167,6 @@ namespace MediaBrowser.Providers.Manager
await SaveItem(metadataResult, updateType, cancellationToken).ConfigureAwait(false); await SaveItem(metadataResult, updateType, cancellationToken).ConfigureAwait(false);
} }
if (updateType > ItemUpdateType.None || refreshResult.IsDirty)
{
await SaveProviderResult(itemOfType, refreshResult, refreshOptions.DirectoryService).ConfigureAwait(false);
}
await AfterMetadataRefresh(itemOfType, refreshOptions, cancellationToken).ConfigureAwait(false); await AfterMetadataRefresh(itemOfType, refreshOptions, cancellationToken).ConfigureAwait(false);
return updateType; return updateType;
@ -278,50 +192,10 @@ namespace MediaBrowser.Providers.Manager
} }
private DateTime GetLastRefreshDate(IHasMetadata item) private DateTime GetLastRefreshDate(IHasMetadata item)
{
if (EnableDateLastRefreshed(item))
{ {
return item.DateLastRefreshed; return item.DateLastRefreshed;
} }
return item.DateLastSaved;
}
private bool EnableDateLastRefreshed(IHasMetadata item)
{
if (ServerConfigurationManager.Configuration.EnableDateLastRefresh)
{
return true;
}
if (item.DateLastRefreshed != default(DateTime))
{
return true;
}
if (!(item is Audio) && !(item is Video))
{
return true;
}
if (item is IItemByName)
{
return true;
}
if (item.SourceType != SourceType.Library)
{
return true;
}
if (item is MusicVideo)
{
return true;
}
return false;
}
protected async Task SaveItem(MetadataResult<TItemType> result, ItemUpdateType reason, CancellationToken cancellationToken) protected async Task SaveItem(MetadataResult<TItemType> result, ItemUpdateType reason, CancellationToken cancellationToken)
{ {
if (result.Item.SupportsPeople && result.People != null) if (result.Item.SupportsPeople && result.People != null)
@ -466,14 +340,12 @@ namespace MediaBrowser.Providers.Manager
/// Gets the providers. /// Gets the providers.
/// </summary> /// </summary>
/// <returns>IEnumerable{`0}.</returns> /// <returns>IEnumerable{`0}.</returns>
protected IEnumerable<IMetadataProvider> GetProviders(IHasMetadata item, MetadataStatus status, MetadataRefreshOptions options, bool requiresRefresh) protected IEnumerable<IMetadataProvider> GetProviders(IHasMetadata item, MetadataRefreshOptions options, bool requiresRefresh)
{ {
// Get providers to refresh // Get providers to refresh
var providers = ((ProviderManager)ProviderManager).GetMetadataProviders<TItemType>(item).ToList(); var providers = ((ProviderManager)ProviderManager).GetMetadataProviders<TItemType>(item).ToList();
var dateLastRefresh = EnableDateLastRefreshed(item) var dateLastRefresh = item.DateLastRefreshed;
? item.DateLastRefreshed
: status.DateLastMetadataRefresh ?? default(DateTime);
// Run all if either of these flags are true // Run all if either of these flags are true
var runAllProviders = options.ReplaceAllMetadata || options.MetadataRefreshMode == MetadataRefreshMode.FullRefresh || dateLastRefresh == default(DateTime) || requiresRefresh; var runAllProviders = options.ReplaceAllMetadata || options.MetadataRefreshMode == MetadataRefreshMode.FullRefresh || dateLastRefresh == default(DateTime) || requiresRefresh;
@ -535,14 +407,12 @@ namespace MediaBrowser.Providers.Manager
return providers; return providers;
} }
protected virtual IEnumerable<IImageProvider> GetNonLocalImageProviders(IHasMetadata item, IEnumerable<IImageProvider> allImageProviders, MetadataStatus status, ImageRefreshOptions options) protected virtual IEnumerable<IImageProvider> GetNonLocalImageProviders(IHasMetadata item, IEnumerable<IImageProvider> allImageProviders, ImageRefreshOptions options)
{ {
// Get providers to refresh // Get providers to refresh
var providers = allImageProviders.Where(i => !(i is ILocalImageProvider)).ToList(); var providers = allImageProviders.Where(i => !(i is ILocalImageProvider)).ToList();
var dateLastImageRefresh = EnableDateLastRefreshed(item) var dateLastImageRefresh = item.DateLastRefreshed;
? item.DateLastRefreshed
: status.DateLastImagesRefresh ?? default(DateTime);
// Run all if either of these flags are true // Run all if either of these flags are true
var runAllProviders = options.ImageRefreshMode == ImageRefreshMode.FullRefresh || dateLastImageRefresh == default(DateTime); var runAllProviders = options.ImageRefreshMode == ImageRefreshMode.FullRefresh || dateLastImageRefresh == default(DateTime);

View File

@ -13,10 +13,6 @@ namespace MediaBrowser.Providers.Movies
{ {
public class MovieMetadataService : MetadataService<Movie, MovieInfo> public class MovieMetadataService : MetadataService<Movie, MovieInfo>
{ {
public MovieMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager)
{
}
protected override bool IsFullLocalMetadata(Movie item) protected override bool IsFullLocalMetadata(Movie item)
{ {
if (string.IsNullOrWhiteSpace(item.Overview)) if (string.IsNullOrWhiteSpace(item.Overview))
@ -42,15 +38,14 @@ namespace MediaBrowser.Providers.Movies
targetItem.CollectionName = sourceItem.CollectionName; targetItem.CollectionName = sourceItem.CollectionName;
} }
} }
public MovieMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
{
}
} }
public class TrailerMetadataService : MetadataService<Trailer, TrailerInfo> public class TrailerMetadataService : MetadataService<Trailer, TrailerInfo>
{ {
public TrailerMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager)
: base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager)
{
}
protected override bool IsFullLocalMetadata(Trailer item) protected override bool IsFullLocalMetadata(Trailer item)
{ {
if (string.IsNullOrWhiteSpace(item.Overview)) if (string.IsNullOrWhiteSpace(item.Overview))
@ -73,6 +68,10 @@ namespace MediaBrowser.Providers.Movies
target.Item.TrailerTypes = source.Item.TrailerTypes; target.Item.TrailerTypes = source.Item.TrailerTypes;
} }
} }
public TrailerMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
{
}
} }
} }

View File

@ -15,10 +15,6 @@ namespace MediaBrowser.Providers.Music
{ {
public class AlbumMetadataService : MetadataService<MusicAlbum, AlbumInfo> public class AlbumMetadataService : MetadataService<MusicAlbum, AlbumInfo>
{ {
public AlbumMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager)
{
}
protected override async Task<ItemUpdateType> BeforeSave(MusicAlbum item, bool isFullRefresh, ItemUpdateType currentUpdateType) protected override async Task<ItemUpdateType> BeforeSave(MusicAlbum item, bool isFullRefresh, ItemUpdateType currentUpdateType)
{ {
var updateType = await base.BeforeSave(item, isFullRefresh, currentUpdateType).ConfigureAwait(false); var updateType = await base.BeforeSave(item, isFullRefresh, currentUpdateType).ConfigureAwait(false);
@ -166,5 +162,9 @@ namespace MediaBrowser.Providers.Music
targetItem.Artists = sourceItem.Artists; targetItem.Artists = sourceItem.Artists;
} }
} }
public AlbumMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
{
}
} }
} }

View File

@ -15,10 +15,6 @@ namespace MediaBrowser.Providers.Music
{ {
public class ArtistMetadataService : MetadataService<MusicArtist, ArtistInfo> public class ArtistMetadataService : MetadataService<MusicArtist, ArtistInfo>
{ {
public ArtistMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager)
{
}
protected override async Task<ItemUpdateType> BeforeSave(MusicArtist item, bool isFullRefresh, ItemUpdateType currentUpdateType) protected override async Task<ItemUpdateType> BeforeSave(MusicArtist item, bool isFullRefresh, ItemUpdateType currentUpdateType)
{ {
var updateType = await base.BeforeSave(item, isFullRefresh, currentUpdateType).ConfigureAwait(false); var updateType = await base.BeforeSave(item, isFullRefresh, currentUpdateType).ConfigureAwait(false);
@ -58,5 +54,9 @@ namespace MediaBrowser.Providers.Music
{ {
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings); ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
} }
public ArtistMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
{
}
} }
} }

View File

@ -12,10 +12,6 @@ namespace MediaBrowser.Providers.Music
{ {
public class AudioMetadataService : MetadataService<Audio, SongInfo> public class AudioMetadataService : MetadataService<Audio, SongInfo>
{ {
public AudioMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager)
{
}
protected override void MergeData(MetadataResult<Audio> source, MetadataResult<Audio> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings) protected override void MergeData(MetadataResult<Audio> source, MetadataResult<Audio> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings)
{ {
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings); ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
@ -33,5 +29,9 @@ namespace MediaBrowser.Providers.Music
targetItem.Album = sourceItem.Album; targetItem.Album = sourceItem.Album;
} }
} }
public AudioMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
{
}
} }
} }

View File

@ -25,6 +25,8 @@ namespace MediaBrowser.Providers.Music
private readonly IApplicationHost _appHost; private readonly IApplicationHost _appHost;
private readonly ILogger _logger; private readonly ILogger _logger;
public static string MusicBrainzBaseUrl = "http://musicbrainz.fercasas.com:5000";
public MusicBrainzAlbumProvider(IHttpClient httpClient, IApplicationHost appHost, ILogger logger) public MusicBrainzAlbumProvider(IHttpClient httpClient, IApplicationHost appHost, ILogger logger)
{ {
_httpClient = httpClient; _httpClient = httpClient;
@ -42,7 +44,7 @@ namespace MediaBrowser.Providers.Music
if (!string.IsNullOrEmpty(releaseId)) if (!string.IsNullOrEmpty(releaseId))
{ {
url = string.Format("https://www.musicbrainz.org/ws/2/release/?query=reid:{0}", releaseId); url = string.Format(MusicBrainzBaseUrl + "/ws/2/release/?query=reid:{0}", releaseId);
} }
else else
{ {
@ -50,7 +52,7 @@ namespace MediaBrowser.Providers.Music
if (!string.IsNullOrWhiteSpace(artistMusicBrainzId)) if (!string.IsNullOrWhiteSpace(artistMusicBrainzId))
{ {
url = string.Format("https://www.musicbrainz.org/ws/2/release/?query=\"{0}\" AND arid:{1}", url = string.Format(MusicBrainzBaseUrl + "/ws/2/release/?query=\"{0}\" AND arid:{1}",
WebUtility.UrlEncode(searchInfo.Name), WebUtility.UrlEncode(searchInfo.Name),
artistMusicBrainzId); artistMusicBrainzId);
} }
@ -58,7 +60,7 @@ namespace MediaBrowser.Providers.Music
{ {
isNameSearch = true; isNameSearch = true;
url = string.Format("https://www.musicbrainz.org/ws/2/release/?query=\"{0}\" AND artist:\"{1}\"", url = string.Format(MusicBrainzBaseUrl + "/ws/2/release/?query=\"{0}\" AND artist:\"{1}\"",
WebUtility.UrlEncode(searchInfo.Name), WebUtility.UrlEncode(searchInfo.Name),
WebUtility.UrlEncode(searchInfo.GetAlbumArtist())); WebUtility.UrlEncode(searchInfo.GetAlbumArtist()));
} }
@ -77,7 +79,7 @@ namespace MediaBrowser.Providers.Music
private IEnumerable<RemoteSearchResult> GetResultsFromResponse(XmlDocument doc) private IEnumerable<RemoteSearchResult> GetResultsFromResponse(XmlDocument doc)
{ {
var ns = new XmlNamespaceManager(doc.NameTable); var ns = new XmlNamespaceManager(doc.NameTable);
ns.AddNamespace("mb", "https://musicbrainz.org/ns/mmd-2.0#"); ns.AddNamespace("mb", MusicBrainzBaseUrl + "/ns/mmd-2.0#");
var list = new List<RemoteSearchResult>(); var list = new List<RemoteSearchResult>();
@ -197,7 +199,7 @@ namespace MediaBrowser.Providers.Music
private async Task<ReleaseResult> GetReleaseResult(string albumName, string artistId, CancellationToken cancellationToken) private async Task<ReleaseResult> GetReleaseResult(string albumName, string artistId, CancellationToken cancellationToken)
{ {
var url = string.Format("https://www.musicbrainz.org/ws/2/release/?query=\"{0}\" AND arid:{1}", var url = string.Format(MusicBrainzBaseUrl + "/ws/2/release/?query=\"{0}\" AND arid:{1}",
WebUtility.UrlEncode(albumName), WebUtility.UrlEncode(albumName),
artistId); artistId);
@ -208,7 +210,7 @@ namespace MediaBrowser.Providers.Music
private async Task<ReleaseResult> GetReleaseResultByArtistName(string albumName, string artistName, CancellationToken cancellationToken) private async Task<ReleaseResult> GetReleaseResultByArtistName(string albumName, string artistName, CancellationToken cancellationToken)
{ {
var url = string.Format("https://www.musicbrainz.org/ws/2/release/?query=\"{0}\" AND artist:\"{1}\"", var url = string.Format(MusicBrainzBaseUrl + "/ws/2/release/?query=\"{0}\" AND artist:\"{1}\"",
WebUtility.UrlEncode(albumName), WebUtility.UrlEncode(albumName),
WebUtility.UrlEncode(artistName)); WebUtility.UrlEncode(artistName));
@ -220,7 +222,7 @@ namespace MediaBrowser.Providers.Music
private ReleaseResult GetReleaseResult(XmlDocument doc) private ReleaseResult GetReleaseResult(XmlDocument doc)
{ {
var ns = new XmlNamespaceManager(doc.NameTable); var ns = new XmlNamespaceManager(doc.NameTable);
ns.AddNamespace("mb", "https://musicbrainz.org/ns/mmd-2.0#"); ns.AddNamespace("mb", MusicBrainzBaseUrl + "/ns/mmd-2.0#");
var result = new ReleaseResult var result = new ReleaseResult
{ {
@ -258,12 +260,12 @@ namespace MediaBrowser.Providers.Music
/// <returns>Task{System.String}.</returns> /// <returns>Task{System.String}.</returns>
private async Task<string> GetReleaseGroupId(string releaseEntryId, CancellationToken cancellationToken) private async Task<string> GetReleaseGroupId(string releaseEntryId, CancellationToken cancellationToken)
{ {
var url = string.Format("https://www.musicbrainz.org/ws/2/release-group/?query=reid:{0}", releaseEntryId); var url = string.Format(MusicBrainzBaseUrl + "/ws/2/release-group/?query=reid:{0}", releaseEntryId);
var doc = await GetMusicBrainzResponse(url, false, cancellationToken).ConfigureAwait(false); var doc = await GetMusicBrainzResponse(url, false, cancellationToken).ConfigureAwait(false);
var ns = new XmlNamespaceManager(doc.NameTable); var ns = new XmlNamespaceManager(doc.NameTable);
ns.AddNamespace("mb", "https://musicbrainz.org/ns/mmd-2.0#"); ns.AddNamespace("mb", MusicBrainzBaseUrl + "/ns/mmd-2.0#");
var node = doc.SelectSingleNode("//mb:release-group-list/mb:release-group/@id", ns); var node = doc.SelectSingleNode("//mb:release-group-list/mb:release-group/@id", ns);
return node != null ? node.Value : null; return node != null ? node.Value : null;

View File

@ -23,7 +23,7 @@ namespace MediaBrowser.Providers.Music
if (!string.IsNullOrWhiteSpace(musicBrainzId)) if (!string.IsNullOrWhiteSpace(musicBrainzId))
{ {
var url = string.Format("https://www.musicbrainz.org/ws/2/artist/?query=arid:{0}", musicBrainzId); var url = string.Format(MusicBrainzAlbumProvider.MusicBrainzBaseUrl + "/ws/2/artist/?query=arid:{0}", musicBrainzId);
var doc = await MusicBrainzAlbumProvider.Current.GetMusicBrainzResponse(url, false, cancellationToken) var doc = await MusicBrainzAlbumProvider.Current.GetMusicBrainzResponse(url, false, cancellationToken)
.ConfigureAwait(false); .ConfigureAwait(false);
@ -35,7 +35,7 @@ namespace MediaBrowser.Providers.Music
// They seem to throw bad request failures on any term with a slash // They seem to throw bad request failures on any term with a slash
var nameToSearch = searchInfo.Name.Replace('/', ' '); var nameToSearch = searchInfo.Name.Replace('/', ' ');
var url = String.Format("https://www.musicbrainz.org/ws/2/artist/?query=artist:\"{0}\"", UrlEncode(nameToSearch)); var url = String.Format(MusicBrainzAlbumProvider.MusicBrainzBaseUrl + "/ws/2/artist/?query=artist:\"{0}\"", UrlEncode(nameToSearch));
var doc = await MusicBrainzAlbumProvider.Current.GetMusicBrainzResponse(url, true, cancellationToken).ConfigureAwait(false); var doc = await MusicBrainzAlbumProvider.Current.GetMusicBrainzResponse(url, true, cancellationToken).ConfigureAwait(false);
@ -49,7 +49,7 @@ namespace MediaBrowser.Providers.Music
if (HasDiacritics(searchInfo.Name)) if (HasDiacritics(searchInfo.Name))
{ {
// Try again using the search with accent characters url // Try again using the search with accent characters url
url = String.Format("https://www.musicbrainz.org/ws/2/artist/?query=artistaccent:\"{0}\"", UrlEncode(nameToSearch)); url = String.Format(MusicBrainzAlbumProvider.MusicBrainzBaseUrl + "/ws/2/artist/?query=artistaccent:\"{0}\"", UrlEncode(nameToSearch));
doc = await MusicBrainzAlbumProvider.Current.GetMusicBrainzResponse(url, true, cancellationToken).ConfigureAwait(false); doc = await MusicBrainzAlbumProvider.Current.GetMusicBrainzResponse(url, true, cancellationToken).ConfigureAwait(false);

View File

@ -13,10 +13,6 @@ namespace MediaBrowser.Providers.Music
{ {
class MusicVideoMetadataService : MetadataService<MusicVideo, MusicVideoInfo> class MusicVideoMetadataService : MetadataService<MusicVideo, MusicVideoInfo>
{ {
public MusicVideoMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager)
{
}
protected override void MergeData(MetadataResult<MusicVideo> source, MetadataResult<MusicVideo> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings) protected override void MergeData(MetadataResult<MusicVideo> source, MetadataResult<MusicVideo> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings)
{ {
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings); ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
@ -34,5 +30,9 @@ namespace MediaBrowser.Providers.Music
targetItem.Artists = sourceItem.Artists.ToList(); targetItem.Artists = sourceItem.Artists.ToList();
} }
} }
public MusicVideoMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
{
}
} }
} }

View File

@ -12,13 +12,13 @@ namespace MediaBrowser.Providers.MusicGenres
{ {
public class MusicGenreMetadataService : MetadataService<MusicGenre, ItemLookupInfo> public class MusicGenreMetadataService : MetadataService<MusicGenre, ItemLookupInfo>
{ {
public MusicGenreMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager)
{
}
protected override void MergeData(MetadataResult<MusicGenre> source, MetadataResult<MusicGenre> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings) protected override void MergeData(MetadataResult<MusicGenre> source, MetadataResult<MusicGenre> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings)
{ {
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings); ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
} }
public MusicGenreMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
{
}
} }
} }

View File

@ -12,10 +12,6 @@ namespace MediaBrowser.Providers.People
{ {
public class PersonMetadataService : MetadataService<Person, PersonLookupInfo> public class PersonMetadataService : MetadataService<Person, PersonLookupInfo>
{ {
public PersonMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager)
{
}
protected override void MergeData(MetadataResult<Person> source, MetadataResult<Person> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings) protected override void MergeData(MetadataResult<Person> source, MetadataResult<Person> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings)
{ {
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings); ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
@ -28,5 +24,9 @@ namespace MediaBrowser.Providers.People
targetItem.PlaceOfBirth = sourceItem.PlaceOfBirth; targetItem.PlaceOfBirth = sourceItem.PlaceOfBirth;
} }
} }
public PersonMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
{
}
} }
} }

View File

@ -12,13 +12,13 @@ namespace MediaBrowser.Providers.Photos
{ {
class PhotoAlbumMetadataService : MetadataService<PhotoAlbum, ItemLookupInfo> class PhotoAlbumMetadataService : MetadataService<PhotoAlbum, ItemLookupInfo>
{ {
public PhotoAlbumMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager)
{
}
protected override void MergeData(MetadataResult<PhotoAlbum> source, MetadataResult<PhotoAlbum> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings) protected override void MergeData(MetadataResult<PhotoAlbum> source, MetadataResult<PhotoAlbum> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings)
{ {
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings); ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
} }
public PhotoAlbumMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
{
}
} }
} }

View File

@ -12,13 +12,13 @@ namespace MediaBrowser.Providers.Photos
{ {
class PhotoMetadataService : MetadataService<Photo, ItemLookupInfo> class PhotoMetadataService : MetadataService<Photo, ItemLookupInfo>
{ {
public PhotoMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager)
{
}
protected override void MergeData(MetadataResult<Photo> source, MetadataResult<Photo> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings) protected override void MergeData(MetadataResult<Photo> source, MetadataResult<Photo> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings)
{ {
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings); ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
} }
public PhotoMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
{
}
} }
} }

View File

@ -12,10 +12,6 @@ namespace MediaBrowser.Providers.Playlists
{ {
class PlaylistMetadataService : MetadataService<Playlist, ItemLookupInfo> class PlaylistMetadataService : MetadataService<Playlist, ItemLookupInfo>
{ {
public PlaylistMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager)
{
}
protected override void MergeData(MetadataResult<Playlist> source, MetadataResult<Playlist> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings) protected override void MergeData(MetadataResult<Playlist> source, MetadataResult<Playlist> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings)
{ {
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings); ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
@ -34,5 +30,9 @@ namespace MediaBrowser.Providers.Playlists
targetItem.Shares = sourceItem.Shares; targetItem.Shares = sourceItem.Shares;
} }
} }
public PlaylistMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
{
}
} }
} }

View File

@ -12,13 +12,13 @@ namespace MediaBrowser.Providers.Studios
{ {
public class StudioMetadataService : MetadataService<Studio, ItemLookupInfo> public class StudioMetadataService : MetadataService<Studio, ItemLookupInfo>
{ {
public StudioMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager)
{
}
protected override void MergeData(MetadataResult<Studio> source, MetadataResult<Studio> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings) protected override void MergeData(MetadataResult<Studio> source, MetadataResult<Studio> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings)
{ {
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings); ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
} }
public StudioMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
{
}
} }
} }

View File

@ -12,10 +12,6 @@ namespace MediaBrowser.Providers.TV
{ {
public class EpisodeMetadataService : MetadataService<Episode, EpisodeInfo> public class EpisodeMetadataService : MetadataService<Episode, EpisodeInfo>
{ {
public EpisodeMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager)
{
}
protected override void MergeData(MetadataResult<Episode> source, MetadataResult<Episode> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings) protected override void MergeData(MetadataResult<Episode> source, MetadataResult<Episode> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings)
{ {
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings); ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
@ -58,5 +54,9 @@ namespace MediaBrowser.Providers.TV
targetItem.IndexNumberEnd = sourceItem.IndexNumberEnd; targetItem.IndexNumberEnd = sourceItem.IndexNumberEnd;
} }
} }
public EpisodeMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
{
}
} }
} }

View File

@ -15,10 +15,6 @@ namespace MediaBrowser.Providers.TV
{ {
public class SeasonMetadataService : MetadataService<Season, SeasonInfo> public class SeasonMetadataService : MetadataService<Season, SeasonInfo>
{ {
public SeasonMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager)
{
}
protected override async Task<ItemUpdateType> BeforeSave(Season item, bool isFullRefresh, ItemUpdateType currentUpdateType) protected override async Task<ItemUpdateType> BeforeSave(Season item, bool isFullRefresh, ItemUpdateType currentUpdateType)
{ {
var updateType = await base.BeforeSave(item, isFullRefresh, currentUpdateType).ConfigureAwait(false); var updateType = await base.BeforeSave(item, isFullRefresh, currentUpdateType).ConfigureAwait(false);
@ -79,5 +75,9 @@ namespace MediaBrowser.Providers.TV
return ItemUpdateType.None; return ItemUpdateType.None;
} }
public SeasonMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
{
}
} }
} }

View File

@ -18,7 +18,7 @@ namespace MediaBrowser.Providers.TV
{ {
private readonly ILocalizationManager _localization; private readonly ILocalizationManager _localization;
public SeriesMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager, ILocalizationManager localization) : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager) public SeriesMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager, ILocalizationManager localization) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
{ {
_localization = localization; _localization = localization;
} }

View File

@ -12,13 +12,13 @@ namespace MediaBrowser.Providers.Users
{ {
public class UserMetadataService : MetadataService<User, ItemLookupInfo> public class UserMetadataService : MetadataService<User, ItemLookupInfo>
{ {
public UserMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager)
{
}
protected override void MergeData(MetadataResult<User> source, MetadataResult<User> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings) protected override void MergeData(MetadataResult<User> source, MetadataResult<User> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings)
{ {
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings); ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
} }
public UserMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
{
}
} }
} }

View File

@ -12,10 +12,6 @@ namespace MediaBrowser.Providers.Videos
{ {
public class VideoMetadataService : MetadataService<Video, ItemLookupInfo> public class VideoMetadataService : MetadataService<Video, ItemLookupInfo>
{ {
public VideoMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager)
{
}
public override int Order public override int Order
{ {
get get
@ -29,5 +25,9 @@ namespace MediaBrowser.Providers.Videos
{ {
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings); ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
} }
public VideoMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
{
}
} }
} }

View File

@ -12,13 +12,13 @@ namespace MediaBrowser.Providers.Years
{ {
public class YearMetadataService : MetadataService<Year, ItemLookupInfo> public class YearMetadataService : MetadataService<Year, ItemLookupInfo>
{ {
public YearMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager, libraryManager)
{
}
protected override void MergeData(MetadataResult<Year> source, MetadataResult<Year> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings) protected override void MergeData(MetadataResult<Year> source, MetadataResult<Year> target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings)
{ {
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings); ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
} }
public YearMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
{
}
} }
} }

View File

@ -1412,6 +1412,7 @@ namespace MediaBrowser.Server.Implementations.Dto
if (episode != null) if (episode != null)
{ {
dto.IndexNumberEnd = episode.IndexNumberEnd; dto.IndexNumberEnd = episode.IndexNumberEnd;
dto.SeriesName = episode.SeriesName;
if (fields.Contains(ItemFields.AlternateEpisodeNumbers)) if (fields.Contains(ItemFields.AlternateEpisodeNumbers))
{ {
@ -1427,23 +1428,50 @@ namespace MediaBrowser.Server.Implementations.Dto
dto.AirsBeforeSeasonNumber = episode.AirsBeforeSeasonNumber; dto.AirsBeforeSeasonNumber = episode.AirsBeforeSeasonNumber;
} }
var seasonId = episode.SeasonId;
if (seasonId.HasValue)
{
dto.SeasonId = seasonId.Value.ToString("N");
}
var episodeSeason = episode.Season; var episodeSeason = episode.Season;
if (episodeSeason != null) if (episodeSeason != null)
{ {
dto.SeasonId = episodeSeason.Id.ToString("N");
if (fields.Contains(ItemFields.SeasonName)) if (fields.Contains(ItemFields.SeasonName))
{ {
dto.SeasonName = episodeSeason.Name; dto.SeasonName = episodeSeason.Name;
} }
} }
var episodeSeries = episode.Series;
if (episodeSeries != null)
{
if (fields.Contains(ItemFields.SeriesGenres)) if (fields.Contains(ItemFields.SeriesGenres))
{ {
var episodeseries = episode.Series; dto.SeriesGenres = episodeSeries.Genres.ToList();
if (episodeseries != null) }
dto.SeriesId = GetDtoId(episodeSeries);
if (fields.Contains(ItemFields.AirTime))
{ {
dto.SeriesGenres = episodeseries.Genres.ToList(); dto.AirTime = episodeSeries.AirTime;
}
if (options.GetImageLimit(ImageType.Thumb) > 0)
{
dto.SeriesThumbImageTag = GetImageCacheTag(episodeSeries, ImageType.Thumb);
}
if (options.GetImageLimit(ImageType.Primary) > 0)
{
dto.SeriesPrimaryImageTag = GetImageCacheTag(episodeSeries, ImageType.Primary);
}
if (fields.Contains(ItemFields.SeriesStudio))
{
dto.SeriesStudio = episodeSeries.Studios.FirstOrDefault();
} }
} }
} }
@ -1464,37 +1492,6 @@ namespace MediaBrowser.Server.Implementations.Dto
dto.AnimeSeriesIndex = series.AnimeSeriesIndex; dto.AnimeSeriesIndex = series.AnimeSeriesIndex;
} }
if (episode != null)
{
series = episode.Series;
if (series != null)
{
dto.SeriesId = GetDtoId(series);
dto.SeriesName = series.Name;
if (fields.Contains(ItemFields.AirTime))
{
dto.AirTime = series.AirTime;
}
if (options.GetImageLimit(ImageType.Thumb) > 0)
{
dto.SeriesThumbImageTag = GetImageCacheTag(series, ImageType.Thumb);
}
if (options.GetImageLimit(ImageType.Primary) > 0)
{
dto.SeriesPrimaryImageTag = GetImageCacheTag(series, ImageType.Primary);
}
if (fields.Contains(ItemFields.SeriesStudio))
{
dto.SeriesStudio = series.Studios.FirstOrDefault();
}
}
}
// Add SeasonInfo // Add SeasonInfo
var season = item as Season; var season = item as Season;
if (season != null) if (season != null)

View File

@ -502,7 +502,7 @@ namespace MediaBrowser.Server.Implementations.Library
throw new ArgumentNullException("type"); throw new ArgumentNullException("type");
} }
if (ConfigurationManager.Configuration.EnableLocalizedGuids && key.StartsWith(ConfigurationManager.ApplicationPaths.ProgramDataPath)) if (key.StartsWith(ConfigurationManager.ApplicationPaths.ProgramDataPath))
{ {
// Try to normalize paths located underneath program-data in an attempt to make them more portable // Try to normalize paths located underneath program-data in an attempt to make them more portable
key = key.Substring(ConfigurationManager.ApplicationPaths.ProgramDataPath.Length) key = key.Substring(ConfigurationManager.ApplicationPaths.ProgramDataPath.Length)

View File

@ -1,6 +1,9 @@
using MediaBrowser.Controller.Entities.TV; using System;
using System.IO;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using System.Linq; using System.Linq;
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
{ {
@ -37,7 +40,8 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
} }
// If the parent is a Season or Series, then this is an Episode if the VideoResolver returns something // If the parent is a Season or Series, then this is an Episode if the VideoResolver returns something
if (season != null || args.HasParent<Series>()) // Also handle flat tv folders
if (season != null || args.HasParent<Series>() || string.Equals(args.GetCollectionType(), CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
{ {
var episode = ResolveVideo<Episode>(args, false); var episode = ResolveVideo<Episode>(args, false);

View File

@ -105,12 +105,6 @@ namespace MediaBrowser.Server.Implementations.Library
} }
} }
if (user.Configuration.DisplayFoldersView)
{
var name = _localizationManager.GetLocalizedString("ViewType" + CollectionType.Folders);
list.Add(await _libraryManager.GetNamedView(name, CollectionType.Folders, string.Empty, cancellationToken).ConfigureAwait(false));
}
if (query.IncludeExternalContent) if (query.IncludeExternalContent)
{ {
var channelResult = await _channelManager.GetChannelsInternal(new ChannelQuery var channelResult = await _channelManager.GetChannelsInternal(new ChannelQuery

View File

@ -102,7 +102,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
_timerProvider.RestartTimers(); _timerProvider.RestartTimers();
SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged; SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
CreateRecordingFolders(); CreateRecordingFolders();
} }
@ -111,7 +110,19 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
CreateRecordingFolders(); CreateRecordingFolders();
} }
private void CreateRecordingFolders() internal void CreateRecordingFolders()
{
try
{
CreateRecordingFoldersInternal();
}
catch (Exception ex)
{
_logger.ErrorException("Error creating recording folders", ex);
}
}
internal void CreateRecordingFoldersInternal()
{ {
var recordingFolders = GetRecordingFolders(); var recordingFolders = GetRecordingFolders();

View File

@ -145,7 +145,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
videoArgs = "-codec:v:0 copy"; videoArgs = "-codec:v:0 copy";
} }
var commandLineArgs = "-fflags +genpts -async 1 -vsync -1 -i \"{0}\" -t {4} -sn {2} -map_metadata -1 -threads 0 {3} -y \"{1}\""; var commandLineArgs = "-probesize 1G -analyzeduration 200M -fflags +genpts -async 1 -vsync -1 -i \"{0}\" -t {4} -sn {2} -map_metadata -1 -threads 0 {3} -y \"{1}\"";
if (mediaSource.ReadAtNativeFramerate) if (mediaSource.ReadAtNativeFramerate)
{ {

View File

@ -1126,6 +1126,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv
private async Task RefreshChannelsInternal(IProgress<double> progress, CancellationToken cancellationToken) private async Task RefreshChannelsInternal(IProgress<double> progress, CancellationToken cancellationToken)
{ {
EmbyTV.EmbyTV.Current.CreateRecordingFolders();
var numComplete = 0; var numComplete = 0;
double progressPerService = _services.Count == 0 double progressPerService = _services.Count == 0
? 0 ? 0

View File

@ -276,7 +276,6 @@
<Compile Include="Notifications\NotificationManager.cs" /> <Compile Include="Notifications\NotificationManager.cs" />
<Compile Include="Persistence\SqliteFileOrganizationRepository.cs" /> <Compile Include="Persistence\SqliteFileOrganizationRepository.cs" />
<Compile Include="Notifications\SqliteNotificationsRepository.cs" /> <Compile Include="Notifications\SqliteNotificationsRepository.cs" />
<Compile Include="Persistence\SqliteProviderInfoRepository.cs" />
<Compile Include="Persistence\TypeMapper.cs" /> <Compile Include="Persistence\TypeMapper.cs" />
<Compile Include="Photos\BaseDynamicImageProvider.cs" /> <Compile Include="Photos\BaseDynamicImageProvider.cs" />
<Compile Include="Playlists\ManualPlaylistsFolder.cs" /> <Compile Include="Playlists\ManualPlaylistsFolder.cs" />

View File

@ -87,7 +87,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
private IDbCommand _updateInheritedRatingCommand; private IDbCommand _updateInheritedRatingCommand;
private IDbCommand _updateInheritedTagsCommand; private IDbCommand _updateInheritedTagsCommand;
public const int LatestSchemaVersion = 79; public const int LatestSchemaVersion = 80;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="SqliteItemRepository"/> class. /// Initializes a new instance of the <see cref="SqliteItemRepository"/> class.
@ -239,6 +239,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
_connection.AddColumn(Logger, "TypedBaseItems", "DateLastMediaAdded", "DATETIME"); _connection.AddColumn(Logger, "TypedBaseItems", "DateLastMediaAdded", "DATETIME");
_connection.AddColumn(Logger, "TypedBaseItems", "Album", "Text"); _connection.AddColumn(Logger, "TypedBaseItems", "Album", "Text");
_connection.AddColumn(Logger, "TypedBaseItems", "IsVirtualItem", "BIT"); _connection.AddColumn(Logger, "TypedBaseItems", "IsVirtualItem", "BIT");
_connection.AddColumn(Logger, "TypedBaseItems", "SeriesName", "Text");
_connection.AddColumn(Logger, "UserDataKeys", "Priority", "INT"); _connection.AddColumn(Logger, "UserDataKeys", "Priority", "INT");
@ -254,53 +255,9 @@ namespace MediaBrowser.Server.Implementations.Persistence
new MediaStreamColumns(_connection, Logger).AddColumns(); new MediaStreamColumns(_connection, Logger).AddColumns();
var mediaStreamsDbFile = Path.Combine(_config.ApplicationPaths.DataPath, "mediainfo.db");
if (File.Exists(mediaStreamsDbFile))
{
MigrateMediaStreams(mediaStreamsDbFile);
}
DataExtensions.Attach(_connection, Path.Combine(_config.ApplicationPaths.DataPath, "userdata_v2.db"), "UserDataDb"); DataExtensions.Attach(_connection, Path.Combine(_config.ApplicationPaths.DataPath, "userdata_v2.db"), "UserDataDb");
} }
private void MigrateMediaStreams(string file)
{
try
{
var backupFile = file + ".bak";
File.Copy(file, backupFile, true);
DataExtensions.Attach(_connection, backupFile, "MediaInfoOld");
var columns = string.Join(",", _mediaStreamSaveColumns);
string[] queries = {
"REPLACE INTO mediastreams("+columns+") SELECT "+columns+" FROM MediaInfoOld.mediastreams;"
};
_connection.RunQueries(queries, Logger);
}
catch (Exception ex)
{
Logger.ErrorException("Error migrating media info database", ex);
}
finally
{
TryDeleteFile(file);
}
}
private void TryDeleteFile(string file)
{
try
{
File.Delete(file);
}
catch (Exception ex)
{
Logger.ErrorException("Error deleting file {0}", ex, file);
}
}
private readonly string[] _retriveItemColumns = private readonly string[] _retriveItemColumns =
{ {
"type", "type",
@ -477,7 +434,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
"PrimaryVersionId", "PrimaryVersionId",
"DateLastMediaAdded", "DateLastMediaAdded",
"Album", "Album",
"IsVirtualItem" "IsVirtualItem",
"SeriesName"
}; };
_saveItemCommand = _connection.CreateCommand(); _saveItemCommand = _connection.CreateCommand();
_saveItemCommand.CommandText = "replace into TypedBaseItems (" + string.Join(",", saveColumns.ToArray()) + ") values ("; _saveItemCommand.CommandText = "replace into TypedBaseItems (" + string.Join(",", saveColumns.ToArray()) + ") values (";
@ -879,6 +837,16 @@ namespace MediaBrowser.Server.Implementations.Persistence
_saveItemCommand.GetParameter(index++).Value = null; _saveItemCommand.GetParameter(index++).Value = null;
} }
var hasSeries = item as IHasSeries;
if (hasSeries != null)
{
_saveItemCommand.GetParameter(index++).Value = hasSeries.SeriesName;
}
else
{
_saveItemCommand.GetParameter(index++).Value = null;
}
_saveItemCommand.Transaction = transaction; _saveItemCommand.Transaction = transaction;
_saveItemCommand.ExecuteNonQuery(); _saveItemCommand.ExecuteNonQuery();
@ -1548,11 +1516,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
private bool EnableJoinUserData(InternalItemsQuery query) private bool EnableJoinUserData(InternalItemsQuery query)
{ {
if (_config.Configuration.SchemaVersion < 76)
{
return false;
}
if (query.User == null) if (query.User == null)
{ {
return false; return false;
@ -1667,7 +1630,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
cmd.CommandText += whereText; cmd.CommandText += whereText;
if (EnableGroupByPresentationUniqueKey(query) && _config.Configuration.SchemaVersion >= 66) if (EnableGroupByPresentationUniqueKey(query))
{ {
cmd.CommandText += " Group by PresentationUniqueKey"; cmd.CommandText += " Group by PresentationUniqueKey";
} }
@ -1755,7 +1718,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
cmd.CommandText += whereText; cmd.CommandText += whereText;
if (EnableGroupByPresentationUniqueKey(query) && _config.Configuration.SchemaVersion >= 66) if (EnableGroupByPresentationUniqueKey(query))
{ {
cmd.CommandText += " Group by PresentationUniqueKey"; cmd.CommandText += " Group by PresentationUniqueKey";
} }
@ -1774,7 +1737,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
} }
} }
if (EnableGroupByPresentationUniqueKey(query) && _config.Configuration.SchemaVersion >= 66) if (EnableGroupByPresentationUniqueKey(query))
{ {
cmd.CommandText += "; select count (distinct PresentationUniqueKey) from TypedBaseItems"; cmd.CommandText += "; select count (distinct PresentationUniqueKey) from TypedBaseItems";
} }
@ -1924,7 +1887,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
cmd.CommandText += whereText; cmd.CommandText += whereText;
if (EnableGroupByPresentationUniqueKey(query) && _config.Configuration.SchemaVersion >= 66) if (EnableGroupByPresentationUniqueKey(query))
{ {
cmd.CommandText += " Group by PresentationUniqueKey"; cmd.CommandText += " Group by PresentationUniqueKey";
} }
@ -1984,7 +1947,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
cmd.CommandText += whereText; cmd.CommandText += whereText;
if (EnableGroupByPresentationUniqueKey(query) && _config.Configuration.SchemaVersion >= 66) if (EnableGroupByPresentationUniqueKey(query))
{ {
cmd.CommandText += " Group by PresentationUniqueKey"; cmd.CommandText += " Group by PresentationUniqueKey";
} }
@ -2067,7 +2030,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
cmd.CommandText += whereText; cmd.CommandText += whereText;
if (EnableGroupByPresentationUniqueKey(query) && _config.Configuration.SchemaVersion >= 66) if (EnableGroupByPresentationUniqueKey(query))
{ {
cmd.CommandText += " Group by PresentationUniqueKey"; cmd.CommandText += " Group by PresentationUniqueKey";
} }
@ -2086,7 +2049,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
} }
} }
if (EnableGroupByPresentationUniqueKey(query) && _config.Configuration.SchemaVersion >= 66) if (EnableGroupByPresentationUniqueKey(query))
{ {
cmd.CommandText += "; select count (distinct PresentationUniqueKey) from TypedBaseItems"; cmd.CommandText += "; select count (distinct PresentationUniqueKey) from TypedBaseItems";
} }
@ -2362,42 +2325,20 @@ namespace MediaBrowser.Server.Implementations.Persistence
} }
if (!string.IsNullOrWhiteSpace(query.SlugName)) if (!string.IsNullOrWhiteSpace(query.SlugName))
{
if (_config.Configuration.SchemaVersion >= 70)
{ {
whereClauses.Add("SlugName=@SlugName"); whereClauses.Add("SlugName=@SlugName");
}
else
{
whereClauses.Add("Name=@SlugName");
}
cmd.Parameters.Add(cmd, "@SlugName", DbType.String).Value = query.SlugName; cmd.Parameters.Add(cmd, "@SlugName", DbType.String).Value = query.SlugName;
} }
if (!string.IsNullOrWhiteSpace(query.Name)) if (!string.IsNullOrWhiteSpace(query.Name))
{
if (_config.Configuration.SchemaVersion >= 66)
{ {
whereClauses.Add("CleanName=@Name"); whereClauses.Add("CleanName=@Name");
cmd.Parameters.Add(cmd, "@Name", DbType.String).Value = query.Name.RemoveDiacritics(); cmd.Parameters.Add(cmd, "@Name", DbType.String).Value = query.Name.RemoveDiacritics();
} }
else
{
whereClauses.Add("Name=@Name");
cmd.Parameters.Add(cmd, "@Name", DbType.String).Value = query.Name;
}
}
if (!string.IsNullOrWhiteSpace(query.NameContains)) if (!string.IsNullOrWhiteSpace(query.NameContains))
{
if (_config.Configuration.SchemaVersion >= 66)
{ {
whereClauses.Add("CleanName like @NameContains"); whereClauses.Add("CleanName like @NameContains");
}
else
{
whereClauses.Add("Name like @NameContains");
}
cmd.Parameters.Add(cmd, "@NameContains", DbType.String).Value = "%" + query.NameContains.RemoveDiacritics() + "%"; cmd.Parameters.Add(cmd, "@NameContains", DbType.String).Value = "%" + query.NameContains.RemoveDiacritics() + "%";
} }
if (!string.IsNullOrWhiteSpace(query.NameStartsWith)) if (!string.IsNullOrWhiteSpace(query.NameStartsWith))

View File

@ -1,248 +0,0 @@
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Logging;
using System;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Server.Implementations.Persistence
{
public class SqliteProviderInfoRepository : BaseSqliteRepository, IProviderRepository
{
private IDbConnection _connection;
private IDbCommand _saveStatusCommand;
private readonly IApplicationPaths _appPaths;
public SqliteProviderInfoRepository(ILogManager logManager, IApplicationPaths appPaths) : base(logManager)
{
_appPaths = appPaths;
}
/// <summary>
/// Gets the name of the repository
/// </summary>
/// <value>The name.</value>
public string Name
{
get
{
return "SQLite";
}
}
/// <summary>
/// Opens the connection to the database
/// </summary>
/// <returns>Task.</returns>
public async Task Initialize(IDbConnector dbConnector)
{
var dbFile = Path.Combine(_appPaths.DataPath, "refreshinfo.db");
_connection = await dbConnector.Connect(dbFile).ConfigureAwait(false);
string[] queries = {
"create table if not exists MetadataStatus (ItemId GUID PRIMARY KEY, DateLastMetadataRefresh datetime, DateLastImagesRefresh datetime, ItemDateModified DateTimeNull)",
"create index if not exists idx_MetadataStatus on MetadataStatus(ItemId)",
//pragmas
"pragma temp_store = memory",
"pragma shrink_memory"
};
_connection.RunQueries(queries, Logger);
AddItemDateModifiedCommand();
PrepareStatements();
}
private static readonly string[] StatusColumns =
{
"ItemId",
"DateLastMetadataRefresh",
"DateLastImagesRefresh",
"ItemDateModified"
};
private void AddItemDateModifiedCommand()
{
using (var cmd = _connection.CreateCommand())
{
cmd.CommandText = "PRAGMA table_info(MetadataStatus)";
using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult))
{
while (reader.Read())
{
if (!reader.IsDBNull(1))
{
var name = reader.GetString(1);
if (string.Equals(name, "ItemDateModified", StringComparison.OrdinalIgnoreCase))
{
return;
}
}
}
}
}
var builder = new StringBuilder();
builder.AppendLine("alter table MetadataStatus");
builder.AppendLine("add column ItemDateModified DateTime NULL");
_connection.RunQueries(new[] { builder.ToString() }, Logger);
}
/// <summary>
/// Prepares the statements.
/// </summary>
private void PrepareStatements()
{
_saveStatusCommand = _connection.CreateCommand();
_saveStatusCommand.CommandText = string.Format("replace into MetadataStatus ({0}) values ({1})",
string.Join(",", StatusColumns),
string.Join(",", StatusColumns.Select(i => "@" + i).ToArray()));
foreach (var col in StatusColumns)
{
_saveStatusCommand.Parameters.Add(_saveStatusCommand, "@" + col);
}
}
public MetadataStatus GetMetadataStatus(Guid itemId)
{
if (itemId == Guid.Empty)
{
throw new ArgumentNullException("itemId");
}
using (var cmd = _connection.CreateCommand())
{
var cmdText = "select " + string.Join(",", StatusColumns) + " from MetadataStatus where";
cmdText += " ItemId=@ItemId";
cmd.Parameters.Add(cmd, "@ItemId", DbType.Guid).Value = itemId;
cmd.CommandText = cmdText;
using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult | CommandBehavior.SingleRow))
{
while (reader.Read())
{
return GetStatus(reader);
}
return null;
}
}
}
private MetadataStatus GetStatus(IDataReader reader)
{
var result = new MetadataStatus
{
ItemId = reader.GetGuid(0)
};
if (!reader.IsDBNull(1))
{
result.DateLastMetadataRefresh = reader.GetDateTime(1).ToUniversalTime();
}
if (!reader.IsDBNull(2))
{
result.DateLastImagesRefresh = reader.GetDateTime(2).ToUniversalTime();
}
if (!reader.IsDBNull(3))
{
result.ItemDateModified = reader.GetDateTime(3).ToUniversalTime();
}
return result;
}
public async Task SaveMetadataStatus(MetadataStatus status, CancellationToken cancellationToken)
{
if (status == null)
{
throw new ArgumentNullException("status");
}
cancellationToken.ThrowIfCancellationRequested();
await WriteLock.WaitAsync(cancellationToken).ConfigureAwait(false);
IDbTransaction transaction = null;
try
{
transaction = _connection.BeginTransaction();
_saveStatusCommand.GetParameter(0).Value = status.ItemId;
_saveStatusCommand.GetParameter(1).Value = status.DateLastMetadataRefresh;
_saveStatusCommand.GetParameter(2).Value = status.DateLastImagesRefresh;
_saveStatusCommand.GetParameter(3).Value = status.ItemDateModified;
_saveStatusCommand.Transaction = transaction;
_saveStatusCommand.ExecuteNonQuery();
transaction.Commit();
}
catch (OperationCanceledException)
{
if (transaction != null)
{
transaction.Rollback();
}
throw;
}
catch (Exception e)
{
Logger.ErrorException("Failed to save provider info:", e);
if (transaction != null)
{
transaction.Rollback();
}
throw;
}
finally
{
if (transaction != null)
{
transaction.Dispose();
}
WriteLock.Release();
}
}
protected override void CloseConnection()
{
if (_connection != null)
{
if (_connection.IsOpen())
{
_connection.Close();
}
_connection.Dispose();
_connection = null;
}
}
}
}

View File

@ -190,7 +190,6 @@ namespace MediaBrowser.Server.Startup.Common
internal IItemRepository ItemRepository { get; set; } internal IItemRepository ItemRepository { get; set; }
private INotificationsRepository NotificationsRepository { get; set; } private INotificationsRepository NotificationsRepository { get; set; }
private IFileOrganizationRepository FileOrganizationRepository { get; set; } private IFileOrganizationRepository FileOrganizationRepository { get; set; }
private IProviderRepository ProviderRepository { get; set; }
private INotificationManager NotificationManager { get; set; } private INotificationManager NotificationManager { get; set; }
private ISubtitleManager SubtitleManager { get; set; } private ISubtitleManager SubtitleManager { get; set; }
@ -339,7 +338,7 @@ namespace MediaBrowser.Server.Startup.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.ErrorException("Error in {0}", ex, entryPoint.GetType().Name); Logger.ErrorException("Error in {0}", ex, entryPoint.GetType().FullName);
} }
}); });
@ -418,10 +417,6 @@ namespace MediaBrowser.Server.Startup.Common
ItemRepository = itemRepo; ItemRepository = itemRepo;
RegisterSingleInstance(ItemRepository); RegisterSingleInstance(ItemRepository);
var providerRepo = new SqliteProviderInfoRepository(LogManager, ApplicationPaths);
ProviderRepository = providerRepo;
RegisterSingleInstance(ProviderRepository);
FileOrganizationRepository = await GetFileOrganizationRepository().ConfigureAwait(false); FileOrganizationRepository = await GetFileOrganizationRepository().ConfigureAwait(false);
RegisterSingleInstance(FileOrganizationRepository); RegisterSingleInstance(FileOrganizationRepository);
@ -564,7 +559,6 @@ namespace MediaBrowser.Server.Startup.Common
await displayPreferencesRepo.Initialize(NativeApp.GetDbConnector()).ConfigureAwait(false); await displayPreferencesRepo.Initialize(NativeApp.GetDbConnector()).ConfigureAwait(false);
await ConfigureUserDataRepositories().ConfigureAwait(false); await ConfigureUserDataRepositories().ConfigureAwait(false);
await itemRepo.Initialize(NativeApp.GetDbConnector()).ConfigureAwait(false); await itemRepo.Initialize(NativeApp.GetDbConnector()).ConfigureAwait(false);
await providerRepo.Initialize(NativeApp.GetDbConnector()).ConfigureAwait(false);
((LibraryManager)LibraryManager).ItemRepository = ItemRepository; ((LibraryManager)LibraryManager).ItemRepository = ItemRepository;
await ConfigureNotificationsRepository().ConfigureAwait(false); await ConfigureNotificationsRepository().ConfigureAwait(false);
progress.Report(100); progress.Report(100);

View File

@ -167,9 +167,6 @@
<Content Include="dashboard-ui\legacy\buttonenabled.js"> <Content Include="dashboard-ui\legacy\buttonenabled.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="dashboard-ui\components\collectioneditor\collectioneditor.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\components\directorybrowser\directorybrowser.js"> <Content Include="dashboard-ui\components\directorybrowser\directorybrowser.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
@ -218,9 +215,6 @@
<Content Include="dashboard-ui\components\metadataeditor\metadataeditor.template.html"> <Content Include="dashboard-ui\components\metadataeditor\metadataeditor.template.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="dashboard-ui\components\playlisteditor\playlisteditor.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\devices\ie\ie.css"> <Content Include="dashboard-ui\devices\ie\ie.css">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
@ -362,6 +356,9 @@
<Content Include="dashboard-ui\scripts\supporterkeypage.js"> <Content Include="dashboard-ui\scripts\supporterkeypage.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="dashboard-ui\scripts\tvlatest.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\scripts\wizardlivetvguide.js"> <Content Include="dashboard-ui\scripts\wizardlivetvguide.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
@ -938,9 +935,6 @@
<Content Include="dashboard-ui\scripts\playlistedit.js"> <Content Include="dashboard-ui\scripts\playlistedit.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="dashboard-ui\scripts\playlistmanager.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\scripts\playlists.js"> <Content Include="dashboard-ui\scripts\playlists.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
@ -1155,9 +1149,6 @@
<Content Include="dashboard-ui\scripts\search.js"> <Content Include="dashboard-ui\scripts\search.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="dashboard-ui\scripts\tvlatest.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\scripts\moviecollections.js"> <Content Include="dashboard-ui\scripts\moviecollections.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>