mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-07 16:28:56 +01:00
improve support for compressed xmltv
This commit is contained in:
@@ -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);
|
||||
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);
|
||||
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);
|
||||
_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 _fileSystem.GetFiles(tempFolder, true)
|
||||
.Where(i => string.Equals(i.Extension, ".xml", StringComparison.OrdinalIgnoreCase))
|
||||
.Select(i => i.FullName)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user