support xmltv gzip
This commit is contained in:
parent
825f0f3507
commit
37d7db4bc4
|
@ -143,7 +143,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|||
};
|
||||
}
|
||||
|
||||
private WebRequest GetRequest(HttpRequestOptions options, string method, bool enableHttpCompression)
|
||||
private WebRequest GetRequest(HttpRequestOptions options, string method)
|
||||
{
|
||||
var request = CreateWebRequest(options.Url);
|
||||
var httpWebRequest = request as HttpWebRequest;
|
||||
|
@ -154,7 +154,9 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|||
|
||||
AddRequestHeaders(httpWebRequest, options);
|
||||
|
||||
httpWebRequest.AutomaticDecompression = enableHttpCompression ? DecompressionMethods.Deflate : DecompressionMethods.None;
|
||||
httpWebRequest.AutomaticDecompression = options.EnableHttpCompression ?
|
||||
(options.DecompressionMethod ?? DecompressionMethods.Deflate) :
|
||||
DecompressionMethods.None;
|
||||
}
|
||||
|
||||
request.CachePolicy = new RequestCachePolicy(RequestCacheLevel.BypassCache);
|
||||
|
@ -366,7 +368,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|||
};
|
||||
}
|
||||
|
||||
var httpWebRequest = GetRequest(options, httpMethod, options.EnableHttpCompression);
|
||||
var httpWebRequest = GetRequest(options, httpMethod);
|
||||
|
||||
if (options.RequestContentBytes != null ||
|
||||
!string.IsNullOrEmpty(options.RequestContent) ||
|
||||
|
@ -556,7 +558,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|||
|
||||
options.CancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var httpWebRequest = GetRequest(options, "GET", options.EnableHttpCompression);
|
||||
var httpWebRequest = GetRequest(options, "GET");
|
||||
|
||||
if (options.ResourcePool != null)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
|
||||
namespace MediaBrowser.Common.Net
|
||||
|
@ -16,6 +17,8 @@ namespace MediaBrowser.Common.Net
|
|||
/// <value>The URL.</value>
|
||||
public string Url { get; set; }
|
||||
|
||||
public DecompressionMethods? DecompressionMethod { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the accept header.
|
||||
/// </summary>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
|
@ -5,10 +6,6 @@ namespace MediaBrowser.Controller.Providers
|
|||
{
|
||||
public class ItemInfo
|
||||
{
|
||||
public ItemInfo()
|
||||
{
|
||||
}
|
||||
|
||||
public ItemInfo(IHasMetadata item)
|
||||
{
|
||||
Path = item.Path;
|
||||
|
@ -21,8 +18,11 @@ namespace MediaBrowser.Controller.Providers
|
|||
VideoType = video.VideoType;
|
||||
IsPlaceHolder = video.IsPlaceHolder;
|
||||
}
|
||||
|
||||
ItemType = item.GetType();
|
||||
}
|
||||
|
||||
public Type ItemType { get; set; }
|
||||
public string Path { get; set; }
|
||||
public string ContainingFolderPath { get; set; }
|
||||
public VideoType VideoType { get; set; }
|
||||
|
|
|
@ -486,10 +486,15 @@ namespace MediaBrowser.Server.Implementations.Dto
|
|||
|
||||
dto.UserData.Played = dto.UserData.PlayedPercentage.HasValue && dto.UserData.PlayedPercentage.Value >= 100;
|
||||
}
|
||||
else
|
||||
else if (item.SourceType == SourceType.Library)
|
||||
{
|
||||
dto.UserData = _userDataRepository.GetUserDataDto(item, user);
|
||||
}
|
||||
else
|
||||
{
|
||||
var userData = _userDataRepository.GetUserData(user, item);
|
||||
dto.UserData = GetUserItemDataDto(userData);
|
||||
}
|
||||
|
||||
if (item.SourceType == SourceType.Library)
|
||||
{
|
||||
|
|
|
@ -6,6 +6,8 @@ using System.Collections.Generic;
|
|||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Emby.XmlTv.Classes;
|
||||
|
@ -53,7 +55,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
|
|||
return path;
|
||||
}
|
||||
|
||||
var cacheFilename = DateTime.UtcNow.DayOfYear.ToString(CultureInfo.InvariantCulture) + "_" + DateTime.UtcNow.Hour.ToString(CultureInfo.InvariantCulture) + ".xml";
|
||||
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 (File.Exists(cacheFile))
|
||||
{
|
||||
|
@ -67,13 +69,34 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
|
|||
CancellationToken = cancellationToken,
|
||||
Url = path,
|
||||
Progress = new Progress<Double>(),
|
||||
EnableHttpCompression = false
|
||||
DecompressionMethod = DecompressionMethods.GZip,
|
||||
|
||||
// It's going to come back gzipped regardless of this value
|
||||
// So we need to make sure the decompression method is set to gzip
|
||||
EnableHttpCompression = true
|
||||
|
||||
}).ConfigureAwait(false);
|
||||
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(cacheFile));
|
||||
File.Copy(tempFile, cacheFile, true);
|
||||
|
||||
using (var stream = File.OpenRead(tempFile))
|
||||
{
|
||||
using (var reader = new StreamReader(stream, Encoding.UTF8))
|
||||
{
|
||||
using (var fileStream = File.OpenWrite(cacheFile))
|
||||
{
|
||||
using (var writer = new StreamWriter(fileStream))
|
||||
{
|
||||
while (!reader.EndOfStream)
|
||||
{
|
||||
writer.WriteLine(reader.ReadLine());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_logger.Debug("Returning xmltv path {0}", cacheFile);
|
||||
return cacheFile;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,9 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
}
|
||||
else
|
||||
{
|
||||
//if (item is Movie)
|
||||
// http://kodi.wiki/view/NFO_files/Movies
|
||||
// movie.nfo will override all and any .nfo files in the same folder as the media files if you use the "Use foldernames for lookups" setting. If you don't, then moviename.nfo is used
|
||||
//if (!item.IsInMixedFolder && item.ItemType == typeof(Movie))
|
||||
//{
|
||||
// list.Add(Path.Combine(item.ContainingFolderPath, "movie.nfo"));
|
||||
//}
|
||||
|
|
Loading…
Reference in New Issue
Block a user