fixes #1145 - Improve support for daily episodes

This commit is contained in:
Luke 2015-12-25 16:18:27 -05:00 committed by Luke Pulverenti
parent 1e470a15d6
commit 47f3571aea
6 changed files with 645 additions and 580 deletions

View File

@ -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
}; };
} }

View File

@ -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()
{ {

View File

@ -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

View File

@ -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>

View File

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