mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
commit
38a32f7b90
@ -527,7 +527,7 @@ return null;
|
|||||||
|
|
||||||
RegisterSingleInstance(FileSystemManager);
|
RegisterSingleInstance(FileSystemManager);
|
||||||
|
|
||||||
HttpClient = new HttpClientManager.HttpClientManager(ApplicationPaths, LogManager.GetLogger("HttpClient"), FileSystemManager, MemoryStreamFactory);
|
HttpClient = new HttpClientManager.HttpClientManager(ApplicationPaths, LogManager.GetLogger("HttpClient"), FileSystemManager, MemoryStreamFactory, GetDefaultUserAgent);
|
||||||
RegisterSingleInstance(HttpClient);
|
RegisterSingleInstance(HttpClient);
|
||||||
|
|
||||||
RegisterSingleInstance(NetworkManager);
|
RegisterSingleInstance(NetworkManager);
|
||||||
@ -549,6 +549,30 @@ return null;
|
|||||||
return Task.FromResult(true);
|
return Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string GetDefaultUserAgent()
|
||||||
|
{
|
||||||
|
var name = FormatAttribute(Name);
|
||||||
|
|
||||||
|
return name + "/" + ApplicationVersion.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private string FormatAttribute(string str)
|
||||||
|
{
|
||||||
|
var arr = str.ToCharArray();
|
||||||
|
|
||||||
|
arr = Array.FindAll<char>(arr, (c => (char.IsLetterOrDigit(c)
|
||||||
|
|| char.IsWhiteSpace(c))));
|
||||||
|
|
||||||
|
var result = new string(arr);
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(result))
|
||||||
|
{
|
||||||
|
result = "Emby";
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a list of types within an assembly
|
/// Gets a list of types within an assembly
|
||||||
/// This will handle situations that would normally throw an exception - such as a type within the assembly that depends on some other non-existant reference
|
/// This will handle situations that would normally throw an exception - such as a type within the assembly that depends on some other non-existant reference
|
||||||
|
@ -44,18 +44,12 @@ namespace Emby.Common.Implementations.HttpClientManager
|
|||||||
|
|
||||||
private readonly IFileSystem _fileSystem;
|
private readonly IFileSystem _fileSystem;
|
||||||
private readonly IMemoryStreamFactory _memoryStreamProvider;
|
private readonly IMemoryStreamFactory _memoryStreamProvider;
|
||||||
private readonly IApplicationHost _appHost;
|
private readonly Func<string> _defaultUserAgentFn;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="HttpClientManager" /> class.
|
/// Initializes a new instance of the <see cref="HttpClientManager" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="appPaths">The app paths.</param>
|
public HttpClientManager(IApplicationPaths appPaths, ILogger logger, IFileSystem fileSystem, IMemoryStreamFactory memoryStreamProvider, Func<string> defaultUserAgentFn)
|
||||||
/// <param name="logger">The logger.</param>
|
|
||||||
/// <param name="fileSystem">The file system.</param>
|
|
||||||
/// <exception cref="System.ArgumentNullException">appPaths
|
|
||||||
/// or
|
|
||||||
/// logger</exception>
|
|
||||||
public HttpClientManager(IApplicationPaths appPaths, ILogger logger, IFileSystem fileSystem, IMemoryStreamFactory memoryStreamProvider)
|
|
||||||
{
|
{
|
||||||
if (appPaths == null)
|
if (appPaths == null)
|
||||||
{
|
{
|
||||||
@ -70,6 +64,7 @@ namespace Emby.Common.Implementations.HttpClientManager
|
|||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
_memoryStreamProvider = memoryStreamProvider;
|
_memoryStreamProvider = memoryStreamProvider;
|
||||||
_appPaths = appPaths;
|
_appPaths = appPaths;
|
||||||
|
_defaultUserAgentFn = defaultUserAgentFn;
|
||||||
|
|
||||||
#if NET46
|
#if NET46
|
||||||
// http://stackoverflow.com/questions/566437/http-post-returns-the-error-417-expectation-failed-c
|
// http://stackoverflow.com/questions/566437/http-post-returns-the-error-417-expectation-failed-c
|
||||||
@ -284,7 +279,7 @@ namespace Emby.Common.Implementations.HttpClientManager
|
|||||||
|
|
||||||
if (!hasUserAgent && options.EnableDefaultUserAgent)
|
if (!hasUserAgent && options.EnableDefaultUserAgent)
|
||||||
{
|
{
|
||||||
SetUserAgent(request, _appHost.Name + "/" + _appHost.ApplicationVersion.ToString());
|
SetUserAgent(request, _defaultUserAgentFn());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +152,11 @@ namespace Emby.Server.Implementations.LiveTv.Listings
|
|||||||
responseString);
|
responseString);
|
||||||
var programDict = programDetails.ToDictionary(p => p.programID, y => y);
|
var programDict = programDetails.ToDictionary(p => p.programID, y => y);
|
||||||
|
|
||||||
var images = await GetImageForPrograms(info, programDetails.Where(p => p.hasImageArtwork).Select(p => p.programID).ToList(), cancellationToken);
|
var programIdsWithImages =
|
||||||
|
programDetails.Where(p => p.hasImageArtwork).Select(p => p.programID)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
var images = await GetImageForPrograms(info, programIdsWithImages, cancellationToken);
|
||||||
|
|
||||||
var schedules = dailySchedules.SelectMany(d => d.programs);
|
var schedules = dailySchedules.SelectMany(d => d.programs);
|
||||||
foreach (ScheduleDirect.Program schedule in schedules)
|
foreach (ScheduleDirect.Program schedule in schedules)
|
||||||
@ -439,13 +443,20 @@ namespace Emby.Server.Implementations.LiveTv.Listings
|
|||||||
List<string> programIds,
|
List<string> programIds,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
|
if (programIds.Count == 0)
|
||||||
|
{
|
||||||
|
return new List<ScheduleDirect.ShowImages>();
|
||||||
|
}
|
||||||
|
|
||||||
var imageIdString = "[";
|
var imageIdString = "[";
|
||||||
|
|
||||||
foreach (var i in programIds)
|
foreach (var i in programIds)
|
||||||
{
|
{
|
||||||
if (!imageIdString.Contains(i.Substring(0, 10)))
|
var imageId = i.Substring(0, 10);
|
||||||
|
|
||||||
|
if (!imageIdString.Contains(imageId))
|
||||||
{
|
{
|
||||||
imageIdString += "\"" + i.Substring(0, 10) + "\",";
|
imageIdString += "\"" + imageId + "\",";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -461,14 +472,21 @@ namespace Emby.Server.Implementations.LiveTv.Listings
|
|||||||
// The data can be large so give it some extra time
|
// The data can be large so give it some extra time
|
||||||
TimeoutMs = 60000
|
TimeoutMs = 60000
|
||||||
};
|
};
|
||||||
List<ScheduleDirect.ShowImages> images;
|
|
||||||
using (var innerResponse2 = await Post(httpOptions, true, info).ConfigureAwait(false))
|
|
||||||
{
|
|
||||||
images = _jsonSerializer.DeserializeFromStream<List<ScheduleDirect.ShowImages>>(
|
|
||||||
innerResponse2.Content);
|
|
||||||
}
|
|
||||||
|
|
||||||
return images;
|
try
|
||||||
|
{
|
||||||
|
using (var innerResponse2 = await Post(httpOptions, true, info).ConfigureAwait(false))
|
||||||
|
{
|
||||||
|
return _jsonSerializer.DeserializeFromStream<List<ScheduleDirect.ShowImages>>(
|
||||||
|
innerResponse2.Content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.ErrorException("Error getting image info from schedules direct", ex);
|
||||||
|
|
||||||
|
return new List<ScheduleDirect.ShowImages>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<NameIdPair>> GetHeadends(ListingsProviderInfo info, string country, string location, CancellationToken cancellationToken)
|
public async Task<List<NameIdPair>> GetHeadends(ListingsProviderInfo info, string country, string location, CancellationToken cancellationToken)
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
[assembly: AssemblyVersion("3.2.0.103")]
|
[assembly: AssemblyVersion("3.2.0.104")]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user