update opensubtitles portable targeting

This commit is contained in:
Luke Pulverenti 2016-10-30 02:36:38 -04:00
parent b5673f4e16
commit 3c305512c0
5 changed files with 42 additions and 17294 deletions

View File

@ -9,14 +9,12 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OpenSubtitlesHandler</RootNamespace>
<AssemblyName>OpenSubtitlesHandler</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
<TargetFrameworkProfile>Profile7</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>

View File

@ -24,6 +24,7 @@ using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.Net;
using MediaBrowser.Model.Cryptography;
using MediaBrowser.Model.TextEncoding;
namespace OpenSubtitlesHandler
{
@ -33,6 +34,9 @@ namespace OpenSubtitlesHandler
public sealed class Utilities
{
public static ICryptographyProvider CryptographyProvider { get; set; }
public static IHttpClient HttpClient { get; set; }
public static IEncoding EncodingHelper { get; set; }
private const string XML_RPC_SERVER = "https://api.opensubtitles.org/xml-rpc";
/// <summary>
@ -105,10 +109,8 @@ namespace OpenSubtitlesHandler
/// <summary>
/// Handle server response stream and decode it as given encoding string.
/// </summary>
/// <param name="responseStream">The response stream. Expects a stream that doesn't support seek.</param>
/// <param name="encoding">The encoding that should be used to decode buffer</param>
/// <returns>The string of the stream after decode using given encoding</returns>
public static string GetStreamString(Stream responseStream, Encoding encoding)
public static string GetStreamString(Stream responseStream)
{
using (responseStream)
{
@ -121,20 +123,15 @@ namespace OpenSubtitlesHandler
break;
data.Add((byte)r);
}
return encoding.GetString(data.ToArray());
var bytes = data.ToArray();
return EncodingHelper.GetASCIIString(bytes, 0, bytes.Length);
}
}
/// <summary>
/// Handle server response stream and decode it as ASCII encoding string.
/// </summary>
/// <param name="responseStream">The response stream. Expects a stream that doesn't support seek.</param>
/// <returns>The string of the stream after decode using ASCII encoding</returns>
public static string GetStreamString(Stream responseStream)
{
return GetStreamString(responseStream, Encoding.ASCII);
}
public static IHttpClient HttpClient { get; set; }
public static byte[] GetASCIIBytes(string text)
{
return EncodingHelper.GetASCIIBytes(text);
}
/// <summary>
/// Send a request to the server

View File

@ -22,6 +22,8 @@ using System.Text;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using OpenSubtitlesHandler;
namespace XmlRpcHandler
{
/// <summary>
@ -103,26 +105,33 @@ namespace XmlRpcHandler
XmlReaderSettings sett = new XmlReaderSettings();
sett.DtdProcessing = DtdProcessing.Ignore;
sett.IgnoreWhitespace = true;
MemoryStream str = new MemoryStream(Encoding.ASCII.GetBytes(xmlResponse));
MemoryStream str;
if (xmlResponse.Contains(@"encoding=""utf-8"""))
{
str = new MemoryStream(Encoding.UTF8.GetBytes(xmlResponse));
}
using (XmlReader XMLread = XmlReader.Create(str, sett))
else
{
XmlRpcMethodCall call = new XmlRpcMethodCall("methodResponse");
// Read parameters
while (XMLread.Read())
str = new MemoryStream(Utilities.GetASCIIBytes(xmlResponse));
}
using (str)
{
using (XmlReader XMLread = XmlReader.Create(str, sett))
{
if (XMLread.Name == "param" && XMLread.IsStartElement())
XmlRpcMethodCall call = new XmlRpcMethodCall("methodResponse");
// Read parameters
while (XMLread.Read())
{
IXmlRpcValue val = ReadValue(XMLread);
if (val != null)
call.Parameters.Add(val);
if (XMLread.Name == "param" && XMLread.IsStartElement())
{
IXmlRpcValue val = ReadValue(XMLread);
if (val != null)
call.Parameters.Add(val);
}
}
methods.Add(call);
return methods.ToArray();
}
methods.Add(call);
return methods.ToArray();
}
}

View File

@ -1,16 +1,7 @@
{
"supports": {
"net46.app": {},
"uwp.10.0.app": {},
"dnxcore50.app": {}
},
"dependencies": {
"Microsoft.NETCore": "5.0.0",
"Microsoft.NETCore.Portable.Compatibility": "1.0.1"
},
{
"supports": {},
"dependencies": {},
"frameworks": {
"dotnet": {
"imports": "portable-net452+win81"
}
".NETPortable,Version=v4.5,Profile=Profile7": {}
}
}

File diff suppressed because it is too large Load Diff