aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/LiveTv
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2017-02-11 16:19:35 -0500
committerGitHub <noreply@github.com>2017-02-11 16:19:35 -0500
commitae7889b4675b45c86a56b1f8f727ed5a96a69ae0 (patch)
tree51a8a6679ccd8aed7f82d4b3187bd6d503678d9a /Emby.Server.Implementations/LiveTv
parentda89dceba0775f8ad2d5469e092b0ffa0b972a9a (diff)
parentf447098e53896f55a8fb99b405f502896e97f827 (diff)
Merge pull request #2464 from MediaBrowser/dev
Dev
Diffstat (limited to 'Emby.Server.Implementations/LiveTv')
-rw-r--r--Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs34
1 files changed, 31 insertions, 3 deletions
diff --git a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs
index d7803f9e35..a89acf6479 100644
--- a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs
+++ b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs
@@ -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());