fixes #1145 - Improve support for daily episodes

This commit is contained in:
Luke 2015-12-25 16:18:27 -05:00
parent 2841eba202
commit da5fc95612
6 changed files with 645 additions and 580 deletions

View File

@ -1835,7 +1835,8 @@ namespace MediaBrowser.Controller.Entities
ProviderIds = ProviderIds,
IndexNumber = IndexNumber,
ParentIndexNumber = ParentIndexNumber,
Year = ProductionYear
Year = ProductionYear,
PremiereDate = PremiereDate
};
}

View File

@ -33,6 +33,7 @@ namespace MediaBrowser.Controller.Providers
public int? Year { get; set; }
public int? IndexNumber { get; set; }
public int? ParentIndexNumber { get; set; }
public DateTime? PremiereDate { get; set; }
public ItemLookupInfo()
{

View File

@ -63,97 +63,89 @@ namespace MediaBrowser.Providers.TV
var seriesDataPath = TvdbSeriesProvider.GetSeriesDataPath(_config.ApplicationPaths, series.ProviderIds);
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))
.Where(i => i != null);
var result = nodes.Select(i => GetImageInfo(i, cancellationToken))
.Where(i => i != null)
.ToList();
return Task.FromResult(result);
return Task.FromResult<IEnumerable<RemoteImageInfo>>(result);
}
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 width = 400;
var url = string.Empty;
using (var streamReader = new StreamReader(xmlFile.FullName, Encoding.UTF8))
{
// Use XmlReader for best performance
using (var reader = XmlReader.Create(streamReader, new XmlReaderSettings
{
CheckCharacters = false,
IgnoreProcessingInstructions = true,
IgnoreComments = true,
ValidationType = ValidationType.None
}))
{
reader.MoveToContent();
// Use XmlReader for best performance
using (reader)
{
reader.MoveToContent();
// Loop through each element
while (reader.Read())
{
cancellationToken.ThrowIfCancellationRequested();
// Loop through each element
while (reader.Read())
{
cancellationToken.ThrowIfCancellationRequested();
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case "thumb_width":
{
var val = reader.ReadElementContentAsString();
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case "thumb_width":
{
var val = reader.ReadElementContentAsString();
if (!string.IsNullOrWhiteSpace(val))
{
int rval;
if (!string.IsNullOrWhiteSpace(val))
{
int rval;
// int.TryParse is local aware, so it can be probamatic, force us culture
if (int.TryParse(val, NumberStyles.Integer, _usCulture, out rval))
{
width = rval;
}
}
break;
}
// int.TryParse is local aware, so it can be probamatic, force us culture
if (int.TryParse(val, NumberStyles.Integer, _usCulture, out rval))
{
width = rval;
}
}
break;
}
case "thumb_height":
{
var val = reader.ReadElementContentAsString();
case "thumb_height":
{
var val = reader.ReadElementContentAsString();
if (!string.IsNullOrWhiteSpace(val))
{
int rval;
if (!string.IsNullOrWhiteSpace(val))
{
int rval;
// int.TryParse is local aware, so it can be probamatic, force us culture
if (int.TryParse(val, NumberStyles.Integer, _usCulture, out rval))
{
height = rval;
}
}
break;
}
// int.TryParse is local aware, so it can be probamatic, force us culture
if (int.TryParse(val, NumberStyles.Integer, _usCulture, out rval))
{
height = rval;
}
}
break;
}
case "filename":
{
var val = reader.ReadElementContentAsString();
if (!string.IsNullOrWhiteSpace(val))
{
url = TVUtils.BannerUrl + val;
}
break;
}
case "filename":
{
var val = reader.ReadElementContentAsString();
if (!string.IsNullOrWhiteSpace(val))
{
url = TVUtils.BannerUrl + val;
}
break;
}
default:
reader.Skip();
break;
}
}
}
}
}
default:
reader.Skip();
break;
}
}
}
}
if (string.IsNullOrEmpty(url))
{
@ -205,11 +197,9 @@ namespace MediaBrowser.Providers.TV
if (series != null && TvdbSeriesProvider.IsValidSeries(series.ProviderIds))
{
// 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 files.Any(i => _fileSystem.GetLastWriteTimeUtc(i) > date);
return _fileSystem.GetLastWriteTimeUtc(seriesXmlPath) > date;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -161,9 +161,7 @@ namespace MediaBrowser.Providers.TV
var seriesDataPath = GetSeriesDataPath(_config.ApplicationPaths, seriesProviderIds);
var seriesXmlFilename = metadataLanguage.ToLower() + ".xml";
var seriesXmlPath = Path.Combine(seriesDataPath, seriesXmlFilename);
var seriesXmlPath = GetSeriesXmlPath (seriesProviderIds, metadataLanguage);
var actorsXmlPath = Path.Combine(seriesDataPath, "actors.xml");
FetchSeriesInfo(series, seriesXmlPath, cancellationToken);
@ -1278,6 +1276,15 @@ namespace MediaBrowser.Providers.TV
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>
/// Gets the series data path.
/// </summary>

View File

@ -1067,9 +1067,6 @@
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\bower_components\emby-apiclient\credentials.js">
<Link>Resources\dashboard-ui\bower_components\emby-apiclient\credentials.js</Link>
</BundleResource>
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\bower_components\emby-apiclient\deferred.js">
<Link>Resources\dashboard-ui\bower_components\emby-apiclient\deferred.js</Link>
</BundleResource>
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\bower_components\emby-apiclient\events.js">
<Link>Resources\dashboard-ui\bower_components\emby-apiclient\events.js</Link>
</BundleResource>
@ -1079,9 +1076,6 @@
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\bower_components\emby-apiclient\localassetmanager.js">
<Link>Resources\dashboard-ui\bower_components\emby-apiclient\localassetmanager.js</Link>
</BundleResource>
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\bower_components\emby-apiclient\logger.js">
<Link>Resources\dashboard-ui\bower_components\emby-apiclient\logger.js</Link>
</BundleResource>
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\bower_components\emby-apiclient\serverdiscovery.js">
<Link>Resources\dashboard-ui\bower_components\emby-apiclient\serverdiscovery.js</Link>
</BundleResource>
@ -1109,6 +1103,21 @@
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\bower_components\emby-icons\emby-icons.html">
<Link>Resources\dashboard-ui\bower_components\emby-icons\emby-icons.html</Link>
</BundleResource>
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\bower_components\emby-webcomponents\.bower.json">
<Link>Resources\dashboard-ui\bower_components\emby-webcomponents\.bower.json</Link>
</BundleResource>
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\bower_components\emby-webcomponents\LICENSE">
<Link>Resources\dashboard-ui\bower_components\emby-webcomponents\LICENSE</Link>
</BundleResource>
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\bower_components\emby-webcomponents\README.md">
<Link>Resources\dashboard-ui\bower_components\emby-webcomponents\README.md</Link>
</BundleResource>
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\bower_components\emby-webcomponents\bower.json">
<Link>Resources\dashboard-ui\bower_components\emby-webcomponents\bower.json</Link>
</BundleResource>
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\bower_components\emby-webcomponents\requirehtml.js">
<Link>Resources\dashboard-ui\bower_components\emby-webcomponents\requirehtml.js</Link>
</BundleResource>
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\bower_components\fastclick\.bower.json">
<Link>Resources\dashboard-ui\bower_components\fastclick\.bower.json</Link>
</BundleResource>
@ -4175,9 +4184,6 @@
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\components\requirecss.js">
<Link>Resources\dashboard-ui\components\requirecss.js</Link>
</BundleResource>
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\components\requirehtml.js">
<Link>Resources\dashboard-ui\components\requirehtml.js</Link>
</BundleResource>
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\components\sharingwidget.js">
<Link>Resources\dashboard-ui\components\sharingwidget.js</Link>
</BundleResource>
@ -4667,6 +4673,9 @@
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\legacy\buttonenabled.js">
<Link>Resources\dashboard-ui\legacy\buttonenabled.js</Link>
</BundleResource>
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\legacy\deferred.js">
<Link>Resources\dashboard-ui\legacy\deferred.js</Link>
</BundleResource>
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\scripts\aboutpage.js">
<Link>Resources\dashboard-ui\scripts\aboutpage.js</Link>
</BundleResource>