mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 03:26:07 +02:00
Improve support for daily episodes
This commit is contained in:
parent
ebffea0696
commit
8a3e52bc09
10 changed files with 731 additions and 621 deletions
|
@ -1779,7 +1779,8 @@ namespace MediaBrowser.Controller.Entities
|
||||||
ProviderIds = ProviderIds,
|
ProviderIds = ProviderIds,
|
||||||
IndexNumber = IndexNumber,
|
IndexNumber = IndexNumber,
|
||||||
ParentIndexNumber = ParentIndexNumber,
|
ParentIndexNumber = ParentIndexNumber,
|
||||||
Year = ProductionYear
|
Year = ProductionYear,
|
||||||
|
PremiereDate = PremiereDate
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ namespace MediaBrowser.Controller.Providers
|
||||||
public int? Year { get; set; }
|
public int? Year { get; set; }
|
||||||
public int? IndexNumber { get; set; }
|
public int? IndexNumber { get; set; }
|
||||||
public int? ParentIndexNumber { get; set; }
|
public int? ParentIndexNumber { get; set; }
|
||||||
|
public DateTime? PremiereDate { get; set; }
|
||||||
|
|
||||||
public ItemLookupInfo()
|
public ItemLookupInfo()
|
||||||
{
|
{
|
||||||
|
|
|
@ -170,4 +170,4 @@ namespace MediaBrowser.Providers.Folders
|
||||||
return GetSupportedImages(item).Any(i => !item.HasImage(i));
|
return GetSupportedImages(item).Any(i => !item.HasImage(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -359,12 +359,13 @@ namespace MediaBrowser.Providers.Manager
|
||||||
private void ClearImages(IHasImages item, ImageType type)
|
private void ClearImages(IHasImages item, ImageType type)
|
||||||
{
|
{
|
||||||
var deleted = false;
|
var deleted = false;
|
||||||
|
var deletedImages = new List<ItemImageInfo>();
|
||||||
|
|
||||||
foreach (var image in item.GetImages(type).ToList())
|
foreach (var image in item.GetImages(type).ToList())
|
||||||
{
|
{
|
||||||
if (!image.IsLocalFile)
|
if (!image.IsLocalFile)
|
||||||
{
|
{
|
||||||
// TODO: Need to get this image removed
|
deletedImages.Add(image);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,6 +385,11 @@ namespace MediaBrowser.Providers.Manager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (var image in deletedImages)
|
||||||
|
{
|
||||||
|
item.RemoveImage(image);
|
||||||
|
}
|
||||||
|
|
||||||
if (deleted)
|
if (deleted)
|
||||||
{
|
{
|
||||||
item.ValidateImages(new DirectoryService(_logger, _fileSystem));
|
item.ValidateImages(new DirectoryService(_logger, _fileSystem));
|
||||||
|
|
|
@ -97,7 +97,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
var itemImageProvider = new ItemImageProvider(Logger, ProviderManager, ServerConfigurationManager, FileSystem);
|
var itemImageProvider = new ItemImageProvider(Logger, ProviderManager, ServerConfigurationManager, FileSystem);
|
||||||
var localImagesFailed = false;
|
var localImagesFailed = false;
|
||||||
|
|
||||||
var allImageProviders = ((ProviderManager)ProviderManager).GetImageProviders(item).ToList();
|
var allImageProviders = ((ProviderManager)ProviderManager).GetImageProviders(item, refreshOptions).ToList();
|
||||||
|
|
||||||
// Start by validating images
|
// Start by validating images
|
||||||
try
|
try
|
||||||
|
|
|
@ -249,17 +249,17 @@ namespace MediaBrowser.Providers.Manager
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<IImageProvider> GetImageProviders(IHasImages item)
|
public IEnumerable<IImageProvider> GetImageProviders(IHasImages item, ImageRefreshOptions refreshOptions)
|
||||||
{
|
{
|
||||||
return GetImageProviders(item, GetMetadataOptions(item), false);
|
return GetImageProviders(item, GetMetadataOptions(item), refreshOptions, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<IImageProvider> GetImageProviders(IHasImages item, MetadataOptions options, bool includeDisabled)
|
private IEnumerable<IImageProvider> GetImageProviders(IHasImages item, MetadataOptions options, ImageRefreshOptions refreshOptions, bool includeDisabled)
|
||||||
{
|
{
|
||||||
// Avoid implicitly captured closure
|
// Avoid implicitly captured closure
|
||||||
var currentOptions = options;
|
var currentOptions = options;
|
||||||
|
|
||||||
return ImageProviders.Where(i => CanRefresh(i, item, options, includeDisabled))
|
return ImageProviders.Where(i => CanRefresh(i, item, options, refreshOptions, includeDisabled))
|
||||||
.OrderBy(i =>
|
.OrderBy(i =>
|
||||||
{
|
{
|
||||||
// See if there's a user-defined order
|
// See if there's a user-defined order
|
||||||
|
@ -315,7 +315,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
{
|
{
|
||||||
var options = GetMetadataOptions(item);
|
var options = GetMetadataOptions(item);
|
||||||
|
|
||||||
return GetImageProviders(item, options, includeDisabled).OfType<IRemoteImageProvider>();
|
return GetImageProviders(item, options, new ImageRefreshOptions(new DirectoryService(_fileSystem)), includeDisabled).OfType<IRemoteImageProvider>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool CanRefresh(IMetadataProvider provider, IHasMetadata item, MetadataOptions options, bool includeDisabled, bool checkIsOwnedItem)
|
private bool CanRefresh(IMetadataProvider provider, IHasMetadata item, MetadataOptions options, bool includeDisabled, bool checkIsOwnedItem)
|
||||||
|
@ -359,14 +359,17 @@ namespace MediaBrowser.Providers.Manager
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool CanRefresh(IImageProvider provider, IHasImages item, MetadataOptions options, bool includeDisabled)
|
private bool CanRefresh(IImageProvider provider, IHasImages item, MetadataOptions options, ImageRefreshOptions refreshOptions, bool includeDisabled)
|
||||||
{
|
{
|
||||||
if (!includeDisabled)
|
if (!includeDisabled)
|
||||||
{
|
{
|
||||||
// If locked only allow local providers
|
// If locked only allow local providers
|
||||||
if (item.IsLocked && !(provider is ILocalImageProvider))
|
if (item.IsLocked && !(provider is ILocalImageProvider))
|
||||||
{
|
{
|
||||||
return false;
|
if (refreshOptions.ImageRefreshMode != ImageRefreshMode.FullRefresh)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (provider is IRemoteImageProvider || provider is IDynamicImageProvider)
|
if (provider is IRemoteImageProvider || provider is IDynamicImageProvider)
|
||||||
|
@ -502,7 +505,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
ItemType = typeof(T).Name
|
ItemType = typeof(T).Name
|
||||||
};
|
};
|
||||||
|
|
||||||
var imageProviders = GetImageProviders(dummy, options, true).ToList();
|
var imageProviders = GetImageProviders(dummy, options, new ImageRefreshOptions(new DirectoryService(_fileSystem)), true).ToList();
|
||||||
|
|
||||||
AddMetadataPlugins(summary.Plugins, dummy, options);
|
AddMetadataPlugins(summary.Plugins, dummy, options);
|
||||||
AddImagePlugins(summary.Plugins, dummy, imageProviders);
|
AddImagePlugins(summary.Plugins, dummy, imageProviders);
|
||||||
|
|
|
@ -15,6 +15,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using CommonIO;
|
using CommonIO;
|
||||||
|
@ -130,6 +131,8 @@ namespace MediaBrowser.Providers.Subtitles
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
//var isText = MediaStream.IsTextFormat(response.Format);
|
||||||
|
|
||||||
using (var fs = _fileSystem.GetFileStream(savePath, FileMode.Create, FileAccess.Write, FileShare.Read, true))
|
using (var fs = _fileSystem.GetFileStream(savePath, FileMode.Create, FileAccess.Write, FileShare.Read, true))
|
||||||
{
|
{
|
||||||
await stream.CopyToAsync(fs).ConfigureAwait(false);
|
await stream.CopyToAsync(fs).ConfigureAwait(false);
|
||||||
|
|
|
@ -63,97 +63,89 @@ namespace MediaBrowser.Providers.TV
|
||||||
var seriesDataPath = TvdbSeriesProvider.GetSeriesDataPath(_config.ApplicationPaths, series.ProviderIds);
|
var seriesDataPath = TvdbSeriesProvider.GetSeriesDataPath(_config.ApplicationPaths, series.ProviderIds);
|
||||||
var indexOffset = TvdbSeriesProvider.GetSeriesOffset(series.ProviderIds) ?? 0;
|
var indexOffset = TvdbSeriesProvider.GetSeriesOffset(series.ProviderIds) ?? 0;
|
||||||
|
|
||||||
var files = TvdbEpisodeProvider.Current.GetEpisodeXmlFiles(episode.ParentIndexNumber + indexOffset, episode.IndexNumber, episode.IndexNumberEnd, seriesDataPath);
|
var nodes = TvdbEpisodeProvider.Current.GetEpisodeXmlNodes(seriesDataPath, episode.GetLookupInfo());
|
||||||
|
|
||||||
var result = files.Select(i => GetImageInfo(i, cancellationToken))
|
var result = nodes.Select(i => GetImageInfo(i, cancellationToken))
|
||||||
.Where(i => i != null);
|
.Where(i => i != null)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
return Task.FromResult(result);
|
return Task.FromResult<IEnumerable<RemoteImageInfo>>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Task.FromResult<IEnumerable<RemoteImageInfo>>(new RemoteImageInfo[] { });
|
return Task.FromResult<IEnumerable<RemoteImageInfo>>(new RemoteImageInfo[] { });
|
||||||
}
|
}
|
||||||
|
|
||||||
private RemoteImageInfo GetImageInfo(FileSystemMetadata xmlFile, CancellationToken cancellationToken)
|
private RemoteImageInfo GetImageInfo(XmlReader reader, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var height = 225;
|
var height = 225;
|
||||||
var width = 400;
|
var width = 400;
|
||||||
var url = string.Empty;
|
var url = string.Empty;
|
||||||
|
|
||||||
using (var streamReader = new StreamReader(xmlFile.FullName, Encoding.UTF8))
|
// Use XmlReader for best performance
|
||||||
{
|
using (reader)
|
||||||
// Use XmlReader for best performance
|
{
|
||||||
using (var reader = XmlReader.Create(streamReader, new XmlReaderSettings
|
reader.MoveToContent();
|
||||||
{
|
|
||||||
CheckCharacters = false,
|
|
||||||
IgnoreProcessingInstructions = true,
|
|
||||||
IgnoreComments = true,
|
|
||||||
ValidationType = ValidationType.None
|
|
||||||
}))
|
|
||||||
{
|
|
||||||
reader.MoveToContent();
|
|
||||||
|
|
||||||
// Loop through each element
|
// Loop through each element
|
||||||
while (reader.Read())
|
while (reader.Read())
|
||||||
{
|
{
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
if (reader.NodeType == XmlNodeType.Element)
|
if (reader.NodeType == XmlNodeType.Element)
|
||||||
{
|
{
|
||||||
switch (reader.Name)
|
switch (reader.Name)
|
||||||
{
|
{
|
||||||
case "thumb_width":
|
case "thumb_width":
|
||||||
{
|
{
|
||||||
var val = reader.ReadElementContentAsString();
|
var val = reader.ReadElementContentAsString();
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(val))
|
if (!string.IsNullOrWhiteSpace(val))
|
||||||
{
|
{
|
||||||
int rval;
|
int rval;
|
||||||
|
|
||||||
// int.TryParse is local aware, so it can be probamatic, force us culture
|
// int.TryParse is local aware, so it can be probamatic, force us culture
|
||||||
if (int.TryParse(val, NumberStyles.Integer, _usCulture, out rval))
|
if (int.TryParse(val, NumberStyles.Integer, _usCulture, out rval))
|
||||||
{
|
{
|
||||||
width = rval;
|
width = rval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "thumb_height":
|
case "thumb_height":
|
||||||
{
|
{
|
||||||
var val = reader.ReadElementContentAsString();
|
var val = reader.ReadElementContentAsString();
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(val))
|
if (!string.IsNullOrWhiteSpace(val))
|
||||||
{
|
{
|
||||||
int rval;
|
int rval;
|
||||||
|
|
||||||
// int.TryParse is local aware, so it can be probamatic, force us culture
|
// int.TryParse is local aware, so it can be probamatic, force us culture
|
||||||
if (int.TryParse(val, NumberStyles.Integer, _usCulture, out rval))
|
if (int.TryParse(val, NumberStyles.Integer, _usCulture, out rval))
|
||||||
{
|
{
|
||||||
height = rval;
|
height = rval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "filename":
|
case "filename":
|
||||||
{
|
{
|
||||||
var val = reader.ReadElementContentAsString();
|
var val = reader.ReadElementContentAsString();
|
||||||
if (!string.IsNullOrWhiteSpace(val))
|
if (!string.IsNullOrWhiteSpace(val))
|
||||||
{
|
{
|
||||||
url = TVUtils.BannerUrl + val;
|
url = TVUtils.BannerUrl + val;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
reader.Skip();
|
reader.Skip();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(url))
|
if (string.IsNullOrEmpty(url))
|
||||||
{
|
{
|
||||||
|
@ -205,11 +197,9 @@ namespace MediaBrowser.Providers.TV
|
||||||
if (series != null && TvdbSeriesProvider.IsValidSeries(series.ProviderIds))
|
if (series != null && TvdbSeriesProvider.IsValidSeries(series.ProviderIds))
|
||||||
{
|
{
|
||||||
// Process images
|
// Process images
|
||||||
var seriesDataPath = TvdbSeriesProvider.GetSeriesDataPath(_config.ApplicationPaths, series.ProviderIds);
|
var seriesXmlPath = TvdbSeriesProvider.Current.GetSeriesXmlPath(series.ProviderIds, series.GetPreferredMetadataLanguage());
|
||||||
|
|
||||||
var files = TvdbEpisodeProvider.Current.GetEpisodeXmlFiles(episode.ParentIndexNumber, episode.IndexNumber, episode.IndexNumberEnd, seriesDataPath);
|
return _fileSystem.GetLastWriteTimeUtc(seriesXmlPath) > date;
|
||||||
|
|
||||||
return files.Any(i => _fileSystem.GetLastWriteTimeUtc(i) > date);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -161,9 +161,7 @@ namespace MediaBrowser.Providers.TV
|
||||||
|
|
||||||
var seriesDataPath = GetSeriesDataPath(_config.ApplicationPaths, seriesProviderIds);
|
var seriesDataPath = GetSeriesDataPath(_config.ApplicationPaths, seriesProviderIds);
|
||||||
|
|
||||||
var seriesXmlFilename = metadataLanguage.ToLower() + ".xml";
|
var seriesXmlPath = GetSeriesXmlPath (seriesProviderIds, metadataLanguage);
|
||||||
|
|
||||||
var seriesXmlPath = Path.Combine(seriesDataPath, seriesXmlFilename);
|
|
||||||
var actorsXmlPath = Path.Combine(seriesDataPath, "actors.xml");
|
var actorsXmlPath = Path.Combine(seriesDataPath, "actors.xml");
|
||||||
|
|
||||||
FetchSeriesInfo(series, seriesXmlPath, cancellationToken);
|
FetchSeriesInfo(series, seriesXmlPath, cancellationToken);
|
||||||
|
@ -1278,6 +1276,15 @@ namespace MediaBrowser.Providers.TV
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetSeriesXmlPath(Dictionary<string, string> seriesProviderIds, string language)
|
||||||
|
{
|
||||||
|
var seriesDataPath = GetSeriesDataPath(_config.ApplicationPaths, seriesProviderIds);
|
||||||
|
|
||||||
|
var seriesXmlFilename = language.ToLower() + ".xml";
|
||||||
|
|
||||||
|
return Path.Combine (seriesDataPath, seriesXmlFilename);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the series data path.
|
/// Gets the series data path.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in a new issue