added more image providers
This commit is contained in:
parent
12757d094b
commit
d0f1a83621
|
@ -378,7 +378,7 @@ namespace MediaBrowser.Api.Images
|
|||
/// <returns>System.String.</returns>
|
||||
private string GetFullCachePath(string filename)
|
||||
{
|
||||
return Path.Combine(_appPaths.DownloadedImagesDataPath, filename.Substring(0, 1), filename);
|
||||
return Path.Combine(_appPaths.CachePath, "remote-images", filename.Substring(0, 1), filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace MediaBrowser.Controller.Entities.Audio
|
|||
/// <summary>
|
||||
/// Class Audio
|
||||
/// </summary>
|
||||
public class Audio : BaseItem, IHasMediaStreams, IHasAlbumArtist, IHasArtist, IHasMusicGenres, IHasLookupInfo<SongInfo>
|
||||
public class Audio : BaseItem, IHasMediaStreams, IHasAlbumArtist, IHasArtist, IHasMusicGenres, IHasLookupInfo<SongInfo>, IHasSeries
|
||||
{
|
||||
public Audio()
|
||||
{
|
||||
|
@ -51,6 +51,15 @@ namespace MediaBrowser.Controller.Entities.Audio
|
|||
}
|
||||
}
|
||||
|
||||
[IgnoreDataMember]
|
||||
public string SeriesName
|
||||
{
|
||||
get
|
||||
{
|
||||
return Album;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the artist.
|
||||
/// </summary>
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace MediaBrowser.Controller.Entities.Audio
|
|||
/// <summary>
|
||||
/// Class MusicAlbum
|
||||
/// </summary>
|
||||
public class MusicAlbum : Folder, IHasAlbumArtist, IHasArtist, IHasMusicGenres, IHasTags, IHasLookupInfo<AlbumInfo>
|
||||
public class MusicAlbum : Folder, IHasAlbumArtist, IHasArtist, IHasMusicGenres, IHasTags, IHasLookupInfo<AlbumInfo>, IHasSeries
|
||||
{
|
||||
public List<Guid> SoundtrackIds { get; set; }
|
||||
|
||||
|
@ -50,6 +50,15 @@ namespace MediaBrowser.Controller.Entities.Audio
|
|||
}
|
||||
}
|
||||
|
||||
[IgnoreDataMember]
|
||||
public string SeriesName
|
||||
{
|
||||
get
|
||||
{
|
||||
return AlbumArtist;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override this to true if class should be grouped under a container in indicies
|
||||
/// The container class should be defined via IndexContainer
|
||||
|
|
|
@ -256,7 +256,7 @@ namespace MediaBrowser.Controller.Entities
|
|||
|
||||
private string _sortName;
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the sort.
|
||||
/// Gets the name of the sort.
|
||||
/// </summary>
|
||||
/// <value>The name of the sort.</value>
|
||||
[IgnoreDataMember]
|
||||
|
|
|
@ -4,7 +4,7 @@ using System.Collections.Generic;
|
|||
|
||||
namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
public class Book : BaseItem, IHasTags, IHasPreferredMetadataLanguage, IHasLookupInfo<BookInfo>
|
||||
public class Book : BaseItem, IHasTags, IHasPreferredMetadataLanguage, IHasLookupInfo<BookInfo>, IHasSeries
|
||||
{
|
||||
public override string MediaType
|
||||
{
|
||||
|
|
|
@ -518,7 +518,7 @@ namespace MediaBrowser.Controller.Entities
|
|||
|
||||
foreach (var child in children)
|
||||
{
|
||||
if (tasks.Count > 3)
|
||||
if (tasks.Count > 5)
|
||||
{
|
||||
await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||
tasks.Clear();
|
||||
|
@ -549,7 +549,7 @@ namespace MediaBrowser.Controller.Entities
|
|||
}
|
||||
else
|
||||
{
|
||||
tasks.Add(RefreshChildMetadata(child, refreshOptions, recursive, innerProgress, cancellationToken));
|
||||
tasks.Add(RefreshChildMetadata(child, refreshOptions, false, innerProgress, cancellationToken));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -129,6 +129,12 @@ namespace MediaBrowser.Controller.Entities
|
|||
/// <param name="images">The images.</param>
|
||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||||
bool AddImages(ImageType imageType, IEnumerable<FileInfo> images);
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether [is save local metadata enabled].
|
||||
/// </summary>
|
||||
/// <returns><c>true</c> if [is save local metadata enabled]; otherwise, <c>false</c>.</returns>
|
||||
bool IsSaveLocalMetadataEnabled();
|
||||
}
|
||||
|
||||
public static class HasImagesExtensions
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities
|
||||
|
@ -33,16 +36,18 @@ namespace MediaBrowser.Controller.Entities
|
|||
/// <value>The date last saved.</value>
|
||||
DateTime DateLastSaved { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether [is save local metadata enabled].
|
||||
/// </summary>
|
||||
/// <returns><c>true</c> if [is save local metadata enabled]; otherwise, <c>false</c>.</returns>
|
||||
bool IsSaveLocalMetadataEnabled();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this instance is in mixed folder.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is in mixed folder; otherwise, <c>false</c>.</value>
|
||||
bool IsInMixedFolder { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Updates to repository.
|
||||
/// </summary>
|
||||
/// <param name="updateReason">The update reason.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task UpdateToRepository(ItemUpdateType updateReason, CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
||||
|
|
12
MediaBrowser.Controller/Entities/IHasSeries.cs
Normal file
12
MediaBrowser.Controller/Entities/IHasSeries.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
|
||||
namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
public interface IHasSeries
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the name of the series.
|
||||
/// </summary>
|
||||
/// <value>The name of the series.</value>
|
||||
string SeriesName { get; }
|
||||
}
|
||||
}
|
|
@ -13,7 +13,7 @@ namespace MediaBrowser.Controller.Entities.Movies
|
|||
/// <summary>
|
||||
/// Class Movie
|
||||
/// </summary>
|
||||
public class Movie : Video, IHasCriticRating, IHasSoundtracks, IHasBudget, IHasKeywords, IHasTrailers, IHasThemeMedia, IHasTaglines, IHasTags, IHasPreferredMetadataLanguage, IHasAwards, IHasMetascore, IHasLookupInfo<MovieInfo>
|
||||
public class Movie : Video, IHasCriticRating, IHasSoundtracks, IHasBudget, IHasKeywords, IHasTrailers, IHasThemeMedia, IHasTaglines, IHasPreferredMetadataLanguage, IHasAwards, IHasMetascore, IHasLookupInfo<MovieInfo>
|
||||
{
|
||||
public List<Guid> SpecialFeatureIds { get; set; }
|
||||
|
||||
|
@ -39,7 +39,6 @@ namespace MediaBrowser.Controller.Entities.Movies
|
|||
ThemeSongIds = new List<Guid>();
|
||||
ThemeVideoIds = new List<Guid>();
|
||||
Taglines = new List<string>();
|
||||
Tags = new List<string>();
|
||||
Keywords = new List<string>();
|
||||
}
|
||||
|
||||
|
@ -52,12 +51,6 @@ namespace MediaBrowser.Controller.Entities.Movies
|
|||
|
||||
public List<MediaUrl> RemoteTrailers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the tags.
|
||||
/// </summary>
|
||||
/// <value>The tags.</value>
|
||||
public List<string> Tags { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the taglines.
|
||||
/// </summary>
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace MediaBrowser.Controller.Entities.TV
|
|||
/// <summary>
|
||||
/// Class Episode
|
||||
/// </summary>
|
||||
public class Episode : Video, IHasLookupInfo<EpisodeInfo>
|
||||
public class Episode : Video, IHasLookupInfo<EpisodeInfo>, IHasSeries
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the season in which it aired.
|
||||
|
@ -138,6 +138,16 @@ namespace MediaBrowser.Controller.Entities.TV
|
|||
get { return FindParent<Season>(); }
|
||||
}
|
||||
|
||||
[IgnoreDataMember]
|
||||
public string SeriesName
|
||||
{
|
||||
get
|
||||
{
|
||||
var series = Series;
|
||||
return series == null ? null : series.Name;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the name of the sort.
|
||||
/// </summary>
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Localization;
|
||||
using MediaBrowser.Controller.Localization;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Querying;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
|
@ -14,7 +11,7 @@ namespace MediaBrowser.Controller.Entities.TV
|
|||
/// <summary>
|
||||
/// Class Season
|
||||
/// </summary>
|
||||
public class Season : Folder
|
||||
public class Season : Folder, IHasSeries
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
|
@ -218,7 +215,7 @@ namespace MediaBrowser.Controller.Entities.TV
|
|||
{
|
||||
episodes = episodes.Where(i => !i.IsVirtualUnaired);
|
||||
}
|
||||
|
||||
|
||||
return LibraryManager
|
||||
.Sort(episodes, user, new[] { ItemSortBy.SortName }, SortOrder.Ascending)
|
||||
.Cast<Episode>();
|
||||
|
@ -234,5 +231,15 @@ namespace MediaBrowser.Controller.Entities.TV
|
|||
// Don't block. Let either the entire series rating or episode rating determine it
|
||||
return false;
|
||||
}
|
||||
|
||||
[IgnoreDataMember]
|
||||
public string SeriesName
|
||||
{
|
||||
get
|
||||
{
|
||||
var series = Series;
|
||||
return series == null ? null : series.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace MediaBrowser.Controller.Entities
|
|||
/// <summary>
|
||||
/// Class Trailer
|
||||
/// </summary>
|
||||
public class Trailer : Video, IHasCriticRating, IHasSoundtracks, IHasBudget, IHasTrailers, IHasKeywords, IHasTaglines, IHasTags, IHasPreferredMetadataLanguage, IHasMetascore, IHasLookupInfo<TrailerInfo>
|
||||
public class Trailer : Video, IHasCriticRating, IHasSoundtracks, IHasBudget, IHasTrailers, IHasKeywords, IHasTaglines, IHasPreferredMetadataLanguage, IHasMetascore, IHasLookupInfo<TrailerInfo>
|
||||
{
|
||||
public List<Guid> SoundtrackIds { get; set; }
|
||||
|
||||
|
@ -28,7 +28,6 @@ namespace MediaBrowser.Controller.Entities
|
|||
Taglines = new List<string>();
|
||||
SoundtrackIds = new List<Guid>();
|
||||
LocalTrailerIds = new List<Guid>();
|
||||
Tags = new List<string>();
|
||||
Keywords = new List<string>();
|
||||
}
|
||||
|
||||
|
@ -40,12 +39,6 @@ namespace MediaBrowser.Controller.Entities
|
|||
|
||||
public List<string> Keywords { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the tags.
|
||||
/// </summary>
|
||||
/// <value>The tags.</value>
|
||||
public List<string> Tags { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the taglines.
|
||||
/// </summary>
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace MediaBrowser.Controller.Entities
|
|||
/// <summary>
|
||||
/// Class Video
|
||||
/// </summary>
|
||||
public class Video : BaseItem, IHasMediaStreams, IHasAspectRatio
|
||||
public class Video : BaseItem, IHasMediaStreams, IHasAspectRatio, IHasTags
|
||||
{
|
||||
public bool IsMultiPart { get; set; }
|
||||
|
||||
|
@ -26,6 +26,7 @@ namespace MediaBrowser.Controller.Entities
|
|||
{
|
||||
PlayableStreamFileNames = new List<string>();
|
||||
AdditionalPartIds = new List<Guid>();
|
||||
Tags = new List<string>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -34,6 +35,12 @@ namespace MediaBrowser.Controller.Entities
|
|||
/// <value><c>true</c> if this instance has subtitles; otherwise, <c>false</c>.</value>
|
||||
public bool HasSubtitles { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the tags.
|
||||
/// </summary>
|
||||
/// <value>The tags.</value>
|
||||
public List<string> Tags { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the video bit rate.
|
||||
/// </summary>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using MediaBrowser.Common.Configuration;
|
||||
using System;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
|
||||
namespace MediaBrowser.Controller
|
||||
{
|
||||
|
@ -101,9 +102,16 @@ namespace MediaBrowser.Controller
|
|||
string TranscodingTempPath { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the downloaded images data path.
|
||||
/// Gets the internal metadata path.
|
||||
/// </summary>
|
||||
/// <value>The downloaded images data path.</value>
|
||||
string DownloadedImagesDataPath { get; }
|
||||
/// <value>The internal metadata path.</value>
|
||||
string InternalMetadataPath { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the internal metadata path.
|
||||
/// </summary>
|
||||
/// <param name="id">The identifier.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
string GetInternalMetadataPath(Guid id);
|
||||
}
|
||||
}
|
|
@ -94,6 +94,7 @@
|
|||
<Compile Include="Entities\IHasPreferredMetadataLanguage.cs" />
|
||||
<Compile Include="Entities\IHasProductionLocations.cs" />
|
||||
<Compile Include="Entities\IHasScreenshots.cs" />
|
||||
<Compile Include="Entities\IHasSeries.cs" />
|
||||
<Compile Include="Entities\IHasSoundtracks.cs" />
|
||||
<Compile Include="Entities\IHasTaglines.cs" />
|
||||
<Compile Include="Entities\IHasTags.cs" />
|
||||
|
|
|
@ -247,7 +247,10 @@ namespace MediaBrowser.Controller.Providers
|
|||
{
|
||||
var val = reader.ReadElementContentAsString();
|
||||
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(val))
|
||||
{
|
||||
item.ForcedSortName = val;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,8 +40,6 @@ namespace MediaBrowser.Controller.Providers
|
|||
|
||||
protected static readonly Task<bool> FalseTaskResult = Task.FromResult(false);
|
||||
|
||||
protected static readonly SemaphoreSlim XmlParsingResourcePool = new SemaphoreSlim(4, 4);
|
||||
|
||||
/// <summary>
|
||||
/// Supportses the specified item.
|
||||
/// </summary>
|
||||
|
|
|
@ -38,14 +38,14 @@ namespace MediaBrowser.Controller.Providers
|
|||
/// <summary>
|
||||
/// The success
|
||||
/// </summary>
|
||||
Success,
|
||||
/// <summary>
|
||||
/// The failure
|
||||
/// </summary>
|
||||
Failure,
|
||||
Success = 0,
|
||||
/// <summary>
|
||||
/// The completed with errors
|
||||
/// </summary>
|
||||
CompletedWithErrors
|
||||
}
|
||||
CompletedWithErrors = 1,
|
||||
/// <summary>
|
||||
/// The failure
|
||||
/// </summary>
|
||||
Failure = 2
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace MediaBrowser.Controller.Providers
|
|||
{
|
||||
}
|
||||
|
||||
public interface IImageFileProvider : ILocalImageProvider
|
||||
public interface ILocalImageFileProvider : ILocalImageProvider
|
||||
{
|
||||
List<LocalImageInfo> GetImages(IHasImages item);
|
||||
}
|
||||
|
|
|
@ -8,22 +8,6 @@ namespace MediaBrowser.Controller.Providers
|
|||
{
|
||||
public interface IProviderRepository : IRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the provider history.
|
||||
/// </summary>
|
||||
/// <param name="itemId">The item identifier.</param>
|
||||
/// <returns>IEnumerable{BaseProviderInfo}.</returns>
|
||||
IEnumerable<BaseProviderInfo> GetProviderHistory(Guid itemId);
|
||||
|
||||
/// <summary>
|
||||
/// Saves the provider history.
|
||||
/// </summary>
|
||||
/// <param name="id">The identifier.</param>
|
||||
/// <param name="history">The history.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task SaveProviderHistory(Guid id, IEnumerable<BaseProviderInfo> history, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the metadata status.
|
||||
/// </summary>
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
|
||||
namespace MediaBrowser.Controller.Providers
|
||||
{
|
||||
|
@ -13,6 +12,18 @@ namespace MediaBrowser.Controller.Providers
|
|||
/// <value>The item identifier.</value>
|
||||
public Guid ItemId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the item.
|
||||
/// </summary>
|
||||
/// <value>The name of the item.</value>
|
||||
public string ItemName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the series.
|
||||
/// </summary>
|
||||
/// <value>The name of the series.</value>
|
||||
public string SeriesName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the date last metadata refresh.
|
||||
/// </summary>
|
||||
|
|
|
@ -34,10 +34,5 @@ namespace MediaBrowser.Providers.AdultVideos
|
|||
{
|
||||
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
|
||||
}
|
||||
|
||||
protected override Task SaveItem(AdultVideo item, ItemUpdateType reason, CancellationToken cancellationToken)
|
||||
{
|
||||
return _libraryManager.UpdateItem(item, reason, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace MediaBrowser.Providers.All
|
||||
{
|
||||
public class InternalMetadataFolderImageProvider : ILocalImageFileProvider, IHasOrder
|
||||
{
|
||||
private readonly IServerConfigurationManager _config;
|
||||
|
||||
public InternalMetadataFolderImageProvider(IServerConfigurationManager config)
|
||||
{
|
||||
_config = config;
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "Internal Images"; }
|
||||
}
|
||||
|
||||
public bool Supports(IHasImages item)
|
||||
{
|
||||
if (!item.IsSaveLocalMetadataEnabled())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var locationType = item.LocationType;
|
||||
|
||||
if (locationType == LocationType.FileSystem ||
|
||||
locationType == LocationType.Offline)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// These always save locally
|
||||
if (item is IItemByName || item is User)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int Order
|
||||
{
|
||||
get
|
||||
{
|
||||
// Make sure this is last so that all other locations are scanned first
|
||||
return 1000;
|
||||
}
|
||||
}
|
||||
|
||||
public List<LocalImageInfo> GetImages(IHasImages item)
|
||||
{
|
||||
var path = _config.ApplicationPaths.GetInternalMetadataPath(item.Id);
|
||||
|
||||
try
|
||||
{
|
||||
return new LocalImageProvider().GetImages(item, path);
|
||||
}
|
||||
catch (DirectoryNotFoundException)
|
||||
{
|
||||
return new List<LocalImageInfo>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
|
@ -13,15 +12,8 @@ using System.Linq;
|
|||
|
||||
namespace MediaBrowser.Providers.All
|
||||
{
|
||||
public class LocalImageProvider : IImageFileProvider
|
||||
public class LocalImageProvider : ILocalImageFileProvider
|
||||
{
|
||||
private readonly IFileSystem _fileSystem;
|
||||
|
||||
public LocalImageProvider(IFileSystem fileSystem)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "Local Images"; }
|
||||
|
@ -91,12 +83,37 @@ namespace MediaBrowser.Providers.All
|
|||
|
||||
var list = new List<LocalImageInfo>();
|
||||
|
||||
PopulateImages(item, list, files);
|
||||
PopulateImages(item, list, files, true);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private void PopulateImages(IHasImages item, List<LocalImageInfo> images, List<FileSystemInfo> files)
|
||||
public List<LocalImageInfo> GetImages(IHasImages item, string path)
|
||||
{
|
||||
return GetImages(item, new[] { path });
|
||||
}
|
||||
|
||||
public List<LocalImageInfo> GetImages(IHasImages item, IEnumerable<string> paths)
|
||||
{
|
||||
var files = paths.SelectMany(i => new DirectoryInfo(i).EnumerateFiles("*", SearchOption.TopDirectoryOnly))
|
||||
.Where(i =>
|
||||
{
|
||||
var ext = i.Extension;
|
||||
|
||||
return !string.IsNullOrEmpty(ext) &&
|
||||
BaseItem.SupportedImageExtensions.Contains(ext, StringComparer.OrdinalIgnoreCase);
|
||||
})
|
||||
.Cast<FileSystemInfo>()
|
||||
.ToList();
|
||||
|
||||
var list = new List<LocalImageInfo>();
|
||||
|
||||
PopulateImages(item, list, files, false);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private void PopulateImages(IHasImages item, List<LocalImageInfo> images, List<FileSystemInfo> files, bool supportParentSeriesFiles)
|
||||
{
|
||||
var imagePrefix = string.Empty;
|
||||
|
||||
|
@ -126,11 +143,14 @@ namespace MediaBrowser.Providers.All
|
|||
AddImage(files, images, imagePrefix + "thumb", ImageType.Thumb);
|
||||
AddImage(files, images, imagePrefix + "landscape", ImageType.Thumb);
|
||||
|
||||
var season = item as Season;
|
||||
|
||||
if (season != null)
|
||||
if (supportParentSeriesFiles)
|
||||
{
|
||||
PopulateSeasonImagesFromSeriesFolder(season, images);
|
||||
var season = item as Season;
|
||||
|
||||
if (season != null)
|
||||
{
|
||||
PopulateSeasonImagesFromSeriesFolder(season, images);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -278,7 +298,7 @@ namespace MediaBrowser.Providers.All
|
|||
}
|
||||
}
|
||||
|
||||
private bool AddImage(List<FileSystemInfo> files, List<LocalImageInfo> images, string name, ImageType type)
|
||||
private bool AddImage(IEnumerable<FileSystemInfo> files, List<LocalImageInfo> images, string name, ImageType type)
|
||||
{
|
||||
var image = GetImage(files, name) as FileInfo;
|
||||
|
||||
|
|
|
@ -39,10 +39,5 @@ namespace MediaBrowser.Providers.Books
|
|||
target.SeriesName = source.SeriesName;
|
||||
}
|
||||
}
|
||||
|
||||
protected override Task SaveItem(Book item, ItemUpdateType reason, CancellationToken cancellationToken)
|
||||
{
|
||||
return _libraryManager.UpdateItem(item, reason, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,11 +41,6 @@ namespace MediaBrowser.Providers.BoxSets
|
|||
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
|
||||
}
|
||||
|
||||
protected override Task SaveItem(BoxSet item, ItemUpdateType reason, CancellationToken cancellationToken)
|
||||
{
|
||||
return _libraryManager.UpdateItem(item, reason, cancellationToken);
|
||||
}
|
||||
|
||||
protected override ItemUpdateType BeforeSave(BoxSet item)
|
||||
{
|
||||
var updateType = base.BeforeSave(item);
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Providers.All;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MediaBrowser.Providers.Folders
|
||||
{
|
||||
public class CollectionFolderLocalImageProvider : ILocalImageFileProvider, IHasOrder
|
||||
{
|
||||
public string Name
|
||||
{
|
||||
get { return "Collection Folder Images"; }
|
||||
}
|
||||
|
||||
public bool Supports(IHasImages item)
|
||||
{
|
||||
return item is CollectionFolder && item.LocationType == LocationType.FileSystem;
|
||||
}
|
||||
|
||||
public int Order
|
||||
{
|
||||
get
|
||||
{
|
||||
// Run after LocalImageProvider
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public List<LocalImageInfo> GetImages(IHasImages item)
|
||||
{
|
||||
var collectionFolder = (CollectionFolder)item;
|
||||
|
||||
return new LocalImageProvider().GetImages(item, collectionFolder.PhysicalLocations);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,8 +7,6 @@ using MediaBrowser.Model.Entities;
|
|||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Providers.Manager;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Providers.Folders
|
||||
{
|
||||
|
@ -35,11 +33,6 @@ namespace MediaBrowser.Providers.Folders
|
|||
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
|
||||
}
|
||||
|
||||
protected override Task SaveItem(Folder item, ItemUpdateType reason, CancellationToken cancellationToken)
|
||||
{
|
||||
return _libraryManager.UpdateItem(item, reason, cancellationToken);
|
||||
}
|
||||
|
||||
public override int Order
|
||||
{
|
||||
get
|
||||
|
|
57
MediaBrowser.Providers/Folders/ImagesByNameImageProvider.cs
Normal file
57
MediaBrowser.Providers/Folders/ImagesByNameImageProvider.cs
Normal file
|
@ -0,0 +1,57 @@
|
|||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Providers.All;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace MediaBrowser.Providers.Folders
|
||||
{
|
||||
public class ImagesByNameImageProvider : ILocalImageFileProvider, IHasOrder
|
||||
{
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly IServerConfigurationManager _config;
|
||||
|
||||
public ImagesByNameImageProvider(IFileSystem fileSystem, IServerConfigurationManager config)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_config = config;
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "Images By Name"; }
|
||||
}
|
||||
|
||||
public bool Supports(IHasImages item)
|
||||
{
|
||||
return item is ICollectionFolder;
|
||||
}
|
||||
|
||||
public int Order
|
||||
{
|
||||
get
|
||||
{
|
||||
// Run after LocalImageProvider, and after CollectionFolderImageProvider
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
public List<LocalImageInfo> GetImages(IHasImages item)
|
||||
{
|
||||
var name = _fileSystem.GetValidFilename(item.Name);
|
||||
|
||||
var path = Path.Combine(_config.ApplicationPaths.GeneralPath, name);
|
||||
|
||||
try
|
||||
{
|
||||
return new LocalImageProvider().GetImages(item, path);
|
||||
}
|
||||
catch (DirectoryNotFoundException)
|
||||
{
|
||||
return new List<LocalImageInfo>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -34,10 +34,5 @@ namespace MediaBrowser.Providers.GameGenres
|
|||
{
|
||||
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
|
||||
}
|
||||
|
||||
protected override Task SaveItem(GameGenre item, ItemUpdateType reason, CancellationToken cancellationToken)
|
||||
{
|
||||
return _libraryManager.UpdateItem(item, reason, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,10 +39,5 @@ namespace MediaBrowser.Providers.Games
|
|||
target.GameSystem = source.GameSystem;
|
||||
}
|
||||
}
|
||||
|
||||
protected override Task SaveItem(Game item, ItemUpdateType reason, CancellationToken cancellationToken)
|
||||
{
|
||||
return _libraryManager.UpdateItem(item, reason, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,10 +39,5 @@ namespace MediaBrowser.Providers.Games
|
|||
target.GameSystemName = source.GameSystemName;
|
||||
}
|
||||
}
|
||||
|
||||
protected override Task SaveItem(GameSystem item, ItemUpdateType reason, CancellationToken cancellationToken)
|
||||
{
|
||||
return _libraryManager.UpdateItem(item, reason, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,10 +34,5 @@ namespace MediaBrowser.Providers.Genres
|
|||
{
|
||||
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
|
||||
}
|
||||
|
||||
protected override Task SaveItem(Genre item, ItemUpdateType reason, CancellationToken cancellationToken)
|
||||
{
|
||||
return _libraryManager.UpdateItem(item, reason, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,10 +33,5 @@ namespace MediaBrowser.Providers.LiveTv
|
|||
{
|
||||
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
|
||||
}
|
||||
|
||||
protected override Task SaveItem(LiveTvAudioRecording item, ItemUpdateType reason, CancellationToken cancellationToken)
|
||||
{
|
||||
return _libraryManager.UpdateItem(item, reason, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,10 +29,5 @@ namespace MediaBrowser.Providers.LiveTv
|
|||
{
|
||||
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
|
||||
}
|
||||
|
||||
protected override Task SaveItem(LiveTvChannel item, ItemUpdateType reason, CancellationToken cancellationToken)
|
||||
{
|
||||
return _libraryManager.UpdateItem(item, reason, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,10 +33,5 @@ namespace MediaBrowser.Providers.LiveTv
|
|||
{
|
||||
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
|
||||
}
|
||||
|
||||
protected override Task SaveItem(LiveTvProgram item, ItemUpdateType reason, CancellationToken cancellationToken)
|
||||
{
|
||||
return _libraryManager.UpdateItem(item, reason, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,10 +33,5 @@ namespace MediaBrowser.Providers.LiveTv
|
|||
{
|
||||
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
|
||||
}
|
||||
|
||||
protected override Task SaveItem(LiveTvVideoRecording item, ItemUpdateType reason, CancellationToken cancellationToken)
|
||||
{
|
||||
return _libraryManager.UpdateItem(item, reason, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,10 +29,6 @@ namespace MediaBrowser.Providers.Manager
|
|||
/// </summary>
|
||||
private readonly IServerConfigurationManager _config;
|
||||
|
||||
/// <summary>
|
||||
/// The remote image cache
|
||||
/// </summary>
|
||||
private readonly FileSystemRepository _remoteImageCache;
|
||||
/// <summary>
|
||||
/// The _directory watchers
|
||||
/// </summary>
|
||||
|
@ -41,17 +37,18 @@ namespace MediaBrowser.Providers.Manager
|
|||
private readonly ILogger _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ImageSaver"/> class.
|
||||
/// Initializes a new instance of the <see cref="ImageSaver" /> class.
|
||||
/// </summary>
|
||||
/// <param name="config">The config.</param>
|
||||
/// <param name="libraryMonitor">The directory watchers.</param>
|
||||
/// <param name="fileSystem">The file system.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
public ImageSaver(IServerConfigurationManager config, ILibraryMonitor libraryMonitor, IFileSystem fileSystem, ILogger logger)
|
||||
{
|
||||
_config = config;
|
||||
_libraryMonitor = libraryMonitor;
|
||||
_fileSystem = fileSystem;
|
||||
_logger = logger;
|
||||
_remoteImageCache = new FileSystemRepository(config.ApplicationPaths.DownloadedImagesDataPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -348,7 +345,7 @@ namespace MediaBrowser.Providers.Manager
|
|||
// None of the save local conditions passed, so store it in our internal folders
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
path = _remoteImageCache.GetResourcePath(item.GetType().FullName + item.Id, filename + extension);
|
||||
path = Path.Combine(_config.ApplicationPaths.GetInternalMetadataPath(item.Id), filename + extension);
|
||||
}
|
||||
|
||||
return path;
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace MediaBrowser.Providers.Manager
|
|||
{
|
||||
var hasChanges = item.ValidateImages();
|
||||
|
||||
foreach (var provider in providers.OfType<IImageFileProvider>())
|
||||
foreach (var provider in providers.OfType<ILocalImageFileProvider>())
|
||||
{
|
||||
var images = provider.GetImages(item);
|
||||
|
||||
|
@ -117,8 +117,7 @@ namespace MediaBrowser.Providers.Manager
|
|||
{
|
||||
var mimeType = "image/" + Path.GetExtension(response.Path).TrimStart('.').ToLower();
|
||||
|
||||
var stream = _fileSystem.GetFileStream(response.Path, FileMode.Open, FileAccess.Read,
|
||||
FileShare.Read, true);
|
||||
var stream = _fileSystem.GetFileStream(response.Path, FileMode.Open, FileAccess.Read, FileShare.Read, true);
|
||||
|
||||
await _providerManager.SaveImage((BaseItem)item, stream, mimeType, imageType, null, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
@ -335,7 +334,7 @@ namespace MediaBrowser.Providers.Manager
|
|||
}
|
||||
catch (HttpException ex)
|
||||
{
|
||||
// Sometimes providers send back bad url's. Just move onto the next image
|
||||
// Sometimes providers send back bad url's. Just move to the next image
|
||||
if (ex.StatusCode.HasValue && ex.StatusCode.Value == HttpStatusCode.NotFound)
|
||||
{
|
||||
continue;
|
||||
|
|
|
@ -37,10 +37,18 @@ namespace MediaBrowser.Providers.Manager
|
|||
/// <summary>
|
||||
/// Saves the provider result.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="result">The result.</param>
|
||||
/// <returns>Task.</returns>
|
||||
protected Task SaveProviderResult(MetadataStatus result)
|
||||
protected Task SaveProviderResult(TItemType item, MetadataStatus result)
|
||||
{
|
||||
result.ItemId = item.Id;
|
||||
result.ItemName = item.Name;
|
||||
|
||||
var series = item as IHasSeries;
|
||||
|
||||
result.SeriesName = series == null ? null : series.SeriesName;
|
||||
|
||||
return ProviderRepo.SaveMetadataStatus(result, CancellationToken.None);
|
||||
}
|
||||
|
||||
|
@ -97,7 +105,6 @@ namespace MediaBrowser.Providers.Manager
|
|||
|
||||
if (providers.Count > 0)
|
||||
{
|
||||
|
||||
var result = await RefreshWithProviders(itemOfType, refreshOptions, providers, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
updateType = updateType | result.UpdateType;
|
||||
|
@ -140,7 +147,7 @@ namespace MediaBrowser.Providers.Manager
|
|||
|
||||
if (providersHadChanges || refreshResult.IsDirty)
|
||||
{
|
||||
await SaveProviderResult(refreshResult).ConfigureAwait(false);
|
||||
await SaveProviderResult(itemOfType, refreshResult).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -231,7 +238,10 @@ namespace MediaBrowser.Providers.Manager
|
|||
return providers;
|
||||
}
|
||||
|
||||
protected abstract Task SaveItem(TItemType item, ItemUpdateType reason, CancellationToken cancellationToken);
|
||||
protected Task SaveItem(TItemType item, ItemUpdateType reason, CancellationToken cancellationToken)
|
||||
{
|
||||
return item.UpdateToRepository(reason, cancellationToken);
|
||||
}
|
||||
|
||||
public bool CanRefresh(IHasMetadata item)
|
||||
{
|
||||
|
@ -298,6 +308,7 @@ namespace MediaBrowser.Providers.Manager
|
|||
}
|
||||
}
|
||||
|
||||
// Local metadata is king - if any is found don't run remote providers
|
||||
if (!options.ReplaceAllMetadata && !hasLocalMetadata)
|
||||
{
|
||||
await ExecuteRemoteProviders(item, temp, providers.OfType<IRemoteMetadataProvider<TItemType, TIdType>>(), refreshResult, cancellationToken).ConfigureAwait(false);
|
||||
|
@ -349,7 +360,14 @@ namespace MediaBrowser.Providers.Manager
|
|||
{
|
||||
Logger.Debug("Running {0} for {1}", provider.GetType().Name, item.Path ?? item.Name);
|
||||
|
||||
id = id ?? item.GetLookupInfo();
|
||||
if (id == null)
|
||||
{
|
||||
id = item.GetLookupInfo();
|
||||
}
|
||||
else
|
||||
{
|
||||
MergeNewData(temp, id);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -375,6 +393,15 @@ namespace MediaBrowser.Providers.Manager
|
|||
}
|
||||
}
|
||||
|
||||
private void MergeNewData(TItemType source, TIdType lookupInfo)
|
||||
{
|
||||
// Copy new provider id's that may have been obtained
|
||||
foreach (var providerId in source.ProviderIds)
|
||||
{
|
||||
lookupInfo.ProviderIds[providerId.Key] = providerId.Value;
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void MergeData(TItemType source, TItemType target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings);
|
||||
|
||||
public virtual int Order
|
||||
|
|
|
@ -470,7 +470,7 @@ namespace MediaBrowser.Providers.Manager
|
|||
}));
|
||||
|
||||
// Savers
|
||||
list.AddRange(_savers.Where(i => i.IsEnabledFor(item, ItemUpdateType.MetadataEdit)).OrderBy(i => i.Name).Select(i => new MetadataPlugin
|
||||
list.AddRange(_savers.Where(i => IsSaverEnabledForItem(i, item, ItemUpdateType.MetadataEdit)).OrderBy(i => i.Name).Select(i => new MetadataPlugin
|
||||
{
|
||||
Name = i.Name,
|
||||
Type = MetadataPluginType.MetadataSaver
|
||||
|
@ -506,7 +506,7 @@ namespace MediaBrowser.Providers.Manager
|
|||
/// <returns>Task.</returns>
|
||||
public async Task SaveMetadata(IHasMetadata item, ItemUpdateType updateType)
|
||||
{
|
||||
foreach (var saver in _savers.Where(i => i.IsEnabledFor(item, updateType)))
|
||||
foreach (var saver in _savers.Where(i => IsSaverEnabledForItem(i, item, updateType)))
|
||||
{
|
||||
_logger.Debug("Saving {0} to {1}.", item.Path ?? item.Name, saver.Name);
|
||||
|
||||
|
@ -514,13 +514,17 @@ namespace MediaBrowser.Providers.Manager
|
|||
|
||||
if (fileSaver != null)
|
||||
{
|
||||
var locationType = item.LocationType;
|
||||
if (locationType == LocationType.Remote || locationType == LocationType.Virtual)
|
||||
{
|
||||
throw new ArgumentException("Only file-system based items can save metadata.");
|
||||
}
|
||||
string path = null;
|
||||
|
||||
var path = fileSaver.GetSavePath(item);
|
||||
try
|
||||
{
|
||||
path = fileSaver.GetSavePath(item);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error in {0} GetSavePath", ex, saver.Name);
|
||||
continue;
|
||||
}
|
||||
|
||||
var semaphore = _fileLocks.GetOrAdd(path, key => new SemaphoreSlim(1, 1));
|
||||
|
||||
|
@ -554,5 +558,18 @@ namespace MediaBrowser.Providers.Manager
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsSaverEnabledForItem(IMetadataSaver saver, IHasMetadata item, ItemUpdateType updateType)
|
||||
{
|
||||
try
|
||||
{
|
||||
return saver.IsEnabledFor(item, updateType);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error in {0}.IsEnabledFor", ex, saver.Name);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ using MediaBrowser.Controller.Entities.Audio;
|
|||
using MediaBrowser.Model.Entities;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MediaBrowser.Providers
|
||||
namespace MediaBrowser.Providers.Manager
|
||||
{
|
||||
public static class ProviderUtils
|
||||
{
|
|
@ -66,12 +66,15 @@
|
|||
<ItemGroup>
|
||||
<Compile Include="AdultVideos\AdultVideoMetadataService.cs" />
|
||||
<Compile Include="AdultVideos\AdultVideoXmlProvider.cs" />
|
||||
<Compile Include="All\InternalMetadataFolderImageProvider.cs" />
|
||||
<Compile Include="All\LocalImageProvider.cs" />
|
||||
<Compile Include="Books\BookMetadataService.cs" />
|
||||
<Compile Include="BoxSets\BoxSetMetadataService.cs" />
|
||||
<Compile Include="BoxSets\MovieDbBoxSetImageProvider.cs" />
|
||||
<Compile Include="BoxSets\MovieDbBoxSetProvider.cs" />
|
||||
<Compile Include="Folders\CollectionFolderImageProvider.cs" />
|
||||
<Compile Include="Folders\FolderMetadataService.cs" />
|
||||
<Compile Include="Folders\ImagesByNameImageProvider.cs" />
|
||||
<Compile Include="GameGenres\GameGenreMetadataService.cs" />
|
||||
<Compile Include="Games\GameMetadataService.cs" />
|
||||
<Compile Include="Games\GameSystemMetadataService.cs" />
|
||||
|
@ -145,8 +148,7 @@
|
|||
<Compile Include="People\PersonXmlProvider.cs" />
|
||||
<Compile Include="People\MovieDbPersonProvider.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ProviderUtils.cs" />
|
||||
<Compile Include="RefreshIntrosTask.cs" />
|
||||
<Compile Include="Manager\ProviderUtils.cs" />
|
||||
<Compile Include="Savers\AlbumXmlSaver.cs" />
|
||||
<Compile Include="Savers\ArtistXmlSaver.cs" />
|
||||
<Compile Include="Savers\BoxSetXmlSaver.cs" />
|
||||
|
|
|
@ -3,6 +3,7 @@ using MediaBrowser.Common.IO;
|
|||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Dto;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
@ -143,10 +144,6 @@ namespace MediaBrowser.Providers.Movies
|
|||
movieItem.TmdbCollectionName = movieData.belongs_to_collection.name;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
movie.SetProviderId(MetadataProviders.TmdbCollection, null); // clear out any old entry
|
||||
}
|
||||
|
||||
float rating;
|
||||
string voteAvg = movieData.vote_average.ToString(CultureInfo.InvariantCulture);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Dto;
|
||||
|
@ -15,7 +16,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace MediaBrowser.Providers.Movies
|
||||
{
|
||||
class MovieDbImageProvider : IRemoteImageProvider, IHasOrder
|
||||
class MovieDbImageProvider : IRemoteImageProvider, IHasOrder, IHasChangeMonitor
|
||||
{
|
||||
private readonly IJsonSerializer _jsonSerializer;
|
||||
private readonly IHttpClient _httpClient;
|
||||
|
@ -207,5 +208,10 @@ namespace MediaBrowser.Providers.Movies
|
|||
ResourcePool = MovieDbProvider.Current.MovieDbResourcePool
|
||||
});
|
||||
}
|
||||
|
||||
public bool HasChanged(IHasMetadata item, DateTime date)
|
||||
{
|
||||
return MovieDbProvider.Current.HasChanged(item, date);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace MediaBrowser.Providers.Movies
|
|||
/// <summary>
|
||||
/// Class MovieDbProvider
|
||||
/// </summary>
|
||||
public class MovieDbProvider : IRemoteMetadataProvider<Movie, MovieInfo>, IDisposable, IHasChangeMonitor
|
||||
public class MovieDbProvider : IRemoteMetadataProvider<Movie, MovieInfo>, IDisposable
|
||||
{
|
||||
internal readonly SemaphoreSlim MovieDbResourcePool = new SemaphoreSlim(1, 1);
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace MediaBrowser.Providers.Movies
|
||||
{
|
||||
public class MovieDbTrailerProvider : IRemoteMetadataProvider<Trailer, TrailerInfo>, IHasChangeMonitor
|
||||
public class MovieDbTrailerProvider : IRemoteMetadataProvider<Trailer, TrailerInfo>
|
||||
{
|
||||
public Task<MetadataResult<Trailer>> GetMetadata(TrailerInfo info, CancellationToken cancellationToken)
|
||||
{
|
||||
|
|
|
@ -34,10 +34,5 @@ namespace MediaBrowser.Providers.Movies
|
|||
{
|
||||
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
|
||||
}
|
||||
|
||||
protected override Task SaveItem(Movie item, ItemUpdateType reason, CancellationToken cancellationToken)
|
||||
{
|
||||
return _libraryManager.UpdateItem(item, reason, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Common.Progress;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
|
|
|
@ -34,10 +34,5 @@ namespace MediaBrowser.Providers.Movies
|
|||
{
|
||||
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
|
||||
}
|
||||
|
||||
protected override Task SaveItem(Trailer item, ItemUpdateType reason, CancellationToken cancellationToken)
|
||||
{
|
||||
return _libraryManager.UpdateItem(item, reason, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,11 +42,6 @@ namespace MediaBrowser.Providers.Music
|
|||
}
|
||||
}
|
||||
|
||||
protected override Task SaveItem(MusicAlbum item, ItemUpdateType reason, CancellationToken cancellationToken)
|
||||
{
|
||||
return _libraryManager.UpdateItem(item, reason, cancellationToken);
|
||||
}
|
||||
|
||||
protected override ItemUpdateType BeforeSave(MusicAlbum item)
|
||||
{
|
||||
var updateType = base.BeforeSave(item);
|
||||
|
|
|
@ -9,12 +9,10 @@ using MediaBrowser.Providers.Manager;
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Providers.Music
|
||||
{
|
||||
public class ArtistMetadataService : MetadataService<MusicArtist, ItemLookupInfo>
|
||||
public class ArtistMetadataService : MetadataService<MusicArtist, ArtistInfo>
|
||||
{
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
|
||||
|
@ -37,11 +35,6 @@ namespace MediaBrowser.Providers.Music
|
|||
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
|
||||
}
|
||||
|
||||
protected override Task SaveItem(MusicArtist item, ItemUpdateType reason, CancellationToken cancellationToken)
|
||||
{
|
||||
return _libraryManager.UpdateItem(item, reason, cancellationToken);
|
||||
}
|
||||
|
||||
protected override ItemUpdateType BeforeSave(MusicArtist item)
|
||||
{
|
||||
var updateType = base.BeforeSave(item);
|
||||
|
|
|
@ -44,10 +44,5 @@ namespace MediaBrowser.Providers.Music
|
|||
target.Album = source.Album;
|
||||
}
|
||||
}
|
||||
|
||||
protected override Task SaveItem(Audio item, ItemUpdateType reason, CancellationToken cancellationToken)
|
||||
{
|
||||
return _libraryManager.UpdateItem(item, reason, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,5 +63,19 @@ namespace MediaBrowser.Providers.Music
|
|||
|
||||
return id;
|
||||
}
|
||||
|
||||
public static string GetArtistId(this ArtistInfo info)
|
||||
{
|
||||
string id;
|
||||
info.ProviderIds.TryGetValue(MetadataProviders.MusicBrainzArtist.ToString(), out id);
|
||||
|
||||
if (string.IsNullOrEmpty(id))
|
||||
{
|
||||
return info.SongInfos.Select(i => i.GetProviderId(MetadataProviders.MusicBrainzAlbumArtist))
|
||||
.FirstOrDefault(i => !string.IsNullOrEmpty(i));
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,9 +5,11 @@ using MediaBrowser.Controller.Providers;
|
|||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using MoreLinq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -39,6 +41,7 @@ namespace MediaBrowser.Providers.Music
|
|||
if (lastFmData != null && lastFmData.album != null)
|
||||
{
|
||||
result.HasMetadata = true;
|
||||
result.Item = new MusicAlbum();
|
||||
ProcessAlbumData(result.Item, lastFmData.album);
|
||||
}
|
||||
|
||||
|
@ -72,18 +75,18 @@ namespace MediaBrowser.Providers.Music
|
|||
}
|
||||
|
||||
var albumArtist = item.GetAlbumArtist();
|
||||
//// Get each song, distinct by the combination of AlbumArtist and Album
|
||||
//var songs = item.RecursiveChildren.OfType<Audio>().DistinctBy(i => (i.AlbumArtist ?? string.Empty) + (i.Album ?? string.Empty), StringComparer.OrdinalIgnoreCase).ToList();
|
||||
// Get each song, distinct by the combination of AlbumArtist and Album
|
||||
var songs = item.SongInfos.DistinctBy(i => (i.AlbumArtist ?? string.Empty) + (i.Album ?? string.Empty), StringComparer.OrdinalIgnoreCase).ToList();
|
||||
|
||||
//foreach (var song in songs.Where(song => !string.IsNullOrEmpty(song.Album) && !string.IsNullOrEmpty(song.AlbumArtist)))
|
||||
//{
|
||||
// var result = await GetAlbumResult(song.AlbumArtist, song.Album, cancellationToken).ConfigureAwait(false);
|
||||
foreach (var song in songs.Where(song => !string.IsNullOrEmpty(song.Album) && !string.IsNullOrEmpty(song.AlbumArtist)))
|
||||
{
|
||||
var result = await GetAlbumResult(song.AlbumArtist, song.Album, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// if (result != null && result.album != null)
|
||||
// {
|
||||
// return result;
|
||||
// }
|
||||
//}
|
||||
if (result != null && result.album != null)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(albumArtist))
|
||||
{
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace MediaBrowser.Providers.Music
|
|||
{
|
||||
var result = new MetadataResult<MusicArtist>();
|
||||
|
||||
var musicBrainzId = id.GetProviderId(MetadataProviders.MusicBrainzArtist);
|
||||
var musicBrainzId = id.GetArtistId();
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(musicBrainzId))
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Providers.Movies;
|
||||
using System;
|
||||
|
@ -7,7 +8,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace MediaBrowser.Providers.Music
|
||||
{
|
||||
public class MovieDbMusicVideoProvider : IRemoteMetadataProvider<MusicVideo, MusicVideoInfo>, IHasChangeMonitor
|
||||
public class MovieDbMusicVideoProvider : IRemoteMetadataProvider<MusicVideo, MusicVideoInfo>
|
||||
{
|
||||
public Task<MetadataResult<MusicVideo>> GetMetadata(MusicVideoInfo info, CancellationToken cancellationToken)
|
||||
{
|
||||
|
|
|
@ -47,14 +47,12 @@ namespace MediaBrowser.Providers.Music
|
|||
{
|
||||
releaseId = releaseResult.ReleaseId;
|
||||
result.HasMetadata = true;
|
||||
result.Item.SetProviderId(MetadataProviders.MusicBrainzAlbum, releaseId);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(releaseResult.ReleaseGroupId))
|
||||
{
|
||||
releaseGroupId = releaseResult.ReleaseGroupId;
|
||||
result.HasMetadata = true;
|
||||
result.Item.SetProviderId(MetadataProviders.MusicBrainzReleaseGroup, releaseGroupId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,7 +61,6 @@ namespace MediaBrowser.Providers.Music
|
|||
{
|
||||
releaseGroupId = await GetReleaseGroupId(releaseId, cancellationToken).ConfigureAwait(false);
|
||||
result.HasMetadata = true;
|
||||
result.Item.SetProviderId(MetadataProviders.MusicBrainzReleaseGroup, releaseGroupId);
|
||||
}
|
||||
|
||||
if (result.HasMetadata)
|
||||
|
|
|
@ -17,8 +17,8 @@ namespace MediaBrowser.Providers.Music
|
|||
public async Task<MetadataResult<MusicArtist>> GetMetadata(ArtistInfo id, CancellationToken cancellationToken)
|
||||
{
|
||||
var result = new MetadataResult<MusicArtist>();
|
||||
|
||||
var musicBrainzId = id.GetProviderId(MetadataProviders.MusicBrainzArtist) ?? await FindId(id, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var musicBrainzId = id.GetArtistId() ?? await FindId(id, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(musicBrainzId))
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
@ -44,10 +45,5 @@ namespace MediaBrowser.Providers.Music
|
|||
target.Artist = source.Artist;
|
||||
}
|
||||
}
|
||||
|
||||
protected override Task SaveItem(MusicVideo item, ItemUpdateType reason, CancellationToken cancellationToken)
|
||||
{
|
||||
return _libraryManager.UpdateItem(item, reason, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System.Xml;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Providers.Movies;
|
||||
|
|
|
@ -34,10 +34,5 @@ namespace MediaBrowser.Providers.MusicGenres
|
|||
{
|
||||
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
|
||||
}
|
||||
|
||||
protected override Task SaveItem(MusicGenre item, ItemUpdateType reason, CancellationToken cancellationToken)
|
||||
{
|
||||
return _libraryManager.UpdateItem(item, reason, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,10 +39,5 @@ namespace MediaBrowser.Providers.People
|
|||
target.PlaceOfBirth = source.PlaceOfBirth;
|
||||
}
|
||||
}
|
||||
|
||||
protected override Task SaveItem(Person item, ItemUpdateType reason, CancellationToken cancellationToken)
|
||||
{
|
||||
return _libraryManager.UpdateItem(item, reason, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
namespace MediaBrowser.Providers.Savers
|
||||
{
|
||||
|
@ -35,6 +36,12 @@ namespace MediaBrowser.Providers.Savers
|
|||
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
|
||||
public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
|
||||
{
|
||||
var locationType = item.LocationType;
|
||||
if (locationType == LocationType.Remote || locationType == LocationType.Virtual)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var wasMetadataEdited = (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit;
|
||||
var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ using MediaBrowser.Controller.Entities;
|
|||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Providers.Music;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -37,6 +38,12 @@ namespace MediaBrowser.Providers.Savers
|
|||
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
|
||||
public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
|
||||
{
|
||||
var locationType = item.LocationType;
|
||||
if (locationType == LocationType.Remote || locationType == LocationType.Virtual)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var wasMetadataEdited = (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit;
|
||||
var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ using System.IO;
|
|||
using System.Text;
|
||||
using System.Threading;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
namespace MediaBrowser.Providers.Savers
|
||||
{
|
||||
|
@ -35,6 +36,12 @@ namespace MediaBrowser.Providers.Savers
|
|||
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
|
||||
public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
|
||||
{
|
||||
var locationType = item.LocationType;
|
||||
if (locationType == LocationType.Remote || locationType == LocationType.Virtual)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var wasMetadataEdited = (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit;
|
||||
var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
namespace MediaBrowser.Providers.Savers
|
||||
{
|
||||
|
@ -22,6 +23,12 @@ namespace MediaBrowser.Providers.Savers
|
|||
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
|
||||
public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
|
||||
{
|
||||
var locationType = item.LocationType;
|
||||
if (locationType == LocationType.Remote || locationType == LocationType.Virtual)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var wasMetadataEdited = (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit;
|
||||
var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ using System.IO;
|
|||
using System.Security;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
namespace MediaBrowser.Providers.Savers
|
||||
{
|
||||
|
@ -26,6 +27,12 @@ namespace MediaBrowser.Providers.Savers
|
|||
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
|
||||
public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
|
||||
{
|
||||
var locationType = item.LocationType;
|
||||
if (locationType == LocationType.Remote || locationType == LocationType.Virtual)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var wasMetadataEdited = (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit;
|
||||
var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
namespace MediaBrowser.Providers.Savers
|
||||
{
|
||||
|
@ -37,6 +38,12 @@ namespace MediaBrowser.Providers.Savers
|
|||
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
|
||||
public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
|
||||
{
|
||||
var locationType = item.LocationType;
|
||||
if (locationType == LocationType.Remote || locationType == LocationType.Virtual)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var folder = item as Folder;
|
||||
|
||||
if (folder == null)
|
||||
|
|
|
@ -7,6 +7,7 @@ using System.IO;
|
|||
using System.Security;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
namespace MediaBrowser.Providers.Savers
|
||||
{
|
||||
|
@ -35,6 +36,12 @@ namespace MediaBrowser.Providers.Savers
|
|||
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
|
||||
public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
|
||||
{
|
||||
var locationType = item.LocationType;
|
||||
if (locationType == LocationType.Remote || locationType == LocationType.Virtual)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var wasMetadataEdited = (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit;
|
||||
var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
@ -40,6 +39,12 @@ namespace MediaBrowser.Providers.Savers
|
|||
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
|
||||
public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
|
||||
{
|
||||
var locationType = item.LocationType;
|
||||
if (locationType == LocationType.Remote || locationType == LocationType.Virtual)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var wasMetadataEdited = (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit;
|
||||
var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
|
@ -11,6 +12,7 @@ using System.Security;
|
|||
using System.Text;
|
||||
using System.Threading;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
namespace MediaBrowser.Providers.Savers
|
||||
{
|
||||
|
@ -44,6 +46,12 @@ namespace MediaBrowser.Providers.Savers
|
|||
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
|
||||
public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
|
||||
{
|
||||
var locationType = item.LocationType;
|
||||
if (locationType == LocationType.Remote || locationType == LocationType.Virtual)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var wasMetadataEdited = (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit;
|
||||
var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ using System.IO;
|
|||
using System.Security;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
namespace MediaBrowser.Providers.Savers
|
||||
{
|
||||
|
@ -30,6 +31,12 @@ namespace MediaBrowser.Providers.Savers
|
|||
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
|
||||
public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
|
||||
{
|
||||
var locationType = item.LocationType;
|
||||
if (locationType == LocationType.Remote || locationType == LocationType.Virtual)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var wasMetadataEdited = (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit;
|
||||
var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
namespace MediaBrowser.Providers.Savers
|
||||
{
|
||||
|
@ -35,6 +36,12 @@ namespace MediaBrowser.Providers.Savers
|
|||
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
|
||||
public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
|
||||
{
|
||||
var locationType = item.LocationType;
|
||||
if (locationType == LocationType.Remote || locationType == LocationType.Virtual)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var wasMetadataEdited = (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit;
|
||||
var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
@ -37,6 +36,12 @@ namespace MediaBrowser.Providers.Savers
|
|||
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
|
||||
public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
|
||||
{
|
||||
var locationType = item.LocationType;
|
||||
if (locationType == LocationType.Remote || locationType == LocationType.Virtual)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var wasMetadataEdited = (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit;
|
||||
var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;
|
||||
|
||||
|
|
|
@ -33,10 +33,5 @@ namespace MediaBrowser.Providers.Studios
|
|||
{
|
||||
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
|
||||
}
|
||||
|
||||
protected override Task SaveItem(Studio item, ItemUpdateType reason, CancellationToken cancellationToken)
|
||||
{
|
||||
return _libraryManager.UpdateItem(item, reason, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,14 +2,12 @@
|
|||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace MediaBrowser.Providers.TV
|
||||
{
|
||||
public class EpisodeLocalImageProvider : IImageFileProvider
|
||||
public class EpisodeLocalLocalImageProvider : ILocalImageFileProvider
|
||||
{
|
||||
public string Name
|
||||
{
|
||||
|
@ -22,38 +20,47 @@ namespace MediaBrowser.Providers.TV
|
|||
}
|
||||
|
||||
public List<LocalImageInfo> GetImages(IHasImages item)
|
||||
{
|
||||
var file = GetFile(item);
|
||||
|
||||
var list = new List<LocalImageInfo>();
|
||||
|
||||
if (file != null)
|
||||
{
|
||||
list.Add(new LocalImageInfo
|
||||
{
|
||||
FileInfo = file,
|
||||
Type = ImageType.Primary
|
||||
});
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private FileInfo GetFile(IHasImages item)
|
||||
{
|
||||
var parentPath = Path.GetDirectoryName(item.Path);
|
||||
|
||||
var nameWithoutExtension = Path.GetFileNameWithoutExtension(item.Path);
|
||||
var thumbName = nameWithoutExtension + "-thumb";
|
||||
|
||||
return new DirectoryInfo(parentPath).EnumerateFiles("*", SearchOption.AllDirectories)
|
||||
.Where(i =>
|
||||
{
|
||||
if (BaseItem.SupportedImageExtensions.Contains(i.Extension))
|
||||
{
|
||||
var currentNameWithoutExtension = Path.GetFileNameWithoutExtension(i.Name);
|
||||
var path = Path.Combine(parentPath, thumbName + ".jpg");
|
||||
var fileInfo = new FileInfo(path);
|
||||
|
||||
if (string.Equals(nameWithoutExtension, currentNameWithoutExtension, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (fileInfo.Exists)
|
||||
{
|
||||
return fileInfo;
|
||||
}
|
||||
|
||||
if (string.Equals(thumbName, currentNameWithoutExtension, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
path = Path.Combine(parentPath, "metadata", nameWithoutExtension + ".jpg");
|
||||
fileInfo = new FileInfo(path);
|
||||
|
||||
return false;
|
||||
})
|
||||
.Select(i => new LocalImageInfo
|
||||
{
|
||||
FileInfo = i,
|
||||
Type = ImageType.Primary
|
||||
})
|
||||
.ToList();
|
||||
if (fileInfo.Exists)
|
||||
{
|
||||
return fileInfo;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,11 +71,6 @@ namespace MediaBrowser.Providers.TV
|
|||
}
|
||||
}
|
||||
|
||||
protected override Task SaveItem(Episode item, ItemUpdateType reason, CancellationToken cancellationToken)
|
||||
{
|
||||
return _libraryManager.UpdateItem(item, reason, cancellationToken);
|
||||
}
|
||||
|
||||
protected override ItemUpdateType BeforeMetadataRefresh(Episode item)
|
||||
{
|
||||
var updateType = base.BeforeMetadataRefresh(item);
|
||||
|
|
|
@ -35,11 +35,6 @@ namespace MediaBrowser.Providers.TV
|
|||
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
|
||||
}
|
||||
|
||||
protected override Task SaveItem(Season item, ItemUpdateType reason, CancellationToken cancellationToken)
|
||||
{
|
||||
return _libraryManager.UpdateItem(item, reason, cancellationToken);
|
||||
}
|
||||
|
||||
protected override ItemUpdateType BeforeMetadataRefresh(Season item)
|
||||
{
|
||||
var updateType = base.BeforeMetadataRefresh(item);
|
||||
|
|
|
@ -36,11 +36,6 @@ namespace MediaBrowser.Providers.TV
|
|||
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
|
||||
}
|
||||
|
||||
protected override Task SaveItem(Series item, ItemUpdateType reason, CancellationToken cancellationToken)
|
||||
{
|
||||
return _libraryManager.UpdateItem(item, reason, cancellationToken);
|
||||
}
|
||||
|
||||
protected override ItemUpdateType BeforeSave(Series item)
|
||||
{
|
||||
var updateType = base.BeforeSave(item);
|
||||
|
|
|
@ -194,6 +194,11 @@ namespace MediaBrowser.Providers.TV
|
|||
|
||||
public bool HasChanged(IHasMetadata item, DateTime date)
|
||||
{
|
||||
if (!_config.Configuration.EnableTvDbUpdates && item.LocationType != LocationType.Virtual)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!item.HasImage(ImageType.Primary))
|
||||
{
|
||||
var episode = (Episode)item;
|
||||
|
@ -211,6 +216,7 @@ namespace MediaBrowser.Providers.TV
|
|||
return files.Any(i => _fileSystem.GetLastWriteTimeUtc(i) > date);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,8 @@
|
|||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Net;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
@ -16,7 +14,6 @@ using System.Text.RegularExpressions;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
using PersonInfo = MediaBrowser.Controller.Entities.PersonInfo;
|
||||
|
||||
namespace MediaBrowser.Providers.TV
|
||||
{
|
||||
|
@ -71,7 +68,7 @@ namespace MediaBrowser.Providers.TV
|
|||
|
||||
public bool HasChanged(IHasMetadata item, DateTime date)
|
||||
{
|
||||
if (!_config.Configuration.EnableTvDbUpdates)
|
||||
if (!_config.Configuration.EnableTvDbUpdates && item.LocationType != LocationType.Virtual)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -423,28 +420,6 @@ namespace MediaBrowser.Providers.TV
|
|||
break;
|
||||
}
|
||||
|
||||
case "filename":
|
||||
{
|
||||
if (string.IsNullOrEmpty(item.PrimaryImagePath))
|
||||
{
|
||||
var val = reader.ReadElementContentAsString();
|
||||
if (!string.IsNullOrWhiteSpace(val))
|
||||
{
|
||||
try
|
||||
{
|
||||
var url = TVUtils.BannerUrl + val;
|
||||
|
||||
//await _providerManager.SaveImage(item, url, TvdbSeriesProvider.Current.TvDbResourcePool, ImageType.Primary, null, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
status = ProviderRefreshStatus.CompletedWithErrors;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case "Overview":
|
||||
{
|
||||
if (!item.LockedFields.Contains(MetadataFields.Overview))
|
||||
|
|
|
@ -342,6 +342,11 @@ namespace MediaBrowser.Providers.TV
|
|||
|
||||
public bool HasChanged(IHasMetadata item, DateTime date)
|
||||
{
|
||||
if (!_config.Configuration.EnableTvDbUpdates && item.LocationType != LocationType.Virtual)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var season = (Season)item;
|
||||
var series = season.Series;
|
||||
|
||||
|
|
|
@ -339,6 +339,11 @@ namespace MediaBrowser.Providers.TV
|
|||
|
||||
public bool HasChanged(IHasMetadata item, DateTime date)
|
||||
{
|
||||
if (!_config.Configuration.EnableTvDbUpdates)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var tvdbId = item.GetProviderId(MetadataProviders.Tvdb);
|
||||
|
||||
if (!String.IsNullOrEmpty(tvdbId))
|
||||
|
|
|
@ -19,11 +19,10 @@ using System.Text;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
using PersonInfo = MediaBrowser.Controller.Entities.PersonInfo;
|
||||
|
||||
namespace MediaBrowser.Providers.TV
|
||||
{
|
||||
public class TvdbSeriesProvider : IRemoteMetadataProvider<Series, SeriesInfo>, IHasChangeMonitor
|
||||
public class TvdbSeriesProvider : IRemoteMetadataProvider<Series, SeriesInfo>
|
||||
{
|
||||
internal readonly SemaphoreSlim TvDbResourcePool = new SemaphoreSlim(2, 2);
|
||||
internal static TvdbSeriesProvider Current { get; private set; }
|
||||
|
|
|
@ -34,10 +34,5 @@ namespace MediaBrowser.Providers.Users
|
|||
{
|
||||
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
|
||||
}
|
||||
|
||||
protected override Task SaveItem(User item, ItemUpdateType reason, CancellationToken cancellationToken)
|
||||
{
|
||||
return _userManager.UpdateUser(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,11 +35,6 @@ namespace MediaBrowser.Providers.Videos
|
|||
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
|
||||
}
|
||||
|
||||
protected override Task SaveItem(Video item, ItemUpdateType reason, CancellationToken cancellationToken)
|
||||
{
|
||||
return _libraryManager.UpdateItem(item, reason, cancellationToken);
|
||||
}
|
||||
|
||||
public override int Order
|
||||
{
|
||||
get
|
||||
|
|
|
@ -34,10 +34,5 @@ namespace MediaBrowser.Providers.Years
|
|||
{
|
||||
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
|
||||
}
|
||||
|
||||
protected override Task SaveItem(Year item, ItemUpdateType reason, CancellationToken cancellationToken)
|
||||
{
|
||||
return _libraryManager.UpdateItem(item, reason, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Resolvers;
|
||||
|
|
|
@ -192,6 +192,7 @@
|
|||
<Compile Include="Roku\RokuControllerFactory.cs" />
|
||||
<Compile Include="ScheduledTasks\PeopleValidationTask.cs" />
|
||||
<Compile Include="ScheduledTasks\ChapterImagesTask.cs" />
|
||||
<Compile Include="ScheduledTasks\RefreshIntrosTask.cs" />
|
||||
<Compile Include="ScheduledTasks\RefreshMediaLibraryTask.cs" />
|
||||
<Compile Include="ServerApplicationPaths.cs" />
|
||||
<Compile Include="ServerManager\ServerManager.cs" />
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
using System.IO;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -17,8 +16,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private IDbCommand _deleteInfosCommand;
|
||||
private IDbCommand _saveInfoCommand;
|
||||
private IDbCommand _saveStatusCommand;
|
||||
private readonly IApplicationPaths _appPaths;
|
||||
|
||||
|
@ -48,16 +45,13 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
/// <returns>Task.</returns>
|
||||
public async Task Initialize()
|
||||
{
|
||||
var dbFile = Path.Combine(_appPaths.DataPath, "providerinfo.db");
|
||||
var dbFile = Path.Combine(_appPaths.DataPath, "refreshinfo.db");
|
||||
|
||||
_connection = await SqliteExtensions.ConnectToDb(dbFile, _logger).ConfigureAwait(false);
|
||||
|
||||
string[] queries = {
|
||||
|
||||
"create table if not exists providerinfos (ItemId GUID, ProviderId GUID, ProviderVersion TEXT, FileStamp GUID, LastRefreshStatus TEXT, LastRefreshed datetime, PRIMARY KEY (ItemId, ProviderId))",
|
||||
"create index if not exists idx_providerinfos on providerinfos(ItemId, ProviderId)",
|
||||
|
||||
"create table if not exists MetadataStatus (ItemId GUID PRIMARY KEY, DateLastMetadataRefresh datetime, DateLastImagesRefresh datetime, LastStatus TEXT, LastErrorMessage TEXT, MetadataProvidersRefreshed TEXT, ImageProvidersRefreshed TEXT)",
|
||||
"create table if not exists MetadataStatus (ItemId GUID PRIMARY KEY, ItemName TEXT, SeriesName TEXT, DateLastMetadataRefresh datetime, DateLastImagesRefresh datetime, LastStatus TEXT, LastErrorMessage TEXT, MetadataProvidersRefreshed TEXT, ImageProvidersRefreshed TEXT)",
|
||||
"create index if not exists idx_MetadataStatus on MetadataStatus(ItemId)",
|
||||
|
||||
//pragmas
|
||||
|
@ -73,21 +67,11 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
_shrinkMemoryTimer = new SqliteShrinkMemoryTimer(_connection, _writeLock, _logger);
|
||||
}
|
||||
|
||||
private static readonly string[] SaveHistoryColumns =
|
||||
{
|
||||
"ItemId",
|
||||
"ProviderId",
|
||||
"ProviderVersion",
|
||||
"FileStamp",
|
||||
"LastRefreshStatus",
|
||||
"LastRefreshed"
|
||||
};
|
||||
|
||||
private readonly string[] _historySelectColumns = SaveHistoryColumns.Skip(1).ToArray();
|
||||
|
||||
private static readonly string[] StatusColumns =
|
||||
{
|
||||
"ItemId",
|
||||
"ItemName",
|
||||
"SeriesName",
|
||||
"DateLastMetadataRefresh",
|
||||
"DateLastImagesRefresh",
|
||||
"LastStatus",
|
||||
|
@ -106,21 +90,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
/// </summary>
|
||||
private void PrepareStatements()
|
||||
{
|
||||
_deleteInfosCommand = _connection.CreateCommand();
|
||||
_deleteInfosCommand.CommandText = "delete from providerinfos where ItemId=@ItemId";
|
||||
_deleteInfosCommand.Parameters.Add(_deleteInfosCommand, "@ItemId");
|
||||
|
||||
_saveInfoCommand = _connection.CreateCommand();
|
||||
|
||||
_saveInfoCommand.CommandText = string.Format("replace into providerinfos ({0}) values ({1})",
|
||||
string.Join(",", SaveHistoryColumns),
|
||||
string.Join(",", SaveHistoryColumns.Select(i => "@" + i).ToArray()));
|
||||
|
||||
foreach (var col in SaveHistoryColumns)
|
||||
{
|
||||
_saveInfoCommand.Parameters.Add(_saveInfoCommand, "@" + col);
|
||||
}
|
||||
|
||||
_saveStatusCommand = _connection.CreateCommand();
|
||||
|
||||
_saveStatusCommand.CommandText = string.Format("replace into MetadataStatus ({0}) values ({1})",
|
||||
|
@ -133,132 +102,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
}
|
||||
}
|
||||
|
||||
public IEnumerable<BaseProviderInfo> GetProviderHistory(Guid itemId)
|
||||
{
|
||||
if (itemId == Guid.Empty)
|
||||
{
|
||||
throw new ArgumentNullException("itemId");
|
||||
}
|
||||
|
||||
using (var cmd = _connection.CreateCommand())
|
||||
{
|
||||
var cmdText = "select " + string.Join(",", _historySelectColumns) + " from providerinfos 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))
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
yield return GetBaseProviderInfo(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the base provider information.
|
||||
/// </summary>
|
||||
/// <param name="reader">The reader.</param>
|
||||
/// <returns>BaseProviderInfo.</returns>
|
||||
private BaseProviderInfo GetBaseProviderInfo(IDataReader reader)
|
||||
{
|
||||
var item = new BaseProviderInfo
|
||||
{
|
||||
ProviderId = reader.GetGuid(0)
|
||||
};
|
||||
|
||||
if (!reader.IsDBNull(1))
|
||||
{
|
||||
item.ProviderVersion = reader.GetString(1);
|
||||
}
|
||||
|
||||
item.FileStamp = reader.GetGuid(2);
|
||||
item.LastRefreshStatus = (ProviderRefreshStatus)Enum.Parse(typeof(ProviderRefreshStatus), reader.GetString(3), true);
|
||||
item.LastRefreshed = reader.GetDateTime(4).ToUniversalTime();
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public async Task SaveProviderHistory(Guid id, IEnumerable<BaseProviderInfo> infos, CancellationToken cancellationToken)
|
||||
{
|
||||
if (id == Guid.Empty)
|
||||
{
|
||||
throw new ArgumentNullException("id");
|
||||
}
|
||||
|
||||
if (infos == null)
|
||||
{
|
||||
throw new ArgumentNullException("infos");
|
||||
}
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
await _writeLock.WaitAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
IDbTransaction transaction = null;
|
||||
|
||||
try
|
||||
{
|
||||
transaction = _connection.BeginTransaction();
|
||||
|
||||
_deleteInfosCommand.GetParameter(0).Value = id;
|
||||
|
||||
_deleteInfosCommand.Transaction = transaction;
|
||||
|
||||
_deleteInfosCommand.ExecuteNonQuery();
|
||||
|
||||
foreach (var stream in infos)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
_saveInfoCommand.GetParameter(0).Value = id;
|
||||
_saveInfoCommand.GetParameter(1).Value = stream.ProviderId;
|
||||
_saveInfoCommand.GetParameter(2).Value = stream.ProviderVersion;
|
||||
_saveInfoCommand.GetParameter(3).Value = stream.FileStamp;
|
||||
_saveInfoCommand.GetParameter(4).Value = stream.LastRefreshStatus.ToString();
|
||||
_saveInfoCommand.GetParameter(5).Value = stream.LastRefreshed;
|
||||
|
||||
_saveInfoCommand.Transaction = transaction;
|
||||
_saveInfoCommand.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();
|
||||
}
|
||||
}
|
||||
|
||||
public MetadataStatus GetMetadataStatus(Guid itemId)
|
||||
{
|
||||
if (itemId == Guid.Empty)
|
||||
|
@ -296,32 +139,42 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
|
||||
if (!reader.IsDBNull(1))
|
||||
{
|
||||
result.DateLastMetadataRefresh = reader.GetDateTime(1).ToUniversalTime();
|
||||
result.ItemName = reader.GetString(1);
|
||||
}
|
||||
|
||||
if (!reader.IsDBNull(2))
|
||||
{
|
||||
result.DateLastImagesRefresh = reader.GetDateTime(2).ToUniversalTime();
|
||||
result.SeriesName = reader.GetString(2);
|
||||
}
|
||||
|
||||
if (!reader.IsDBNull(3))
|
||||
{
|
||||
result.LastStatus = (ProviderRefreshStatus)Enum.Parse(typeof(ProviderRefreshStatus), reader.GetString(3), true);
|
||||
result.DateLastMetadataRefresh = reader.GetDateTime(3).ToUniversalTime();
|
||||
}
|
||||
|
||||
if (!reader.IsDBNull(4))
|
||||
{
|
||||
result.LastErrorMessage = reader.GetString(4);
|
||||
result.DateLastImagesRefresh = reader.GetDateTime(4).ToUniversalTime();
|
||||
}
|
||||
|
||||
if (!reader.IsDBNull(5))
|
||||
{
|
||||
result.MetadataProvidersRefreshed = reader.GetString(5).Split('|').Where(i => !string.IsNullOrEmpty(i)).Select(i => new Guid(i)).ToList();
|
||||
result.LastStatus = (ProviderRefreshStatus)Enum.Parse(typeof(ProviderRefreshStatus), reader.GetString(5), true);
|
||||
}
|
||||
|
||||
if (!reader.IsDBNull(6))
|
||||
{
|
||||
result.ImageProvidersRefreshed = reader.GetString(6).Split('|').Where(i => !string.IsNullOrEmpty(i)).Select(i => new Guid(i)).ToList();
|
||||
result.LastErrorMessage = reader.GetString(6);
|
||||
}
|
||||
|
||||
if (!reader.IsDBNull(7))
|
||||
{
|
||||
result.MetadataProvidersRefreshed = reader.GetString(7).Split('|').Where(i => !string.IsNullOrEmpty(i)).Select(i => new Guid(i)).ToList();
|
||||
}
|
||||
|
||||
if (!reader.IsDBNull(8))
|
||||
{
|
||||
result.ImageProvidersRefreshed = reader.GetString(8).Split('|').Where(i => !string.IsNullOrEmpty(i)).Select(i => new Guid(i)).ToList();
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -345,12 +198,14 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
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.LastStatus.ToString();
|
||||
_saveStatusCommand.GetParameter(4).Value = status.LastErrorMessage;
|
||||
_saveStatusCommand.GetParameter(5).Value = string.Join("|", status.MetadataProvidersRefreshed.ToArray());
|
||||
_saveStatusCommand.GetParameter(6).Value = string.Join("|", status.ImageProvidersRefreshed.ToArray());
|
||||
_saveStatusCommand.GetParameter(1).Value = status.ItemName;
|
||||
_saveStatusCommand.GetParameter(2).Value = status.SeriesName;
|
||||
_saveStatusCommand.GetParameter(3).Value = status.DateLastMetadataRefresh;
|
||||
_saveStatusCommand.GetParameter(4).Value = status.DateLastImagesRefresh;
|
||||
_saveStatusCommand.GetParameter(5).Value = status.LastStatus.ToString();
|
||||
_saveStatusCommand.GetParameter(6).Value = status.LastErrorMessage;
|
||||
_saveStatusCommand.GetParameter(7).Value = string.Join("|", status.MetadataProvidersRefreshed.ToArray());
|
||||
_saveStatusCommand.GetParameter(8).Value = string.Join("|", status.ImageProvidersRefreshed.ToArray());
|
||||
|
||||
_saveStatusCommand.Transaction = transaction;
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Controller.IO;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
|
@ -7,7 +6,7 @@ using System.Linq;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Providers
|
||||
namespace MediaBrowser.Server.Implementations.ScheduledTasks
|
||||
{
|
||||
/// <summary>
|
||||
/// Class RefreshIntrosTask
|
||||
|
@ -24,12 +23,13 @@ namespace MediaBrowser.Providers
|
|||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IFileSystem _fileSystem;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RefreshIntrosTask"/> class.
|
||||
/// Initializes a new instance of the <see cref="RefreshIntrosTask" /> class.
|
||||
/// </summary>
|
||||
/// <param name="libraryManager">The library manager.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <param name="fileSystem">The file system.</param>
|
||||
public RefreshIntrosTask(ILibraryManager libraryManager, ILogger logger, IFileSystem fileSystem)
|
||||
{
|
||||
_libraryManager = libraryManager;
|
|
@ -1,4 +1,5 @@
|
|||
using MediaBrowser.Common.Implementations;
|
||||
using System;
|
||||
using MediaBrowser.Common.Implementations;
|
||||
using MediaBrowser.Controller;
|
||||
using System.IO;
|
||||
|
||||
|
@ -213,18 +214,6 @@ namespace MediaBrowser.Server.Implementations
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the images data path.
|
||||
/// </summary>
|
||||
/// <value>The images data path.</value>
|
||||
public string DownloadedImagesDataPath
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.Combine(DataPath, "remote-images");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the artists path.
|
||||
/// </summary>
|
||||
|
@ -249,5 +238,20 @@ namespace MediaBrowser.Server.Implementations
|
|||
return Path.Combine(ItemsByNamePath, "GameGenre");
|
||||
}
|
||||
}
|
||||
|
||||
public string InternalMetadataPath
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.Combine(DataPath, "metadata");
|
||||
}
|
||||
}
|
||||
|
||||
public string GetInternalMetadataPath(Guid id)
|
||||
{
|
||||
var idString = id.ToString("N");
|
||||
|
||||
return Path.Combine(InternalMetadataPath, idString.Substring(0, 2), idString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user