aboutsummaryrefslogtreecommitdiff
path: root/OpenSubtitlesHandler/OpenSubtitles.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSubtitlesHandler/OpenSubtitles.cs')
-rw-r--r--OpenSubtitlesHandler/OpenSubtitles.cs547
1 files changed, 275 insertions, 272 deletions
diff --git a/OpenSubtitlesHandler/OpenSubtitles.cs b/OpenSubtitlesHandler/OpenSubtitles.cs
index 2dc71560b..76f70dc07 100644
--- a/OpenSubtitlesHandler/OpenSubtitles.cs
+++ b/OpenSubtitlesHandler/OpenSubtitles.cs
@@ -1,4 +1,4 @@
-/* This file is part of OpenSubtitles Handler
+/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
@@ -17,10 +17,10 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
-using System.Globalization;
-using System.Text;
using System.Collections.Generic;
+using System.Globalization;
using System.IO;
+using System.Text;
using System.Threading;
using System.Threading.Tasks;
using OpenSubtitlesHandler.Console;
@@ -57,12 +57,12 @@ namespace OpenSubtitlesHandler
public static IMethodResponse LogIn(string userName, string password, string language)
{
// Method call ..
- List<IXmlRpcValue> parms = new List<IXmlRpcValue>();
+ var parms = new List<IXmlRpcValue>();
parms.Add(new XmlRpcValueBasic(userName));
parms.Add(new XmlRpcValueBasic(password));
parms.Add(new XmlRpcValueBasic(language));
parms.Add(new XmlRpcValueBasic(XML_PRC_USERAGENT));
- XmlRpcMethodCall call = new XmlRpcMethodCall("LogIn", parms);
+ var call = new XmlRpcMethodCall("LogIn", parms);
OSHConsole.WriteLine("Sending LogIn request to the server ...", DebugCode.Good);
//File.WriteAllText(".\\request.txt", Encoding.UTF8.GetString(XmlRpcGenerator.Generate(call)));
@@ -77,8 +77,8 @@ namespace OpenSubtitlesHandler
{
if (calls[0].Parameters.Count > 0)
{
- XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
- MethodResponseLogIn re = new MethodResponseLogIn("Success", "Log in successful.");
+ var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
+ var re = new MethodResponseLogIn("Success", "Log in successful.");
foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
{
switch (MEMBER.Name)
@@ -103,12 +103,12 @@ namespace OpenSubtitlesHandler
public static async Task<IMethodResponse> LogInAsync(string userName, string password, string language, CancellationToken cancellationToken)
{
// Method call ..
- List<IXmlRpcValue> parms = new List<IXmlRpcValue>();
+ var parms = new List<IXmlRpcValue>();
parms.Add(new XmlRpcValueBasic(userName));
parms.Add(new XmlRpcValueBasic(password));
parms.Add(new XmlRpcValueBasic(language));
parms.Add(new XmlRpcValueBasic(XML_PRC_USERAGENT));
- XmlRpcMethodCall call = new XmlRpcMethodCall("LogIn", parms);
+ var call = new XmlRpcMethodCall("LogIn", parms);
OSHConsole.WriteLine("Sending LogIn request to the server ...", DebugCode.Good);
//File.WriteAllText(".\\request.txt", Encoding.UTF8.GetString(XmlRpcGenerator.Generate(call)));
@@ -126,23 +126,23 @@ namespace OpenSubtitlesHandler
{
if (calls[0].Parameters.Count > 0)
{
- XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
- MethodResponseLogIn re = new MethodResponseLogIn("Success", "Log in successful.");
+ var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
+ var re = new MethodResponseLogIn("Success", "Log in successful.");
foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
{
switch (MEMBER.Name)
{
- case "token":
- re.Token = TOKEN = MEMBER.Data.Data.ToString();
- OSHConsole.WriteLine(MEMBER.Name + "= " + MEMBER.Data.Data.ToString());
+ case "token":
+ re.Token = TOKEN = MEMBER.Data.Data.ToString();
+ OSHConsole.WriteLine(MEMBER.Name + "= " + MEMBER.Data.Data.ToString());
break;
case "seconds":
re.Seconds = double.Parse(MEMBER.Data.Data.ToString(), CultureInfo.InvariantCulture);
- OSHConsole.WriteLine(MEMBER.Name + "= " + MEMBER.Data.Data.ToString());
+ OSHConsole.WriteLine(MEMBER.Name + "= " + MEMBER.Data.Data.ToString());
break;
- case "status":
- re.Status = MEMBER.Data.Data.ToString();
- OSHConsole.WriteLine(MEMBER.Name + "= " + MEMBER.Data.Data.ToString());
+ case "status":
+ re.Status = MEMBER.Data.Data.ToString();
+ OSHConsole.WriteLine(MEMBER.Name + "= " + MEMBER.Data.Data.ToString());
break;
}
}
@@ -157,7 +157,7 @@ namespace OpenSubtitlesHandler
}
return new MethodResponseError("Fail", "Log in failed !");
}
-
+
/// <summary>
/// Log out from the server. Call this to terminate the session.
/// </summary>
@@ -170,9 +170,9 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first.");
}
// Method call ..
- List<IXmlRpcValue> parms = new List<IXmlRpcValue>();
+ var parms = new List<IXmlRpcValue>();
parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String));
- XmlRpcMethodCall call = new XmlRpcMethodCall("LogOut", parms);
+ var call = new XmlRpcMethodCall("LogOut", parms);
OSHConsole.WriteLine("Sending LogOut request to the server ...", DebugCode.Good);
// Send the request to the server
@@ -185,10 +185,10 @@ namespace OpenSubtitlesHandler
{
if (calls[0].Parameters.Count > 0)
{
- XmlRpcValueStruct strct = (XmlRpcValueStruct)calls[0].Parameters[0];
+ var strct = (XmlRpcValueStruct)calls[0].Parameters[0];
OSHConsole.WriteLine("STATUS=" + ((XmlRpcValueBasic)strct.Members[0].Data).Data.ToString());
OSHConsole.WriteLine("SECONDS=" + ((XmlRpcValueBasic)strct.Members[1].Data).Data.ToString());
- MethodResponseLogIn re = new MethodResponseLogIn("Success", "Log out successful.");
+ var re = new MethodResponseLogIn("Success", "Log out successful.");
re.Status = ((XmlRpcValueBasic)strct.Members[0].Data).Data.ToString();
re.Seconds = (double)((XmlRpcValueBasic)strct.Members[1].Data).Data;
return re;
@@ -203,7 +203,7 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "Log out failed !");
}
/// <summary>
- /// keep-alive user's session, verify token/session validity
+ /// keep-alive user's session, verify token/session validity
/// </summary>
/// <returns>Status of the call operation</returns>
public static IMethodResponse NoOperation()
@@ -214,10 +214,10 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first.");
}
// Method call ..
- List<IXmlRpcValue> parms = new List<IXmlRpcValue>();
+ var parms = new List<IXmlRpcValue>();
parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String));
parms.Add(new XmlRpcValueBasic(XML_PRC_USERAGENT, XmlRpcBasicValueType.String));
- XmlRpcMethodCall call = new XmlRpcMethodCall("NoOperation", parms);
+ var call = new XmlRpcMethodCall("NoOperation", parms);
OSHConsole.WriteLine("Sending NoOperation request to the server ...", DebugCode.Good);
// Send the request to the server
@@ -230,8 +230,8 @@ namespace OpenSubtitlesHandler
{
if (calls[0].Parameters.Count > 0)
{
- MethodResponseNoOperation R = new MethodResponseNoOperation();
- XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
+ var R = new MethodResponseNoOperation();
+ var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
// To make sure response is not currepted by server, do it in loop
foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
{
@@ -240,7 +240,7 @@ namespace OpenSubtitlesHandler
case "status": R.Status = (string)MEMBER.Data.Data; OSHConsole.WriteLine(MEMBER.Name + "= " + MEMBER.Data.Data); break;
case "seconds": R.Seconds = (double)MEMBER.Data.Data; OSHConsole.WriteLine(MEMBER.Name + "= " + MEMBER.Data.Data); break;
case "download_limits":
- XmlRpcValueStruct dlStruct = (XmlRpcValueStruct)MEMBER.Data;
+ var dlStruct = (XmlRpcValueStruct)MEMBER.Data;
foreach (XmlRpcStructMember dlmember in dlStruct.Members)
{
OSHConsole.WriteLine(" >" + dlmember.Name + "= " + dlmember.Data.Data.ToString());
@@ -270,7 +270,7 @@ namespace OpenSubtitlesHandler
}
/*Search and download*/
/// <summary>
- /// Search for subtitle files matching your videos using either video file hashes or IMDb IDs.
+ /// Search for subtitle files matching your videos using either video file hashes or IMDb IDs.
/// </summary>
/// <param name="parameters">List of search subtitle parameters which each one represents 'struct parameter' as descriped at http://trac.opensubtitles.org/projects/opensubtitles/wiki/XmlRpcSearchSubtitles </param>
/// <returns>Status of the call operation. If the call success the response will be 'MethodResponseSubtitleSearch'</returns>
@@ -284,28 +284,29 @@ namespace OpenSubtitlesHandler
if (parameters == null)
{
OSHConsole.UpdateLine("No subtitle search parameter passed !!", DebugCode.Error);
- return new MethodResponseError("Fail", "No subtitle search parameter passed"); ;
+ return new MethodResponseError("Fail", "No subtitle search parameter passed");
}
if (parameters.Length == 0)
{
OSHConsole.UpdateLine("No subtitle search parameter passed !!", DebugCode.Error);
- return new MethodResponseError("Fail", "No subtitle search parameter passed"); ;
+ return new MethodResponseError("Fail", "No subtitle search parameter passed");
}
// Method call ..
- List<IXmlRpcValue> parms = new List<IXmlRpcValue>();
+ var parms = new List<IXmlRpcValue>();
// Add token param
parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String));
// Add subtitle search parameters. Each one will be like 'array' of structs.
- XmlRpcValueArray array = new XmlRpcValueArray();
+ var array = new XmlRpcValueArray();
foreach (SubtitleSearchParameters param in parameters)
{
- XmlRpcValueStruct strct = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
+ var strct = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
// sublanguageid member
- XmlRpcStructMember member = new XmlRpcStructMember("sublanguageid",
+ var member = new XmlRpcStructMember("sublanguageid",
new XmlRpcValueBasic(param.SubLangaugeID, XmlRpcBasicValueType.String));
strct.Members.Add(member);
// moviehash member
- if (param.MovieHash.Length > 0 && param.MovieByteSize > 0) {
+ if (param.MovieHash.Length > 0 && param.MovieByteSize > 0)
+ {
member = new XmlRpcStructMember("moviehash",
new XmlRpcValueBasic(param.MovieHash, XmlRpcBasicValueType.String));
strct.Members.Add(member);
@@ -314,19 +315,21 @@ namespace OpenSubtitlesHandler
new XmlRpcValueBasic(param.MovieByteSize, XmlRpcBasicValueType.Int));
strct.Members.Add(member);
}
- if (param.Query.Length > 0) {
+ if (param.Query.Length > 0)
+ {
member = new XmlRpcStructMember("query",
new XmlRpcValueBasic(param.Query, XmlRpcBasicValueType.String));
strct.Members.Add(member);
}
- if (param.Episode.Length > 0 && param.Season.Length>0) {
- member = new XmlRpcStructMember("season",
- new XmlRpcValueBasic(param.Season, XmlRpcBasicValueType.String));
- strct.Members.Add(member);
- member = new XmlRpcStructMember("episode",
- new XmlRpcValueBasic(param.Episode, XmlRpcBasicValueType.String));
- strct.Members.Add(member);
+ if (param.Episode.Length > 0 && param.Season.Length > 0)
+ {
+ member = new XmlRpcStructMember("season",
+ new XmlRpcValueBasic(param.Season, XmlRpcBasicValueType.String));
+ strct.Members.Add(member);
+ member = new XmlRpcStructMember("episode",
+ new XmlRpcValueBasic(param.Episode, XmlRpcBasicValueType.String));
+ strct.Members.Add(member);
}
// imdbid member
@@ -342,14 +345,14 @@ namespace OpenSubtitlesHandler
// Add the array to the parameters
parms.Add(array);
// Call !
- XmlRpcMethodCall call = new XmlRpcMethodCall("SearchSubtitles", parms);
+ var call = new XmlRpcMethodCall("SearchSubtitles", parms);
OSHConsole.WriteLine("Sending SearchSubtitles request to the server ...", DebugCode.Good);
// Send the request to the server
string response = Utilities.GetStreamString(Utilities.SendRequest(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT));
if (!response.Contains("ERROR:"))
{
- // No error occur, get and decode the response.
+ // No error occur, get and decode the response.
XmlRpcMethodCall[] calls = XmlRpcGenerator.DecodeMethodResponse(response);
if (calls.Length > 0)
{
@@ -359,9 +362,9 @@ namespace OpenSubtitlesHandler
//* the first is status
//* the second is [array of structs, each one includes subtitle file].
//* the third is [double basic value] represent seconds token by server.
- XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
+ var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
// Create the response, we'll need it later
- MethodResponseSubtitleSearch R = new MethodResponseSubtitleSearch();
+ var R = new MethodResponseSubtitleSearch();
// To make sure response is not currepted by server, do it in loop
foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
{
@@ -381,13 +384,13 @@ namespace OpenSubtitlesHandler
{
OSHConsole.WriteLine("Search results: ");
- XmlRpcValueArray rarray = (XmlRpcValueArray)MEMBER.Data;
+ var rarray = (XmlRpcValueArray)MEMBER.Data;
foreach (IXmlRpcValue subStruct in rarray.Values)
{
if (subStruct == null) continue;
if (!(subStruct is XmlRpcValueStruct)) continue;
- SubtitleSearchResult result = new SubtitleSearchResult();
+ var result = new SubtitleSearchResult();
foreach (XmlRpcStructMember submember in ((XmlRpcValueStruct)subStruct).Members)
{
// To avoid errors of arranged info or missing ones, let's do it with switch..
@@ -461,24 +464,24 @@ namespace OpenSubtitlesHandler
if (parameters == null)
{
OSHConsole.UpdateLine("No subtitle search parameter passed !!", DebugCode.Error);
- return new MethodResponseError("Fail", "No subtitle search parameter passed"); ;
+ return new MethodResponseError("Fail", "No subtitle search parameter passed");
}
if (parameters.Length == 0)
{
OSHConsole.UpdateLine("No subtitle search parameter passed !!", DebugCode.Error);
- return new MethodResponseError("Fail", "No subtitle search parameter passed"); ;
+ return new MethodResponseError("Fail", "No subtitle search parameter passed");
}
// Method call ..
- List<IXmlRpcValue> parms = new List<IXmlRpcValue>();
+ var parms = new List<IXmlRpcValue>();
// Add token param
parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String));
// Add subtitle search parameters. Each one will be like 'array' of structs.
- XmlRpcValueArray array = new XmlRpcValueArray();
+ var array = new XmlRpcValueArray();
foreach (SubtitleSearchParameters param in parameters)
{
- XmlRpcValueStruct strct = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
+ var strct = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
// sublanguageid member
- XmlRpcStructMember member = new XmlRpcStructMember("sublanguageid",
+ var member = new XmlRpcStructMember("sublanguageid",
new XmlRpcValueBasic(param.SubLangaugeID, XmlRpcBasicValueType.String));
strct.Members.Add(member);
// moviehash member
@@ -522,14 +525,14 @@ namespace OpenSubtitlesHandler
// Add the array to the parameters
parms.Add(array);
// Call !
- XmlRpcMethodCall call = new XmlRpcMethodCall("SearchSubtitles", parms);
+ var call = new XmlRpcMethodCall("SearchSubtitles", parms);
OSHConsole.WriteLine("Sending SearchSubtitles request to the server ...", DebugCode.Good);
// Send the request to the server
string response = Utilities.GetStreamString(await Utilities.SendRequestAsync(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT, cancellationToken).ConfigureAwait(false));
if (!response.Contains("ERROR:"))
{
- // No error occur, get and decode the response.
+ // No error occur, get and decode the response.
XmlRpcMethodCall[] calls = XmlRpcGenerator.DecodeMethodResponse(response);
if (calls.Length > 0)
{
@@ -539,9 +542,9 @@ namespace OpenSubtitlesHandler
//* the first is status
//* the second is [array of structs, each one includes subtitle file].
//* the third is [double basic value] represent seconds token by server.
- XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
+ var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
// Create the response, we'll need it later
- MethodResponseSubtitleSearch R = new MethodResponseSubtitleSearch();
+ var R = new MethodResponseSubtitleSearch();
// To make sure response is not currepted by server, do it in loop
foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
{
@@ -561,13 +564,13 @@ namespace OpenSubtitlesHandler
{
OSHConsole.WriteLine("Search results: ");
- XmlRpcValueArray rarray = (XmlRpcValueArray)MEMBER.Data;
+ var rarray = (XmlRpcValueArray)MEMBER.Data;
foreach (IXmlRpcValue subStruct in rarray.Values)
{
if (subStruct == null) continue;
if (!(subStruct is XmlRpcValueStruct)) continue;
- SubtitleSearchResult result = new SubtitleSearchResult();
+ var result = new SubtitleSearchResult();
foreach (XmlRpcStructMember submember in ((XmlRpcValueStruct)subStruct).Members)
{
// To avoid errors of arranged info or missing ones, let's do it with switch..
@@ -630,7 +633,7 @@ namespace OpenSubtitlesHandler
}
return new MethodResponseError("Fail", "Search Subtitles call failed !");
}
-
+
/// <summary>
/// Download subtitle file(s)
/// </summary>
@@ -646,19 +649,19 @@ namespace OpenSubtitlesHandler
if (subIDS == null)
{
OSHConsole.UpdateLine("No subtitle id passed !!", DebugCode.Error);
- return new MethodResponseError("Fail", "No subtitle id passed"); ;
+ return new MethodResponseError("Fail", "No subtitle id passed");
}
if (subIDS.Length == 0)
{
OSHConsole.UpdateLine("No subtitle id passed !!", DebugCode.Error);
- return new MethodResponseError("Fail", "No subtitle id passed"); ;
+ return new MethodResponseError("Fail", "No subtitle id passed");
}
// Method call ..
- List<IXmlRpcValue> parms = new List<IXmlRpcValue>();
+ var parms = new List<IXmlRpcValue>();
// Add token param
parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String));
// Add subtitle search parameters. Each one will be like 'array' of structs.
- XmlRpcValueArray array = new XmlRpcValueArray();
+ var array = new XmlRpcValueArray();
foreach (int id in subIDS)
{
array.Values.Add(new XmlRpcValueBasic(id, XmlRpcBasicValueType.Int));
@@ -666,13 +669,13 @@ namespace OpenSubtitlesHandler
// Add the array to the parameters
parms.Add(array);
// Call !
- XmlRpcMethodCall call = new XmlRpcMethodCall("DownloadSubtitles", parms);
+ var call = new XmlRpcMethodCall("DownloadSubtitles", parms);
OSHConsole.WriteLine("Sending DownloadSubtitles request to the server ...", DebugCode.Good);
// Send the request to the server
string response = Utilities.GetStreamString(Utilities.SendRequest(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT));
if (!response.Contains("ERROR:"))
{
- // No error occur, get and decode the response.
+ // No error occur, get and decode the response.
XmlRpcMethodCall[] calls = XmlRpcGenerator.DecodeMethodResponse(response);
if (calls.Length > 0)
{
@@ -682,9 +685,9 @@ namespace OpenSubtitlesHandler
//* the first is status
//* the second is [array of structs, each one includes subtitle file].
//* the third is [double basic value] represent seconds token by server.
- XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
+ var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
// Create the response, we'll need it later
- MethodResponseSubtitleDownload R = new MethodResponseSubtitleDownload();
+ var R = new MethodResponseSubtitleDownload();
// To make sure response is not currepted by server, do it in loop
foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
@@ -704,13 +707,13 @@ namespace OpenSubtitlesHandler
if (MEMBER.Data is XmlRpcValueArray)
{
OSHConsole.WriteLine("Download results:");
- XmlRpcValueArray rarray = (XmlRpcValueArray)MEMBER.Data;
+ var rarray = (XmlRpcValueArray)MEMBER.Data;
foreach (IXmlRpcValue subStruct in rarray.Values)
{
if (subStruct == null) continue;
if (!(subStruct is XmlRpcValueStruct)) continue;
- SubtitleDownloadResult result = new SubtitleDownloadResult();
+ var result = new SubtitleDownloadResult();
foreach (XmlRpcStructMember submember in ((XmlRpcValueStruct)subStruct).Members)
{
// To avoid errors of arranged info or missing ones, let's do it with switch..
@@ -753,19 +756,19 @@ namespace OpenSubtitlesHandler
if (subIDS == null)
{
OSHConsole.UpdateLine("No subtitle id passed !!", DebugCode.Error);
- return new MethodResponseError("Fail", "No subtitle id passed"); ;
+ return new MethodResponseError("Fail", "No subtitle id passed");
}
if (subIDS.Length == 0)
{
OSHConsole.UpdateLine("No subtitle id passed !!", DebugCode.Error);
- return new MethodResponseError("Fail", "No subtitle id passed"); ;
+ return new MethodResponseError("Fail", "No subtitle id passed");
}
// Method call ..
- List<IXmlRpcValue> parms = new List<IXmlRpcValue>();
+ var parms = new List<IXmlRpcValue>();
// Add token param
parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String));
// Add subtitle search parameters. Each one will be like 'array' of structs.
- XmlRpcValueArray array = new XmlRpcValueArray();
+ var array = new XmlRpcValueArray();
foreach (int id in subIDS)
{
array.Values.Add(new XmlRpcValueBasic(id, XmlRpcBasicValueType.Int));
@@ -773,7 +776,7 @@ namespace OpenSubtitlesHandler
// Add the array to the parameters
parms.Add(array);
// Call !
- XmlRpcMethodCall call = new XmlRpcMethodCall("DownloadSubtitles", parms);
+ var call = new XmlRpcMethodCall("DownloadSubtitles", parms);
OSHConsole.WriteLine("Sending DownloadSubtitles request to the server ...", DebugCode.Good);
// Send the request to the server
@@ -782,7 +785,7 @@ namespace OpenSubtitlesHandler
string response = Utilities.GetStreamString(httpResponse);
if (!response.Contains("ERROR:"))
{
- // No error occur, get and decode the response.
+ // No error occur, get and decode the response.
XmlRpcMethodCall[] calls = XmlRpcGenerator.DecodeMethodResponse(response);
if (calls.Length > 0)
{
@@ -792,9 +795,9 @@ namespace OpenSubtitlesHandler
//* the first is status
//* the second is [array of structs, each one includes subtitle file].
//* the third is [double basic value] represent seconds token by server.
- XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
+ var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
// Create the response, we'll need it later
- MethodResponseSubtitleDownload R = new MethodResponseSubtitleDownload();
+ var R = new MethodResponseSubtitleDownload();
// To make sure response is not currepted by server, do it in loop
foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
@@ -814,13 +817,13 @@ namespace OpenSubtitlesHandler
if (MEMBER.Data is XmlRpcValueArray)
{
OSHConsole.WriteLine("Download results:");
- XmlRpcValueArray rarray = (XmlRpcValueArray)MEMBER.Data;
+ var rarray = (XmlRpcValueArray)MEMBER.Data;
foreach (IXmlRpcValue subStruct in rarray.Values)
{
if (subStruct == null) continue;
if (!(subStruct is XmlRpcValueStruct)) continue;
- SubtitleDownloadResult result = new SubtitleDownloadResult();
+ var result = new SubtitleDownloadResult();
foreach (XmlRpcStructMember submember in ((XmlRpcValueStruct)subStruct).Members)
{
// To avoid errors of arranged info or missing ones, let's do it with switch..
@@ -852,7 +855,7 @@ namespace OpenSubtitlesHandler
}
return new MethodResponseError("Fail", "DownloadSubtitles call failed !");
}
-
+
/// <summary>
/// Returns comments for subtitles
/// </summary>
@@ -868,37 +871,37 @@ namespace OpenSubtitlesHandler
if (subIDS == null)
{
OSHConsole.UpdateLine("No subtitle id passed !!", DebugCode.Error);
- return new MethodResponseError("Fail", "No subtitle id passed"); ;
+ return new MethodResponseError("Fail", "No subtitle id passed");
}
if (subIDS.Length == 0)
{
OSHConsole.UpdateLine("No subtitle id passed !!", DebugCode.Error);
- return new MethodResponseError("Fail", "No subtitle id passed"); ;
+ return new MethodResponseError("Fail", "No subtitle id passed");
}
// Method call ..
- List<IXmlRpcValue> parms = new List<IXmlRpcValue>();
+ var parms = new List<IXmlRpcValue>();
// Add token param
parms.Add(new XmlRpcValueBasic(TOKEN));
// Add subtitle search parameters. Each one will be like 'array' of structs.
- XmlRpcValueArray array = new XmlRpcValueArray(subIDS);
+ var array = new XmlRpcValueArray(subIDS);
// Add the array to the parameters
parms.Add(array);
// Call !
- XmlRpcMethodCall call = new XmlRpcMethodCall("GetComments", parms);
+ var call = new XmlRpcMethodCall("GetComments", parms);
OSHConsole.WriteLine("Sending GetComments request to the server ...", DebugCode.Good);
// Send the request to the server
string response = Utilities.GetStreamString(Utilities.SendRequest(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT));
if (!response.Contains("ERROR:"))
{
- // No error occur, get and decode the response.
+ // No error occur, get and decode the response.
XmlRpcMethodCall[] calls = XmlRpcGenerator.DecodeMethodResponse(response);
if (calls.Length > 0)
{
if (calls[0].Parameters.Count > 0)
{
- XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
+ var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
// Create the response, we'll need it later
- MethodResponseGetComments R = new MethodResponseGetComments();
+ var R = new MethodResponseGetComments();
// To make sure response is not currepted by server, do it in loop
foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
@@ -918,13 +921,13 @@ namespace OpenSubtitlesHandler
if (MEMBER.Data is XmlRpcValueArray)
{
OSHConsole.WriteLine("Comments results:");
- XmlRpcValueArray rarray = (XmlRpcValueArray)MEMBER.Data;
+ var rarray = (XmlRpcValueArray)MEMBER.Data;
foreach (IXmlRpcValue commentStruct in rarray.Values)
{
if (commentStruct == null) continue;
if (!(commentStruct is XmlRpcValueStruct)) continue;
- GetCommentsResult result = new GetCommentsResult();
+ var result = new GetCommentsResult();
foreach (XmlRpcStructMember commentmember in ((XmlRpcValueStruct)commentStruct).Members)
{
// To avoid errors of arranged info or missing ones, let's do it with switch..
@@ -974,37 +977,37 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first.");
}
// Method call ..
- List<IXmlRpcValue> parms = new List<IXmlRpcValue>();
+ var parms = new List<IXmlRpcValue>();
parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String));
// Array of sub langs
- XmlRpcValueArray a = new XmlRpcValueArray(languageIDS);
+ var a = new XmlRpcValueArray(languageIDS);
parms.Add(a);
// Array of video parameters
a = new XmlRpcValueArray();
foreach (SearchToMailMovieParameter p in movies)
{
- XmlRpcValueStruct str = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
+ var str = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
str.Members.Add(new XmlRpcStructMember("moviehash", new XmlRpcValueBasic(p.moviehash)));
str.Members.Add(new XmlRpcStructMember("moviesize", new XmlRpcValueBasic(p.moviesize)));
a.Values.Add(str);
}
parms.Add(a);
- XmlRpcMethodCall call = new XmlRpcMethodCall("SearchToMail", parms);
+ var call = new XmlRpcMethodCall("SearchToMail", parms);
OSHConsole.WriteLine("Sending SearchToMail request to the server ...", DebugCode.Good);
// Send the request to the server
string response = Utilities.GetStreamString(Utilities.SendRequest(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT));
if (!response.Contains("ERROR:"))
{
- // No error occur, get and decode the response.
+ // No error occur, get and decode the response.
XmlRpcMethodCall[] calls = XmlRpcGenerator.DecodeMethodResponse(response);
if (calls.Length > 0)
{
if (calls[0].Parameters.Count > 0)
{
- XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
+ var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
// Create the response, we'll need it later
- MethodResponseSearchToMail R = new MethodResponseSearchToMail();
+ var R = new MethodResponseSearchToMail();
// To make sure response is not currepted by server, do it in loop
foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
@@ -1029,7 +1032,7 @@ namespace OpenSubtitlesHandler
}
/*Movies*/
/// <summary>
- /// Search for a movie (using movie title)
+ /// Search for a movie (using movie title)
/// </summary>
/// <param name="query">Movie title user is searching for, this is cleaned-up a bit (remove dvdrip, etc.) before searching </param>
/// <returns>Status of the call operation. If the call success the response will be 'MethodResponseSubtitleSearch'</returns>
@@ -1041,27 +1044,27 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first.");
}
// Method call ..
- List<IXmlRpcValue> parms = new List<IXmlRpcValue>();
+ var parms = new List<IXmlRpcValue>();
// Add token param
parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String));
// Add query param
parms.Add(new XmlRpcValueBasic(query, XmlRpcBasicValueType.String));
// Call !
- XmlRpcMethodCall call = new XmlRpcMethodCall("SearchMoviesOnIMDB", parms);
+ var call = new XmlRpcMethodCall("SearchMoviesOnIMDB", parms);
OSHConsole.WriteLine("Sending SearchMoviesOnIMDB request to the server ...", DebugCode.Good);
// Send the request to the server
string response = Utilities.GetStreamString(Utilities.SendRequest(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT));
if (!response.Contains("ERROR:"))
{
- // No error occur, get and decode the response.
+ // No error occur, get and decode the response.
XmlRpcMethodCall[] calls = XmlRpcGenerator.DecodeMethodResponse(response);
if (calls.Length > 0)
{
if (calls[0].Parameters.Count > 0)
{
- XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
+ var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
// Create the response, we'll need it later
- MethodResponseMovieSearch R = new MethodResponseMovieSearch();
+ var R = new MethodResponseMovieSearch();
// To make sure response is not currepted by server, do it in loop
foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
@@ -1081,13 +1084,13 @@ namespace OpenSubtitlesHandler
if (MEMBER.Data is XmlRpcValueArray)
{
OSHConsole.WriteLine("Search results:");
- XmlRpcValueArray rarray = (XmlRpcValueArray)MEMBER.Data;
+ var rarray = (XmlRpcValueArray)MEMBER.Data;
foreach (IXmlRpcValue subStruct in rarray.Values)
{
if (subStruct == null) continue;
if (!(subStruct is XmlRpcValueStruct)) continue;
- MovieSearchResult result = new MovieSearchResult();
+ var result = new MovieSearchResult();
foreach (XmlRpcStructMember submember in ((XmlRpcValueStruct)subStruct).Members)
{
// To avoid errors of arranged info or missing ones, let's do it with switch..
@@ -1120,7 +1123,7 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "SearchMoviesOnIMDB call failed !");
}
/// <summary>
- /// Get movie details for given IMDb ID
+ /// Get movie details for given IMDb ID
/// </summary>
/// <param name="imdbid">http://www.imdb.com/</param>
/// <returns>Status of the call operation. If the call success the response will be 'MethodResponseMovieDetails'</returns>
@@ -1132,27 +1135,27 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first.");
}
// Method call ..
- List<IXmlRpcValue> parms = new List<IXmlRpcValue>();
+ var parms = new List<IXmlRpcValue>();
// Add token param
parms.Add(new XmlRpcValueBasic(TOKEN));
// Add query param
parms.Add(new XmlRpcValueBasic(imdbid));
// Call !
- XmlRpcMethodCall call = new XmlRpcMethodCall("GetIMDBMovieDetails", parms);
+ var call = new XmlRpcMethodCall("GetIMDBMovieDetails", parms);
OSHConsole.WriteLine("Sending GetIMDBMovieDetails request to the server ...", DebugCode.Good);
// Send the request to the server
string response = Utilities.GetStreamString(Utilities.SendRequest(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT));
if (!response.Contains("ERROR:"))
{
- // No error occur, get and decode the response.
+ // No error occur, get and decode the response.
XmlRpcMethodCall[] calls = XmlRpcGenerator.DecodeMethodResponse(response);
if (calls.Length > 0)
{
if (calls[0].Parameters.Count > 0)
{
- XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
+ var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
// Create the response, we'll need it later
- MethodResponseMovieDetails R = new MethodResponseMovieDetails();
+ var R = new MethodResponseMovieDetails();
// To make sure response is not currepted by server, do it in loop
foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
@@ -1173,7 +1176,7 @@ namespace OpenSubtitlesHandler
if (MEMBER.Data is XmlRpcValueStruct)
{
OSHConsole.WriteLine("Details result:");
- XmlRpcValueStruct detailsStruct = (XmlRpcValueStruct)MEMBER.Data;
+ var detailsStruct = (XmlRpcValueStruct)MEMBER.Data;
foreach (XmlRpcStructMember dmem in detailsStruct.Members)
{
switch (dmem.Name)
@@ -1190,7 +1193,7 @@ namespace OpenSubtitlesHandler
case "cast":
// this is another struct with cast members...
OSHConsole.WriteLine(">" + dmem.Name + "= ");
- XmlRpcValueStruct castStruct = (XmlRpcValueStruct)dmem.Data;
+ var castStruct = (XmlRpcValueStruct)dmem.Data;
foreach (XmlRpcStructMember castMemeber in castStruct.Members)
{
R.Cast.Add(castMemeber.Data.Data.ToString());
@@ -1200,7 +1203,7 @@ namespace OpenSubtitlesHandler
case "directors":
OSHConsole.WriteLine(">" + dmem.Name + "= ");
// this is another struct with directors members...
- XmlRpcValueStruct directorsStruct = (XmlRpcValueStruct)dmem.Data;
+ var directorsStruct = (XmlRpcValueStruct)dmem.Data;
foreach (XmlRpcStructMember directorsMember in directorsStruct.Members)
{
R.Directors.Add(directorsMember.Data.Data.ToString());
@@ -1210,7 +1213,7 @@ namespace OpenSubtitlesHandler
case "writers":
OSHConsole.WriteLine(">" + dmem.Name + "= ");
// this is another struct with writers members...
- XmlRpcValueStruct writersStruct = (XmlRpcValueStruct)dmem.Data;
+ var writersStruct = (XmlRpcValueStruct)dmem.Data;
foreach (XmlRpcStructMember writersMember in writersStruct.Members)
{
R.Writers.Add(writersMember.Data.Data.ToString());
@@ -1219,7 +1222,7 @@ namespace OpenSubtitlesHandler
break;
case "awards":
// this is an array of genres...
- XmlRpcValueArray awardsArray = (XmlRpcValueArray)dmem.Data;
+ var awardsArray = (XmlRpcValueArray)dmem.Data;
foreach (XmlRpcValueBasic award in awardsArray.Values)
{
R.Awards.Add(award.Data.ToString());
@@ -1229,7 +1232,7 @@ namespace OpenSubtitlesHandler
case "genres":
OSHConsole.WriteLine(">" + dmem.Name + "= ");
// this is an array of genres...
- XmlRpcValueArray genresArray = (XmlRpcValueArray)dmem.Data;
+ var genresArray = (XmlRpcValueArray)dmem.Data;
foreach (XmlRpcValueBasic genre in genresArray.Values)
{
R.Genres.Add(genre.Data.ToString());
@@ -1239,7 +1242,7 @@ namespace OpenSubtitlesHandler
case "country":
OSHConsole.WriteLine(">" + dmem.Name + "= ");
// this is an array of country...
- XmlRpcValueArray countryArray = (XmlRpcValueArray)dmem.Data;
+ var countryArray = (XmlRpcValueArray)dmem.Data;
foreach (XmlRpcValueBasic country in countryArray.Values)
{
R.Country.Add(country.Data.ToString());
@@ -1249,7 +1252,7 @@ namespace OpenSubtitlesHandler
case "language":
OSHConsole.WriteLine(">" + dmem.Name + "= ");
// this is an array of language...
- XmlRpcValueArray languageArray = (XmlRpcValueArray)dmem.Data;
+ var languageArray = (XmlRpcValueArray)dmem.Data;
foreach (XmlRpcValueBasic language in languageArray.Values)
{
R.Language.Add(language.Data.ToString());
@@ -1259,7 +1262,7 @@ namespace OpenSubtitlesHandler
case "certification":
OSHConsole.WriteLine(">" + dmem.Name + "= ");
// this is an array of certification...
- XmlRpcValueArray certificationArray = (XmlRpcValueArray)dmem.Data;
+ var certificationArray = (XmlRpcValueArray)dmem.Data;
foreach (XmlRpcValueBasic certification in certificationArray.Values)
{
R.Certification.Add(certification.Data.ToString());
@@ -1288,7 +1291,7 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "GetIMDBMovieDetails call failed !");
}
/// <summary>
- /// Allows registered users to insert new movies (not stored in IMDb) to the database.
+ /// Allows registered users to insert new movies (not stored in IMDb) to the database.
/// </summary>
/// <param name="movieName">Movie title </param>
/// <param name="movieyear">Release year </param>
@@ -1301,30 +1304,30 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first.");
}
// Method call ..
- List<IXmlRpcValue> parms = new List<IXmlRpcValue>();
+ var parms = new List<IXmlRpcValue>();
// Add token param
parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String));
// Add movieinfo struct
- XmlRpcValueStruct movieinfo = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
+ var movieinfo = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
movieinfo.Members.Add(new XmlRpcStructMember("moviename", new XmlRpcValueBasic(movieName)));
movieinfo.Members.Add(new XmlRpcStructMember("movieyear", new XmlRpcValueBasic(movieyear)));
parms.Add(movieinfo);
// Call !
- XmlRpcMethodCall call = new XmlRpcMethodCall("InsertMovie", parms);
+ var call = new XmlRpcMethodCall("InsertMovie", parms);
OSHConsole.WriteLine("Sending InsertMovie request to the server ...", DebugCode.Good);
// Send the request to the server
string response = Utilities.GetStreamString(Utilities.SendRequest(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT));
if (!response.Contains("ERROR:"))
{
- // No error occur, get and decode the response.
+ // No error occur, get and decode the response.
XmlRpcMethodCall[] calls = XmlRpcGenerator.DecodeMethodResponse(response);
if (calls.Length > 0)
{
if (calls[0].Parameters.Count > 0)
{
- XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
+ var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
// Create the response, we'll need it later
- MethodResponseInsertMovie R = new MethodResponseInsertMovie();
+ var R = new MethodResponseInsertMovie();
// To make sure response is not currepted by server, do it in loop
foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
@@ -1370,11 +1373,11 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first.");
}
// Method call ..
- List<IXmlRpcValue> parms = new List<IXmlRpcValue>();
+ var parms = new List<IXmlRpcValue>();
parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String));
foreach (InsertMovieHashParameters p in parameters)
{
- XmlRpcValueStruct pstruct = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
+ var pstruct = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
pstruct.Members.Add(new XmlRpcStructMember("moviehash", new XmlRpcValueBasic(p.moviehash)));
pstruct.Members.Add(new XmlRpcStructMember("moviebytesize", new XmlRpcValueBasic(p.moviebytesize)));
pstruct.Members.Add(new XmlRpcStructMember("imdbid", new XmlRpcValueBasic(p.imdbid)));
@@ -1383,22 +1386,22 @@ namespace OpenSubtitlesHandler
pstruct.Members.Add(new XmlRpcStructMember("moviefilename", new XmlRpcValueBasic(p.moviefilename)));
parms.Add(pstruct);
}
- XmlRpcMethodCall call = new XmlRpcMethodCall("InsertMovieHash", parms);
+ var call = new XmlRpcMethodCall("InsertMovieHash", parms);
OSHConsole.WriteLine("Sending InsertMovieHash request to the server ...", DebugCode.Good);
// Send the request to the server
string response = Utilities.GetStreamString(Utilities.SendRequest(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT));
if (!response.Contains("ERROR:"))
{
- // No error occur, get and decode the response.
+ // No error occur, get and decode the response.
XmlRpcMethodCall[] calls = XmlRpcGenerator.DecodeMethodResponse(response);
if (calls.Length > 0)
{
if (calls[0].Parameters.Count > 0)
{
- XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
+ var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
// Create the response, we'll need it later
- MethodResponseInsertMovieHash R = new MethodResponseInsertMovieHash();
+ var R = new MethodResponseInsertMovieHash();
// To make sure response is not currepted by server, do it in loop
foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
@@ -1414,13 +1417,13 @@ namespace OpenSubtitlesHandler
OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString());
break;
case "data":
- XmlRpcValueStruct dataStruct = (XmlRpcValueStruct)MEMBER.Data;
+ var dataStruct = (XmlRpcValueStruct)MEMBER.Data;
foreach (XmlRpcStructMember dataMember in dataStruct.Members)
{
switch (dataMember.Name)
{
case "accepted_moviehashes":
- XmlRpcValueArray mh = (XmlRpcValueArray)dataMember.Data;
+ var mh = (XmlRpcValueArray)dataMember.Data;
foreach (IXmlRpcValue val in mh.Values)
{
if (val is XmlRpcValueBasic)
@@ -1430,7 +1433,7 @@ namespace OpenSubtitlesHandler
}
break;
case "new_imdbs":
- XmlRpcValueArray mi = (XmlRpcValueArray)dataMember.Data;
+ var mi = (XmlRpcValueArray)dataMember.Data;
foreach (IXmlRpcValue val in mi.Values)
{
if (val is XmlRpcValueBasic)
@@ -1458,7 +1461,7 @@ namespace OpenSubtitlesHandler
}
/*Reporting and rating*/
/// <summary>
- /// Get basic server information and statistics
+ /// Get basic server information and statistics
/// </summary>
/// <returns>Status of the call operation. If the call success the response will be 'MethodResponseServerInfo'</returns>
public static IMethodResponse ServerInfo()
@@ -1469,25 +1472,25 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first.");
}
// Method call ..
- List<IXmlRpcValue> parms = new List<IXmlRpcValue>();
+ var parms = new List<IXmlRpcValue>();
parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String));
parms.Add(new XmlRpcValueBasic(XML_PRC_USERAGENT, XmlRpcBasicValueType.String));
- XmlRpcMethodCall call = new XmlRpcMethodCall("ServerInfo", parms);
+ var call = new XmlRpcMethodCall("ServerInfo", parms);
OSHConsole.WriteLine("Sending ServerInfo request to the server ...", DebugCode.Good);
// Send the request to the server
string response = Utilities.GetStreamString(Utilities.SendRequest(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT));
if (!response.Contains("ERROR:"))
{
- // No error occur, get and decode the response.
+ // No error occur, get and decode the response.
XmlRpcMethodCall[] calls = XmlRpcGenerator.DecodeMethodResponse(response);
if (calls.Length > 0)
{
if (calls[0].Parameters.Count > 0)
{
- XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
+ var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
// Create the response, we'll need it later
- MethodResponseServerInfo R = new MethodResponseServerInfo();
+ var R = new MethodResponseServerInfo();
// To make sure response is not currepted by server, do it in loop
foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
@@ -1565,7 +1568,7 @@ namespace OpenSubtitlesHandler
case "last_update_strings":
//R.total_subtitles_languages = (string)MEMBER.Data.Data;
OSHConsole.WriteLine(">" + MEMBER.Name + ":");
- XmlRpcValueStruct luStruct = (XmlRpcValueStruct)MEMBER.Data;
+ var luStruct = (XmlRpcValueStruct)MEMBER.Data;
foreach (XmlRpcStructMember luMemeber in luStruct.Members)
{
R.last_update_strings.Add(luMemeber.Name + " [" + luMemeber.Data.Data.ToString() + "]");
@@ -1599,25 +1602,25 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first.");
}
// Method call ..
- List<IXmlRpcValue> parms = new List<IXmlRpcValue>();
+ var parms = new List<IXmlRpcValue>();
parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String));
parms.Add(new XmlRpcValueBasic(IDSubMovieFile, XmlRpcBasicValueType.String));
- XmlRpcMethodCall call = new XmlRpcMethodCall("ReportWrongMovieHash", parms);
+ var call = new XmlRpcMethodCall("ReportWrongMovieHash", parms);
OSHConsole.WriteLine("Sending ReportWrongMovieHash request to the server ...", DebugCode.Good);
// Send the request to the server
string response = Utilities.GetStreamString(Utilities.SendRequest(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT));
if (!response.Contains("ERROR:"))
{
- // No error occur, get and decode the response.
+ // No error occur, get and decode the response.
XmlRpcMethodCall[] calls = XmlRpcGenerator.DecodeMethodResponse(response);
if (calls.Length > 0)
{
if (calls[0].Parameters.Count > 0)
{
- XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
+ var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
// Create the response, we'll need it later
- MethodResponseReportWrongMovieHash R = new MethodResponseReportWrongMovieHash();
+ var R = new MethodResponseReportWrongMovieHash();
// To make sure response is not currepted by server, do it in loop
foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
@@ -1647,9 +1650,9 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "ReportWrongMovieHash call failed !");
}
/// <summary>
- /// This method is needed to report bad movie hash for imdbid. This method should be used for correcting wrong entries,
- /// when using CheckMovieHash2. Pass moviehash and moviebytesize for file, and imdbid as new, corrected one IMDBID
- /// (id number without trailing zeroes). After some reports, moviehash will be linked to new imdbid.
+ /// This method is needed to report bad movie hash for imdbid. This method should be used for correcting wrong entries,
+ /// when using CheckMovieHash2. Pass moviehash and moviebytesize for file, and imdbid as new, corrected one IMDBID
+ /// (id number without trailing zeroes). After some reports, moviehash will be linked to new imdbid.
/// </summary>
/// <param name="moviehash">The movie hash</param>
/// <param name="moviebytesize">The movie size in bytes</param>
@@ -1663,29 +1666,29 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first.");
}
// Method call ..
- List<IXmlRpcValue> parms = new List<IXmlRpcValue>();
+ var parms = new List<IXmlRpcValue>();
parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String));
- XmlRpcValueStruct s = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
+ var s = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
s.Members.Add(new XmlRpcStructMember("moviehash", new XmlRpcValueBasic(moviehash)));
s.Members.Add(new XmlRpcStructMember("moviebytesize", new XmlRpcValueBasic(moviebytesize)));
s.Members.Add(new XmlRpcStructMember("imdbid", new XmlRpcValueBasic(imdbid)));
parms.Add(s);
- XmlRpcMethodCall call = new XmlRpcMethodCall("ReportWrongImdbMovie", parms);
+ var call = new XmlRpcMethodCall("ReportWrongImdbMovie", parms);
OSHConsole.WriteLine("Sending ReportWrongImdbMovie request to the server ...", DebugCode.Good);
// Send the request to the server
string response = Utilities.GetStreamString(Utilities.SendRequest(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT));
if (!response.Contains("ERROR:"))
{
- // No error occur, get and decode the response.
+ // No error occur, get and decode the response.
XmlRpcMethodCall[] calls = XmlRpcGenerator.DecodeMethodResponse(response);
if (calls.Length > 0)
{
if (calls[0].Parameters.Count > 0)
{
- XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
+ var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
// Create the response, we'll need it later
- MethodResponseAddComment R = new MethodResponseAddComment();
+ var R = new MethodResponseAddComment();
// To make sure response is not currepted by server, do it in loop
foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
@@ -1709,7 +1712,7 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "ReportWrongImdbMovie call failed !");
}
/// <summary>
- /// Rate subtitles
+ /// Rate subtitles
/// </summary>
/// <param name="idsubtitle">Id of subtitle (NOT subtitle file) user wants to rate </param>
/// <param name="score">Subtitle rating, must be in interval 1 (worst) to 10 (best). </param>
@@ -1722,28 +1725,28 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first.");
}
// Method call ..
- List<IXmlRpcValue> parms = new List<IXmlRpcValue>();
+ var parms = new List<IXmlRpcValue>();
parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String));
- XmlRpcValueStruct s = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
+ var s = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
s.Members.Add(new XmlRpcStructMember("idsubtitle", new XmlRpcValueBasic(idsubtitle)));
s.Members.Add(new XmlRpcStructMember("score", new XmlRpcValueBasic(score)));
parms.Add(s);
- XmlRpcMethodCall call = new XmlRpcMethodCall("SubtitlesVote", parms);
+ var call = new XmlRpcMethodCall("SubtitlesVote", parms);
OSHConsole.WriteLine("Sending SubtitlesVote request to the server ...", DebugCode.Good);
// Send the request to the server
string response = Utilities.GetStreamString(Utilities.SendRequest(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT));
if (!response.Contains("ERROR:"))
{
- // No error occur, get and decode the response.
+ // No error occur, get and decode the response.
XmlRpcMethodCall[] calls = XmlRpcGenerator.DecodeMethodResponse(response);
if (calls.Length > 0)
{
if (calls[0].Parameters.Count > 0)
{
- XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
+ var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
// Create the response, we'll need it later
- MethodResponseSubtitlesVote R = new MethodResponseSubtitlesVote();
+ var R = new MethodResponseSubtitlesVote();
// To make sure response is not currepted by server, do it in loop
foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
@@ -1753,7 +1756,7 @@ namespace OpenSubtitlesHandler
case "status": R.Status = (string)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break;
case "seconds": R.Seconds = (double)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break;
case "data":
- XmlRpcValueStruct dataStruct = (XmlRpcValueStruct)MEMBER.Data;
+ var dataStruct = (XmlRpcValueStruct)MEMBER.Data;
foreach (XmlRpcStructMember dataMemeber in dataStruct.Members)
{
OSHConsole.WriteLine(" >" + dataMemeber.Name + "= " + dataMemeber.Data.Data.ToString());
@@ -1780,7 +1783,7 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "SubtitlesVote call failed !");
}
/// <summary>
- /// Add comment to a subtitle
+ /// Add comment to a subtitle
/// </summary>
/// <param name="idsubtitle">Subtitle identifier (BEWARE! this is not the ID of subtitle file but of the whole subtitle (a subtitle can contain multiple subtitle files))</param>
/// <param name="comment">User's comment</param>
@@ -1794,32 +1797,32 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first.");
}
// Method call ..
- List<IXmlRpcValue> parms = new List<IXmlRpcValue>();
+ var parms = new List<IXmlRpcValue>();
parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String));
- XmlRpcValueStruct s = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
+ var s = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
s.Members.Add(new XmlRpcStructMember("idsubtitle", new XmlRpcValueBasic(idsubtitle)));
s.Members.Add(new XmlRpcStructMember("comment", new XmlRpcValueBasic(comment)));
s.Members.Add(new XmlRpcStructMember("badsubtitle", new XmlRpcValueBasic(badsubtitle)));
parms.Add(s);
- XmlRpcMethodCall call = new XmlRpcMethodCall("AddComment", parms);
+ var call = new XmlRpcMethodCall("AddComment", parms);
OSHConsole.WriteLine("Sending AddComment request to the server ...", DebugCode.Good);
// Send the request to the server
string response = Utilities.GetStreamString(Utilities.SendRequest(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT));
if (!response.Contains("ERROR:"))
{
- // No error occur, get and decode the response.
+ // No error occur, get and decode the response.
XmlRpcMethodCall[] calls = XmlRpcGenerator.DecodeMethodResponse(response);
if (calls.Length > 0)
{
if (calls[0].Parameters.Count > 0)
{
- XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
+ var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
// Create the response, we'll need it later
- MethodResponseAddComment R = new MethodResponseAddComment();
+ var R = new MethodResponseAddComment();
// To make sure response is not currepted by server, do it in loop
- foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
+ foreach (var MEMBER in mainStruct.Members)
{
switch (MEMBER.Name)
{
@@ -1854,29 +1857,29 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first.");
}
// Method call ..
- List<IXmlRpcValue> parms = new List<IXmlRpcValue>();
+ var parms = new List<IXmlRpcValue>();
parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String));
- XmlRpcValueStruct s = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
+ var s = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
s.Members.Add(new XmlRpcStructMember("sublanguageid", new XmlRpcValueBasic(sublanguageid)));
s.Members.Add(new XmlRpcStructMember("idmovieimdb", new XmlRpcValueBasic(idmovieimdb)));
s.Members.Add(new XmlRpcStructMember("comment", new XmlRpcValueBasic(comment)));
parms.Add(s);
- XmlRpcMethodCall call = new XmlRpcMethodCall("AddRequest", parms);
+ var call = new XmlRpcMethodCall("AddRequest", parms);
OSHConsole.WriteLine("Sending AddRequest request to the server ...", DebugCode.Good);
// Send the request to the server
string response = Utilities.GetStreamString(Utilities.SendRequest(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT));
if (!response.Contains("ERROR:"))
{
- // No error occur, get and decode the response.
+ // No error occur, get and decode the response.
XmlRpcMethodCall[] calls = XmlRpcGenerator.DecodeMethodResponse(response);
if (calls.Length > 0)
{
if (calls[0].Parameters.Count > 0)
{
- XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
+ var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
// Create the response, we'll need it later
- MethodResponseAddRequest R = new MethodResponseAddRequest();
+ var R = new MethodResponseAddRequest();
// To make sure response is not currepted by server, do it in loop
foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
@@ -1886,7 +1889,7 @@ namespace OpenSubtitlesHandler
case "status": R.Status = (string)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break;
case "seconds": R.Seconds = (double)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break;
case "data":
- XmlRpcValueStruct dataStruct = (XmlRpcValueStruct)MEMBER.Data;
+ var dataStruct = (XmlRpcValueStruct)MEMBER.Data;
foreach (XmlRpcStructMember dataMemeber in dataStruct.Members)
{
switch (dataMemeber.Name)
@@ -1923,25 +1926,25 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first.");
}
// Method call ..
- List<IXmlRpcValue> parms = new List<IXmlRpcValue>();
+ var parms = new List<IXmlRpcValue>();
parms.Add(new XmlRpcValueBasic(TOKEN));
parms.Add(new XmlRpcValueBasic(language));
- XmlRpcMethodCall call = new XmlRpcMethodCall("GetSubLanguages", parms);
+ var call = new XmlRpcMethodCall("GetSubLanguages", parms);
OSHConsole.WriteLine("Sending GetSubLanguages request to the server ...", DebugCode.Good);
// Send the request to the server
string response = Utilities.GetStreamString(Utilities.SendRequest(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT));
if (!response.Contains("ERROR:"))
{
- // No error occur, get and decode the response.
+ // No error occur, get and decode the response.
XmlRpcMethodCall[] calls = XmlRpcGenerator.DecodeMethodResponse(response);
if (calls.Length > 0)
{
if (calls[0].Parameters.Count > 0)
{
- XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
+ var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
// Create the response, we'll need it later
- MethodResponseGetSubLanguages R = new MethodResponseGetSubLanguages();
+ var R = new MethodResponseGetSubLanguages();
// To make sure response is not currepted by server, do it in loop
foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
@@ -1951,13 +1954,13 @@ namespace OpenSubtitlesHandler
case "status": R.Status = (string)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break;
case "seconds": R.Seconds = (double)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break;
case "data":// array of structs
- XmlRpcValueArray array = (XmlRpcValueArray)MEMBER.Data;
+ var array = (XmlRpcValueArray)MEMBER.Data;
foreach (IXmlRpcValue value in array.Values)
{
if (value is XmlRpcValueStruct)
{
- XmlRpcValueStruct valueStruct = (XmlRpcValueStruct)value;
- SubtitleLanguage lang = new SubtitleLanguage();
+ var valueStruct = (XmlRpcValueStruct)value;
+ var lang = new SubtitleLanguage();
OSHConsole.WriteLine(">SubLanguage:");
foreach (XmlRpcStructMember langMemeber in valueStruct.Members)
{
@@ -1993,7 +1996,7 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "GetSubLanguages call failed !");
}
/// <summary>
- /// Detect language for given strings
+ /// Detect language for given strings
/// </summary>
/// <param name="texts">Array of strings you want language detected for</param>
/// <param name="encodingUsed">The encoding that will be used to get buffer of given strings. (this is not OS official parameter)</param>
@@ -2006,10 +2009,10 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first.");
}
// Method call ..
- List<IXmlRpcValue> parms = new List<IXmlRpcValue>();
+ var parms = new List<IXmlRpcValue>();
parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String));
// We need to gzip texts then code them with base 24
- List<string> decodedTexts = new List<string>();
+ var decodedTexts = new List<string>();
foreach (string text in texts)
{
// compress
@@ -2022,22 +2025,22 @@ namespace OpenSubtitlesHandler
decodedTexts.Add(Convert.ToBase64String(data));
}
parms.Add(new XmlRpcValueArray(decodedTexts.ToArray()));
- XmlRpcMethodCall call = new XmlRpcMethodCall("DetectLanguage", parms);
+ var call = new XmlRpcMethodCall("DetectLanguage", parms);
OSHConsole.WriteLine("Sending DetectLanguage request to the server ...", DebugCode.Good);
// Send the request to the server
string response = Utilities.GetStreamString(Utilities.SendRequest(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT));
if (!response.Contains("ERROR:"))
{
- // No error occur, get and decode the response.
+ // No error occur, get and decode the response.
XmlRpcMethodCall[] calls = XmlRpcGenerator.DecodeMethodResponse(response);
if (calls.Length > 0)
{
if (calls[0].Parameters.Count > 0)
{
- XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
+ var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
// Create the response, we'll need it later
- MethodResponseDetectLanguage R = new MethodResponseDetectLanguage();
+ var R = new MethodResponseDetectLanguage();
// To make sure response is not currepted by server, do it in loop
foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
@@ -2050,10 +2053,10 @@ namespace OpenSubtitlesHandler
if (MEMBER.Data is XmlRpcValueStruct)
{
OSHConsole.WriteLine(">Languages:");
- XmlRpcValueStruct dataStruct = (XmlRpcValueStruct)MEMBER.Data;
+ var dataStruct = (XmlRpcValueStruct)MEMBER.Data;
foreach (XmlRpcStructMember dataMember in dataStruct.Members)
{
- DetectLanguageResult lang = new DetectLanguageResult();
+ var lang = new DetectLanguageResult();
lang.InputSample = dataMember.Name;
lang.LanguageID = dataMember.Data.Data.ToString();
R.Results.Add(lang);
@@ -2092,25 +2095,25 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first.");
}
// Method call ..
- List<IXmlRpcValue> parms = new List<IXmlRpcValue>();
+ var parms = new List<IXmlRpcValue>();
parms.Add(new XmlRpcValueBasic(TOKEN));
parms.Add(new XmlRpcValueBasic(program));
- XmlRpcMethodCall call = new XmlRpcMethodCall("GetAvailableTranslations", parms);
+ var call = new XmlRpcMethodCall("GetAvailableTranslations", parms);
OSHConsole.WriteLine("Sending GetAvailableTranslations request to the server ...", DebugCode.Good);
// Send the request to the server
string response = Utilities.GetStreamString(Utilities.SendRequest(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT));
if (!response.Contains("ERROR:"))
{
- // No error occur, get and decode the response.
+ // No error occur, get and decode the response.
XmlRpcMethodCall[] calls = XmlRpcGenerator.DecodeMethodResponse(response);
if (calls.Length > 0)
{
if (calls[0].Parameters.Count > 0)
{
- XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
+ var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
// Create the response, we'll need it later
- MethodResponseGetAvailableTranslations R = new MethodResponseGetAvailableTranslations();
+ var R = new MethodResponseGetAvailableTranslations();
// To make sure response is not currepted by server, do it in loop
foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
@@ -2120,14 +2123,14 @@ namespace OpenSubtitlesHandler
case "status": R.Status = (string)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break;
case "seconds": R.Seconds = (double)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break;
case "data":
- XmlRpcValueStruct dataStruct = (XmlRpcValueStruct)MEMBER.Data;
+ var dataStruct = (XmlRpcValueStruct)MEMBER.Data;
OSHConsole.WriteLine(">data:");
foreach (XmlRpcStructMember dataMember in dataStruct.Members)
{
if (dataMember.Data is XmlRpcValueStruct)
{
- XmlRpcValueStruct resStruct = (XmlRpcValueStruct)dataMember.Data;
- GetAvailableTranslationsResult res = new GetAvailableTranslationsResult();
+ var resStruct = (XmlRpcValueStruct)dataMember.Data;
+ var res = new GetAvailableTranslationsResult();
res.LanguageID = dataMember.Name;
OSHConsole.WriteLine(" >LanguageID: " + dataMember.Name);
foreach (XmlRpcStructMember resMember in resStruct.Members)
@@ -2161,7 +2164,7 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "GetAvailableTranslations call failed !");
}
/// <summary>
- /// Get a translation for given program and language
+ /// Get a translation for given program and language
/// </summary>
/// <param name="iso639">language ​ISO639-1 2-letter code </param>
/// <param name="format">available formats: [gnugettext compatible: mo, po] and [additional: txt, xml]</param>
@@ -2175,12 +2178,12 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first.");
}
// Method call ..
- List<IXmlRpcValue> parms = new List<IXmlRpcValue>();
+ var parms = new List<IXmlRpcValue>();
parms.Add(new XmlRpcValueBasic(TOKEN));
parms.Add(new XmlRpcValueBasic(iso639));
parms.Add(new XmlRpcValueBasic(format));
parms.Add(new XmlRpcValueBasic(program));
- XmlRpcMethodCall call = new XmlRpcMethodCall("GetTranslation", parms);
+ var call = new XmlRpcMethodCall("GetTranslation", parms);
OSHConsole.WriteLine("Sending GetTranslation request to the server ...", DebugCode.Good);
// Send the request to the server
@@ -2188,15 +2191,15 @@ namespace OpenSubtitlesHandler
string response = Utilities.GetStreamString(Utilities.SendRequest(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT));
if (!response.Contains("ERROR:"))
{
- // No error occur, get and decode the response.
+ // No error occur, get and decode the response.
XmlRpcMethodCall[] calls = XmlRpcGenerator.DecodeMethodResponse(response);
if (calls.Length > 0)
{
if (calls[0].Parameters.Count > 0)
{
- XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
+ var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
// Create the response, we'll need it later
- MethodResponseGetTranslation R = new MethodResponseGetTranslation();
+ var R = new MethodResponseGetTranslation();
// To make sure response is not currepted by server, do it in loop
foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
@@ -2221,7 +2224,7 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "GetTranslation call failed !");
}
/// <summary>
- /// Check for the latest version of given application
+ /// Check for the latest version of given application
/// </summary>
/// <param name="program">name of the program/client application you want to check. (Currently supported values: subdownloader, oscar)</param>
/// <returns>Status of the call operation. If the call success the response will be 'MethodResponseAutoUpdate'</returns>
@@ -2233,26 +2236,26 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first.");
}*/
// Method call ..
- List<IXmlRpcValue> parms = new List<IXmlRpcValue>();
+ var parms = new List<IXmlRpcValue>();
// parms.Add(new XmlRpcValueBasic(TOKEN));
parms.Add(new XmlRpcValueBasic(program));
// parms.Add(new XmlRpcValueBasic(XML_PRC_USERAGENT));
- XmlRpcMethodCall call = new XmlRpcMethodCall("AutoUpdate", parms);
+ var call = new XmlRpcMethodCall("AutoUpdate", parms);
OSHConsole.WriteLine("Sending AutoUpdate request to the server ...", DebugCode.Good);
// Send the request to the server
string response = Utilities.GetStreamString(Utilities.SendRequest(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT));
if (!response.Contains("ERROR:"))
{
- // No error occur, get and decode the response.
+ // No error occur, get and decode the response.
XmlRpcMethodCall[] calls = XmlRpcGenerator.DecodeMethodResponse(response);
if (calls.Length > 0)
{
if (calls[0].Parameters.Count > 0)
{
- XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
+ var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
// Create the response, we'll need it later
- MethodResponseAutoUpdate R = new MethodResponseAutoUpdate();
+ var R = new MethodResponseAutoUpdate();
// To make sure response is not currepted by server, do it in loop
foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
@@ -2293,25 +2296,25 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first.");
}
// Method call ..
- List<IXmlRpcValue> parms = new List<IXmlRpcValue>();
+ var parms = new List<IXmlRpcValue>();
parms.Add(new XmlRpcValueBasic(TOKEN));
parms.Add(new XmlRpcValueArray(hashes));
- XmlRpcMethodCall call = new XmlRpcMethodCall("CheckMovieHash", parms);
+ var call = new XmlRpcMethodCall("CheckMovieHash", parms);
OSHConsole.WriteLine("Sending CheckMovieHash request to the server ...", DebugCode.Good);
// Send the request to the server
string response = Utilities.GetStreamString(Utilities.SendRequest(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT));
if (!response.Contains("ERROR:"))
{
- // No error occur, get and decode the response.
+ // No error occur, get and decode the response.
XmlRpcMethodCall[] calls = XmlRpcGenerator.DecodeMethodResponse(response);
if (calls.Length > 0)
{
if (calls[0].Parameters.Count > 0)
{
- XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
+ var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
// Create the response, we'll need it later
- MethodResponseCheckMovieHash R = new MethodResponseCheckMovieHash();
+ var R = new MethodResponseCheckMovieHash();
// To make sure response is not currepted by server, do it in loop
foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
@@ -2321,14 +2324,14 @@ namespace OpenSubtitlesHandler
case "status": R.Status = (string)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break;
case "seconds": R.Seconds = (double)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break;
case "data":
- XmlRpcValueStruct dataStruct = (XmlRpcValueStruct)MEMBER.Data;
+ var dataStruct = (XmlRpcValueStruct)MEMBER.Data;
OSHConsole.WriteLine(">Data:");
foreach (XmlRpcStructMember dataMember in dataStruct.Members)
{
- CheckMovieHashResult res = new CheckMovieHashResult();
+ var res = new CheckMovieHashResult();
res.Name = dataMember.Name;
OSHConsole.WriteLine(" >" + res.Name + ":");
- XmlRpcValueStruct movieStruct = (XmlRpcValueStruct)dataMember.Data;
+ var movieStruct = (XmlRpcValueStruct)dataMember.Data;
foreach (XmlRpcStructMember movieMember in movieStruct.Members)
{
switch (movieMember.Name)
@@ -2357,7 +2360,7 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "CheckMovieHash call failed !");
}
/// <summary>
- /// Check if video file hashes are already stored in the database. This method returns matching !MovieImdbID, MovieName, MovieYear, SeriesSeason, SeriesEpisode,
+ /// Check if video file hashes are already stored in the database. This method returns matching !MovieImdbID, MovieName, MovieYear, SeriesSeason, SeriesEpisode,
/// MovieKind if available for each $moviehash, always sorted by SeenCount DESC.
/// </summary>
/// <param name="hashes">Array of video file hashes</param>
@@ -2370,25 +2373,25 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first.");
}
// Method call ..
- List<IXmlRpcValue> parms = new List<IXmlRpcValue>();
+ var parms = new List<IXmlRpcValue>();
parms.Add(new XmlRpcValueBasic(TOKEN));
parms.Add(new XmlRpcValueArray(hashes));
- XmlRpcMethodCall call = new XmlRpcMethodCall("CheckMovieHash2", parms);
+ var call = new XmlRpcMethodCall("CheckMovieHash2", parms);
OSHConsole.WriteLine("Sending CheckMovieHash2 request to the server ...", DebugCode.Good);
// Send the request to the server
string response = Utilities.GetStreamString(Utilities.SendRequest(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT));
if (!response.Contains("ERROR:"))
{
- // No error occur, get and decode the response.
+ // No error occur, get and decode the response.
XmlRpcMethodCall[] calls = XmlRpcGenerator.DecodeMethodResponse(response);
if (calls.Length > 0)
{
if (calls[0].Parameters.Count > 0)
{
- XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
+ var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
// Create the response, we'll need it later
- MethodResponseCheckMovieHash2 R = new MethodResponseCheckMovieHash2();
+ var R = new MethodResponseCheckMovieHash2();
// To make sure response is not currepted by server, do it in loop
foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
@@ -2398,18 +2401,18 @@ namespace OpenSubtitlesHandler
case "status": R.Status = (string)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break;
case "seconds": R.Seconds = (double)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break;
case "data":
- XmlRpcValueStruct dataStruct = (XmlRpcValueStruct)MEMBER.Data;
+ var dataStruct = (XmlRpcValueStruct)MEMBER.Data;
OSHConsole.WriteLine(">Data:");
foreach (XmlRpcStructMember dataMember in dataStruct.Members)
{
- CheckMovieHash2Result res = new CheckMovieHash2Result();
+ var res = new CheckMovieHash2Result();
res.Name = dataMember.Name;
OSHConsole.WriteLine(" >" + res.Name + ":");
- XmlRpcValueArray dataArray = (XmlRpcValueArray)dataMember.Data;
+ var dataArray = (XmlRpcValueArray)dataMember.Data;
foreach (XmlRpcValueStruct movieStruct in dataArray.Values)
{
- CheckMovieHash2Data d = new CheckMovieHash2Data();
+ var d = new CheckMovieHash2Data();
foreach (XmlRpcStructMember movieMember in movieStruct.Members)
{
switch (movieMember.Name)
@@ -2444,7 +2447,7 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "CheckMovieHash2 call failed !");
}
/// <summary>
- /// Check if given subtitle files are already stored in the database
+ /// Check if given subtitle files are already stored in the database
/// </summary>
/// <param name="hashes">Array of subtitle file hashes (MD5 hashes of subtitle file contents) </param>
/// <returns>Status of the call operation. If the call success the response will be 'MethodResponseCheckSubHash'</returns>
@@ -2456,25 +2459,25 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first.");
}
// Method call ..
- List<IXmlRpcValue> parms = new List<IXmlRpcValue>();
+ var parms = new List<IXmlRpcValue>();
parms.Add(new XmlRpcValueBasic(TOKEN));
parms.Add(new XmlRpcValueArray(hashes));
- XmlRpcMethodCall call = new XmlRpcMethodCall("CheckSubHash", parms);
+ var call = new XmlRpcMethodCall("CheckSubHash", parms);
OSHConsole.WriteLine("Sending CheckSubHash request to the server ...", DebugCode.Good);
// Send the request to the server
string response = Utilities.GetStreamString(Utilities.SendRequest(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT));
if (!response.Contains("ERROR:"))
{
- // No error occur, get and decode the response.
+ // No error occur, get and decode the response.
XmlRpcMethodCall[] calls = XmlRpcGenerator.DecodeMethodResponse(response);
if (calls.Length > 0)
{
if (calls[0].Parameters.Count > 0)
{
- XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
+ var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
// Create the response, we'll need it later
- MethodResponseCheckSubHash R = new MethodResponseCheckSubHash();
+ var R = new MethodResponseCheckSubHash();
// To make sure response is not currepted by server, do it in loop
foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
@@ -2485,11 +2488,11 @@ namespace OpenSubtitlesHandler
case "seconds": R.Seconds = (double)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break;
case "data":
OSHConsole.WriteLine(">Data:");
- XmlRpcValueStruct dataStruct = (XmlRpcValueStruct)MEMBER.Data;
+ var dataStruct = (XmlRpcValueStruct)MEMBER.Data;
foreach (XmlRpcStructMember dataMember in dataStruct.Members)
{
OSHConsole.WriteLine(" >" + dataMember.Name + "= " + dataMember.Data.Data.ToString());
- CheckSubHashResult r = new CheckSubHashResult();
+ var r = new CheckSubHashResult();
r.Hash = dataMember.Name;
r.SubID = dataMember.Data.Data.ToString();
R.Results.Add(r);
@@ -2511,7 +2514,7 @@ namespace OpenSubtitlesHandler
}
/*Upload*/
/// <summary>
- /// Try to upload subtitles, perform pre-upload checking (i.e. check if subtitles already exist on server)
+ /// Try to upload subtitles, perform pre-upload checking (i.e. check if subtitles already exist on server)
/// </summary>
/// <param name="subs">The subtitle parameters collection to try to upload</param>
/// <returns>Status of the call operation. If the call success the response will be 'MethodResponseTryUploadSubtitles'</returns>
@@ -2523,14 +2526,14 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first.");
}
// Method call ..
- List<IXmlRpcValue> parms = new List<IXmlRpcValue>();
+ var parms = new List<IXmlRpcValue>();
parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String));
- XmlRpcValueStruct s = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
+ var s = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
int i = 1;
- foreach (TryUploadSubtitlesParameters cd in subs)
+ foreach (var cd in subs)
{
- XmlRpcStructMember member = new XmlRpcStructMember("cd" + i, null);
- XmlRpcValueStruct memberStruct = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
+ var member = new XmlRpcStructMember("cd" + i, null);
+ var memberStruct = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
memberStruct.Members.Add(new XmlRpcStructMember("subhash", new XmlRpcValueBasic(cd.subhash)));
memberStruct.Members.Add(new XmlRpcStructMember("subfilename", new XmlRpcValueBasic(cd.subfilename)));
memberStruct.Members.Add(new XmlRpcStructMember("moviehash", new XmlRpcValueBasic(cd.moviehash)));
@@ -2544,22 +2547,22 @@ namespace OpenSubtitlesHandler
i++;
}
parms.Add(s);
- XmlRpcMethodCall call = new XmlRpcMethodCall("TryUploadSubtitles", parms);
+ var call = new XmlRpcMethodCall("TryUploadSubtitles", parms);
OSHConsole.WriteLine("Sending TryUploadSubtitles request to the server ...", DebugCode.Good);
// Send the request to the server
string response = Utilities.GetStreamString(Utilities.SendRequest(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT));
if (!response.Contains("ERROR:"))
{
- // No error occur, get and decode the response.
+ // No error occur, get and decode the response.
XmlRpcMethodCall[] calls = XmlRpcGenerator.DecodeMethodResponse(response);
if (calls.Length > 0)
{
if (calls[0].Parameters.Count > 0)
{
- XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
+ var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
// Create the response, we'll need it later
- MethodResponseTryUploadSubtitles R = new MethodResponseTryUploadSubtitles();
+ var R = new MethodResponseTryUploadSubtitles();
// To make sure response is not currepted by server, do it in loop
foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
@@ -2574,13 +2577,13 @@ namespace OpenSubtitlesHandler
{
OSHConsole.WriteLine("Results: ");
- XmlRpcValueArray rarray = (XmlRpcValueArray)MEMBER.Data;
+ var rarray = (XmlRpcValueArray)MEMBER.Data;
foreach (IXmlRpcValue subStruct in rarray.Values)
{
if (subStruct == null) continue;
if (!(subStruct is XmlRpcValueStruct)) continue;
- SubtitleSearchResult result = new SubtitleSearchResult();
+ var result = new SubtitleSearchResult();
foreach (XmlRpcStructMember submember in ((XmlRpcValueStruct)subStruct).Members)
{
// To avoid errors of arranged info or missing ones, let's do it with switch..
@@ -2643,7 +2646,7 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "TryUploadSubtitles call failed !");
}
/// <summary>
- /// Upload given subtitles to OSDb server
+ /// Upload given subtitles to OSDb server
/// </summary>
/// <param name="info">The pamaters of upload method</param>
/// <returns>Status of the call operation. If the call success the response will be 'MethodResponseUploadSubtitles'</returns>
@@ -2655,16 +2658,16 @@ namespace OpenSubtitlesHandler
return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first.");
}
// Method call ..
- List<IXmlRpcValue> parms = new List<IXmlRpcValue>();
+ var parms = new List<IXmlRpcValue>();
parms.Add(new XmlRpcValueBasic(TOKEN));
// Main struct
- XmlRpcValueStruct s = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
+ var s = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
// Base info member as struct
- XmlRpcStructMember member = new XmlRpcStructMember("baseinfo", null);
- XmlRpcValueStruct memberStruct = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
+ var member = new XmlRpcStructMember("baseinfo", null);
+ var memberStruct = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
memberStruct.Members.Add(new XmlRpcStructMember("idmovieimdb", new XmlRpcValueBasic(info.idmovieimdb)));
- memberStruct.Members.Add(new XmlRpcStructMember("sublanguageid", new XmlRpcValueBasic(info.sublanguageid)));
+ memberStruct.Members.Add(new XmlRpcStructMember("sublanguageid", new XmlRpcValueBasic(info.sublanguageid)));
memberStruct.Members.Add(new XmlRpcStructMember("moviereleasename", new XmlRpcValueBasic(info.moviereleasename)));
memberStruct.Members.Add(new XmlRpcStructMember("movieaka", new XmlRpcValueBasic(info.movieaka)));
memberStruct.Members.Add(new XmlRpcStructMember("subauthorcomment", new XmlRpcValueBasic(info.subauthorcomment)));
@@ -2678,8 +2681,8 @@ namespace OpenSubtitlesHandler
int i = 1;
foreach (UploadSubtitleParameters cd in info.CDS)
{
- XmlRpcStructMember member2 = new XmlRpcStructMember("cd" + i, null);
- XmlRpcValueStruct memberStruct2 = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
+ var member2 = new XmlRpcStructMember("cd" + i, null);
+ var memberStruct2 = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
memberStruct2.Members.Add(new XmlRpcStructMember("subhash", new XmlRpcValueBasic(cd.subhash)));
memberStruct2.Members.Add(new XmlRpcStructMember("subfilename", new XmlRpcValueBasic(cd.subfilename)));
memberStruct2.Members.Add(new XmlRpcStructMember("moviehash", new XmlRpcValueBasic(cd.moviehash)));
@@ -2698,21 +2701,21 @@ namespace OpenSubtitlesHandler
parms.Add(s);
// add user agent
//parms.Add(new XmlRpcValueBasic(XML_PRC_USERAGENT));
- XmlRpcMethodCall call = new XmlRpcMethodCall("UploadSubtitles", parms);
+ var call = new XmlRpcMethodCall("UploadSubtitles", parms);
OSHConsole.WriteLine("Sending UploadSubtitles request to the server ...", DebugCode.Good);
// Send the request to the server
string response = Utilities.GetStreamString(Utilities.SendRequest(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT));
if (!response.Contains("ERROR:"))
{
- // No error occur, get and decode the response.
+ // No error occur, get and decode the response.
XmlRpcMethodCall[] calls = XmlRpcGenerator.DecodeMethodResponse(response);
if (calls.Length > 0)
{
if (calls[0].Parameters.Count > 0)
{
- XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
+ var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
// Create the response, we'll need it later
- MethodResponseUploadSubtitles R = new MethodResponseUploadSubtitles();
+ var R = new MethodResponseUploadSubtitles();
// To make sure response is not currepted by server, do it in loop
foreach (XmlRpcStructMember MEMBER in mainStruct.Members)