update xmltv xml parsing

This commit is contained in:
Luke Pulverenti 2017-02-11 16:16:22 -05:00
parent 825bb32d7b
commit f447098e53
4 changed files with 47 additions and 6 deletions

View File

@ -309,8 +309,8 @@
<Project>{4f26d5d8-a7b0-42b3-ba42-7cb7d245934e}</Project>
<Name>SocketHttpListener.Portable</Name>
</ProjectReference>
<Reference Include="Emby.XmlTv, Version=1.0.6249.32870, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Emby.XmlTv.1.0.6\lib\portable-net45+win8\Emby.XmlTv.dll</HintPath>
<Reference Include="Emby.XmlTv, Version=1.0.6251.29080, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Emby.XmlTv.1.0.7\lib\portable-net45+win8\Emby.XmlTv.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MediaBrowser.Naming, Version=1.0.6201.24431, Culture=neutral, processorArchitecture=MSIL">

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Text;
@ -26,13 +27,15 @@ namespace Emby.Server.Implementations.LiveTv.Listings
private readonly IHttpClient _httpClient;
private readonly ILogger _logger;
private readonly IFileSystem _fileSystem;
private readonly IZipClient _zipClient;
public XmlTvListingsProvider(IServerConfigurationManager config, IHttpClient httpClient, ILogger logger, IFileSystem fileSystem)
public XmlTvListingsProvider(IServerConfigurationManager config, IHttpClient httpClient, ILogger logger, IFileSystem fileSystem, IZipClient zipClient)
{
_config = config;
_httpClient = httpClient;
_logger = logger;
_fileSystem = fileSystem;
_zipClient = zipClient;
}
public string Name
@ -63,7 +66,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
var cacheFile = Path.Combine(_config.ApplicationPaths.CachePath, "xmltv", cacheFilename);
if (_fileSystem.FileExists(cacheFile))
{
return cacheFile;
return UnzipIfNeeded(path, cacheFile);
}
_logger.Info("Downloading xmltv listings from {0}", path);
@ -103,7 +106,30 @@ namespace Emby.Server.Implementations.LiveTv.Listings
}
_logger.Debug("Returning xmltv path {0}", cacheFile);
return cacheFile;
return UnzipIfNeeded(path, cacheFile);
}
private string UnzipIfNeeded(string originalUrl, string file)
{
//var ext = Path.GetExtension(originalUrl);
//if (string.Equals(ext, ".gz", StringComparison.OrdinalIgnoreCase))
//{
// using (var stream = _fileSystem.OpenRead(file))
// {
// var tempFolder = Path.Combine(_config.ApplicationPaths.TempDirectory, Guid.NewGuid().ToString());
// _fileSystem.CreateDirectory(tempFolder);
// _zipClient.ExtractAllFromZip(stream, tempFolder, true);
// return _fileSystem.GetFiles(tempFolder, true)
// .Where(i => string.Equals(i.Extension, ".xml", StringComparison.OrdinalIgnoreCase))
// .Select(i => i.FullName)
// .FirstOrDefault();
// }
//}
return file;
}
public async Task<IEnumerable<ProgramInfo>> GetProgramsAsync(ListingsProviderInfo info, string channelId, DateTime startDateUtc, DateTime endDateUtc, CancellationToken cancellationToken)
@ -122,6 +148,8 @@ namespace Emby.Server.Implementations.LiveTv.Listings
}
}
_logger.Debug("Getting xmltv programs for channel {0}", channelId);
var path = await GetXml(info.Path, cancellationToken).ConfigureAwait(false);
var reader = new XmlTvReader(path, GetLanguage());

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Emby.XmlTv" version="1.0.6" targetFramework="portable45-net45+win8" />
<package id="Emby.XmlTv" version="1.0.7" targetFramework="portable45-net45+win8" />
<package id="MediaBrowser.Naming" version="1.0.4" targetFramework="portable45-net45+win8" />
<package id="SQLitePCL.pretty" version="1.1.0" targetFramework="portable45-net45+win8" />
<package id="SQLitePCLRaw.core" version="1.1.1" targetFramework="portable45-net45+win8" />

View File

@ -48,6 +48,19 @@ namespace MediaBrowser.Controller.LiveTv
return list;
}
public override double? GetDefaultPrimaryImageAspectRatio()
{
if (IsMovie)
{
double value = 2;
value /= 3;
return value;
}
return null;
}
[IgnoreDataMember]
public override SourceType SourceType
{