3.0.5641.0

This commit is contained in:
Luke Pulverenti 2015-06-11 17:22:44 -04:00
parent 2c4e27dac2
commit 67c4c9381f
5 changed files with 59 additions and 24 deletions

View File

@ -1,4 +1,5 @@
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Providers;
using System.Collections.Generic;
using System.Threading;
@ -35,5 +36,12 @@ namespace MediaBrowser.Controller.Subtitles
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task{SubtitleResponse}.</returns>
Task<SubtitleResponse> GetSubtitles(string id, CancellationToken cancellationToken);
/// <summary>
/// Gets the supported languages.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task&lt;IEnumerable&lt;NameIdPair&gt;&gt;.</returns>
Task<IEnumerable<NameIdPair>> GetSupportedLanguages(CancellationToken cancellationToken);
}
}

View File

@ -5,10 +5,11 @@ using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Controller.Security;
using MediaBrowser.Controller.Subtitles;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Providers;
using MediaBrowser.Model.Serialization;
using OpenSubtitlesHandler;
using System;
using System.Collections.Generic;
@ -38,17 +39,23 @@ namespace MediaBrowser.Providers.Subtitles
// And the user may restart the server
private const int MaxDownloadsPerDay = 150;
public OpenSubtitleDownloader(ILogManager logManager, IHttpClient httpClient, IServerConfigurationManager config, IEncryptionManager encryption)
private readonly IJsonSerializer _json;
public OpenSubtitleDownloader(ILogManager logManager, IHttpClient httpClient, IServerConfigurationManager config, IEncryptionManager encryption, IJsonSerializer json)
{
_logger = logManager.GetLogger(GetType().Name);
_httpClient = httpClient;
_config = config;
_encryption = encryption;
_json = json;
_config.NamedConfigurationUpdating += _config_NamedConfigurationUpdating;
// Reset the count every 24 hours
_dailyTimer = new Timer(state => _dailyDownloadCount = 0, null, TimeSpan.FromHours(24), TimeSpan.FromHours(24));
Utilities.HttpClient = httpClient;
OpenSubtitles.SetUserAgent("mediabrowser.tv");
}
private const string PasswordHashPrefix = "h:";
@ -195,6 +202,26 @@ namespace MediaBrowser.Providers.Subtitles
_lastLogin = DateTime.UtcNow;
}
public async Task<IEnumerable<NameIdPair>> GetSupportedLanguages(CancellationToken cancellationToken)
{
await Login(cancellationToken).ConfigureAwait(false);
var result = OpenSubtitles.GetSubLanguages("en");
if (!(result is MethodResponseGetSubLanguages))
{
_logger.Error("Invalid response type");
return new List<NameIdPair>();
}
var results = ((MethodResponseGetSubLanguages)result).Languages;
return results.Select(i => new NameIdPair
{
Name = i.LanguageName,
Id = i.SubLanguageID
});
}
public async Task<IEnumerable<RemoteSubtitleInfo>> Search(SubtitleSearchRequest request, CancellationToken cancellationToken)
{
var imdbIdText = request.GetProviderId(MetadataProviders.Imdb);
@ -229,9 +256,6 @@ namespace MediaBrowser.Providers.Subtitles
return new List<RemoteSubtitleInfo>();
}
Utilities.HttpClient = _httpClient;
OpenSubtitles.SetUserAgent("mediabrowser.tv");
await Login(cancellationToken).ConfigureAwait(false);
var subLanguageId = request.Language;
@ -260,7 +284,7 @@ namespace MediaBrowser.Providers.Subtitles
var result = await OpenSubtitles.SearchSubtitlesAsync(parms.ToArray(), cancellationToken).ConfigureAwait(false);
if (!(result is MethodResponseSubtitleSearch))
{
_logger.Debug("Invalid response type");
_logger.Error("Invalid response type");
return new List<RemoteSubtitleInfo>();
}

View File

@ -398,21 +398,21 @@ namespace MediaBrowser.Providers.TV
}
}
if (titles.Any(t => string.Equals(t, comparableName, StringComparison.OrdinalIgnoreCase)))
{
var id = node.SelectSingleNode("./seriesid") ??
node.SelectSingleNode("./id");
if (id != null)
{
searchResult.Name = titles.FirstOrDefault();
searchResult.SetProviderId(MetadataProviders.Tvdb, id.InnerText);
searchResults.Add(searchResult);
}
}
foreach (var title in titles)
{
if (string.Equals(title, comparableName, StringComparison.OrdinalIgnoreCase))
{
var id = node.SelectSingleNode("./seriesid") ??
node.SelectSingleNode("./id");
if (id != null)
{
searchResult.Name = title;
searchResult.SetProviderId(MetadataProviders.Tvdb, id.InnerText);
searchResults.Add(searchResult);
}
break;
}
_logger.Info("TVDb Provider - " + title + " did not match " + comparableName);
}
}

View File

@ -1,4 +1,4 @@
using System.Linq;
using MediaBrowser.Common;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Connect;
@ -22,14 +22,16 @@ namespace MediaBrowser.Server.Implementations.Connect
private readonly IConnectManager _connectManager;
private readonly INetworkManager _networkManager;
private readonly IApplicationHost _appHost;
public ConnectEntryPoint(IHttpClient httpClient, IApplicationPaths appPaths, ILogger logger, INetworkManager networkManager, IConnectManager connectManager)
public ConnectEntryPoint(IHttpClient httpClient, IApplicationPaths appPaths, ILogger logger, INetworkManager networkManager, IConnectManager connectManager, IApplicationHost appHost)
{
_httpClient = httpClient;
_appPaths = appPaths;
_logger = logger;
_networkManager = networkManager;
_connectManager = connectManager;
_appHost = appHost;
}
public void Run()
@ -49,7 +51,8 @@ namespace MediaBrowser.Server.Implementations.Connect
{
using (var stream = await _httpClient.Get(new HttpRequestOptions
{
Url = ipLookupUrl
Url = ipLookupUrl,
UserAgent = "Emby Server/" + _appHost.ApplicationVersion
}).ConfigureAwait(false))
{

View File

@ -1,4 +1,4 @@
using System.Reflection;
[assembly: AssemblyVersion("3.0.*")]
//[assembly: AssemblyVersion("3.0.5621.4")]
//[assembly: AssemblyVersion("3.0.*")]
[assembly: AssemblyVersion("3.0.5641.0")]