aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2017-09-25 01:06:15 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2017-09-25 01:06:15 -0400
commit978eedbcb7a778248acd03b7f924260db70cd406 (patch)
tree034fcf627081d6b0f5b60c62e5147127de438371 /Emby.Server.Implementations
parent768f20b1bbc16c9f0eb013a486d472dc7d2684a2 (diff)
improve support for compressed xmltv
Diffstat (limited to 'Emby.Server.Implementations')
-rw-r--r--Emby.Server.Implementations/Archiving/ZipClient.cs17
-rw-r--r--Emby.Server.Implementations/Emby.Server.Implementations.csproj4
-rw-r--r--Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs42
-rw-r--r--Emby.Server.Implementations/packages.config2
4 files changed, 42 insertions, 23 deletions
diff --git a/Emby.Server.Implementations/Archiving/ZipClient.cs b/Emby.Server.Implementations/Archiving/ZipClient.cs
index 3218d56c6..d7d37bb61 100644
--- a/Emby.Server.Implementations/Archiving/ZipClient.cs
+++ b/Emby.Server.Implementations/Archiving/ZipClient.cs
@@ -4,6 +4,7 @@ using SharpCompress.Archives.Rar;
using SharpCompress.Archives.SevenZip;
using SharpCompress.Archives.Tar;
using SharpCompress.Readers;
+using SharpCompress.Readers.GZip;
using SharpCompress.Readers.Zip;
namespace Emby.Server.Implementations.Archiving
@@ -72,6 +73,22 @@ namespace Emby.Server.Implementations.Archiving
}
}
+ public void ExtractAllFromGz(Stream source, string targetPath, bool overwriteExistingFiles)
+ {
+ using (var reader = GZipReader.Open(source))
+ {
+ var options = new ExtractionOptions();
+ options.ExtractFullPath = true;
+
+ if (overwriteExistingFiles)
+ {
+ options.Overwrite = true;
+ }
+
+ reader.WriteAllToDirectory(targetPath, options);
+ }
+ }
+
/// <summary>
/// Extracts all from7z.
/// </summary>
diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj
index ccff29eef..41a62a417 100644
--- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj
+++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj
@@ -667,8 +667,8 @@
<HintPath>..\packages\ServiceStack.Text.4.5.8\lib\net45\ServiceStack.Text.dll</HintPath>
<Private>True</Private>
</Reference>
- <Reference Include="SharpCompress, Version=0.14.0.0, Culture=neutral, processorArchitecture=MSIL">
- <HintPath>..\packages\SharpCompress.0.14.0\lib\net45\SharpCompress.dll</HintPath>
+ <Reference Include="SharpCompress, Version=0.18.2.0, Culture=neutral, PublicKeyToken=afb0a02973931d96, processorArchitecture=MSIL">
+ <HintPath>..\packages\SharpCompress.0.18.2\lib\net45\SharpCompress.dll</HintPath>
</Reference>
<Reference Include="SimpleInjector, Version=4.0.8.0, Culture=neutral, PublicKeyToken=984cb50dea722e99, processorArchitecture=MSIL">
<HintPath>..\packages\SimpleInjector.4.0.8\lib\net45\SimpleInjector.dll</HintPath>
diff --git a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs
index fb8308cda..55500df6e 100644
--- a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs
+++ b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs
@@ -65,14 +65,15 @@ namespace Emby.Server.Implementations.LiveTv.Listings
if (!path.StartsWith("http", StringComparison.OrdinalIgnoreCase))
{
- return path;
+ return UnzipIfNeeded(path, path);
}
var cacheFilename = DateTime.UtcNow.DayOfYear.ToString(CultureInfo.InvariantCulture) + "-" + DateTime.UtcNow.Hour.ToString(CultureInfo.InvariantCulture) + ".xml";
var cacheFile = Path.Combine(_config.ApplicationPaths.CachePath, "xmltv", cacheFilename);
if (_fileSystem.FileExists(cacheFile))
{
- return UnzipIfNeeded(path, cacheFile);
+ //return UnzipIfNeeded(path, cacheFile);
+ return cacheFile;
}
_logger.Info("Downloading xmltv listings from {0}", path);
@@ -112,28 +113,29 @@ namespace Emby.Server.Implementations.LiveTv.Listings
}
_logger.Debug("Returning xmltv path {0}", cacheFile);
- return UnzipIfNeeded(path, 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();
- // }
- //}
+ var ext = Path.GetExtension(originalUrl.Split('?')[0]);
+
+ 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.ExtractAllFromGz(stream, tempFolder, true);
+
+ return _fileSystem.GetFiles(tempFolder, true)
+ .Where(i => string.Equals(i.Extension, ".xml", StringComparison.OrdinalIgnoreCase))
+ .Select(i => i.FullName)
+ .FirstOrDefault();
+ }
+ }
return file;
}
diff --git a/Emby.Server.Implementations/packages.config b/Emby.Server.Implementations/packages.config
index c27b8ac26..d27722fef 100644
--- a/Emby.Server.Implementations/packages.config
+++ b/Emby.Server.Implementations/packages.config
@@ -2,7 +2,7 @@
<packages>
<package id="Emby.XmlTv" version="1.0.10" targetFramework="net46" />
<package id="ServiceStack.Text" version="4.5.8" targetFramework="net46" />
- <package id="SharpCompress" version="0.14.0" targetFramework="net46" />
+ <package id="SharpCompress" version="0.18.2" targetFramework="net46" />
<package id="SimpleInjector" version="4.0.8" targetFramework="net46" />
<package id="SQLitePCL.pretty" version="1.1.0" targetFramework="portable45-net45+win8" />
<package id="SQLitePCLRaw.core" version="1.1.8" targetFramework="net46" />