예제 #1
0
 private static void WriteArrayValue(XmlWriter XMLwrt, XmlRpcValueArray val)
 {
     XMLwrt.WriteStartElement("value"); //value
     XMLwrt.WriteStartElement("array"); //array
     XMLwrt.WriteStartElement("data");  //data
     foreach (IXmlRpcValue o in val.Values)
     {
         if (o is XmlRpcValueBasic)
         {
             WriteBasicValue(XMLwrt, (XmlRpcValueBasic)o);
         }
         else if (o is XmlRpcValueStruct)
         {
             WriteStructValue(XMLwrt, (XmlRpcValueStruct)o);
         }
         else if (o is XmlRpcValueArray)
         {
             WriteArrayValue(XMLwrt, (XmlRpcValueArray)o);
         }
     }
     XMLwrt.WriteEndElement(); //data
     XMLwrt.WriteEndElement(); //array
     XMLwrt.WriteEndElement(); //value
 }
예제 #2
0
        private static IXmlRpcValue ReadValue(XmlReader xmlReader)
        {
            while (xmlReader.Read())
            {
                if (xmlReader.Name == "value" && xmlReader.IsStartElement())
                {
                    xmlReader.Read();
                    if (xmlReader.Name == "string" && xmlReader.IsStartElement())
                    {
                        return(new XmlRpcValueBasic(xmlReader.ReadString(), XmlRpcBasicValueType.String));
                    }
                    else if (xmlReader.Name == "int" && xmlReader.IsStartElement())
                    {
                        return(new XmlRpcValueBasic(int.Parse(xmlReader.ReadString(), UsCulture), XmlRpcBasicValueType.Int));
                    }
                    else if (xmlReader.Name == "boolean" && xmlReader.IsStartElement())
                    {
                        return(new XmlRpcValueBasic(xmlReader.ReadString() == "1", XmlRpcBasicValueType.Boolean));
                    }
                    else if (xmlReader.Name == "double" && xmlReader.IsStartElement())
                    {
                        return(new XmlRpcValueBasic(double.Parse(xmlReader.ReadString(), UsCulture), XmlRpcBasicValueType.Double));
                    }
                    else if (xmlReader.Name == "dateTime.iso8601" && xmlReader.IsStartElement())
                    {
                        string   date   = xmlReader.ReadString();
                        int      year   = int.Parse(date.Substring(0, 4), UsCulture);
                        int      month  = int.Parse(date.Substring(4, 2), UsCulture);
                        int      day    = int.Parse(date.Substring(6, 2), UsCulture);
                        int      hour   = int.Parse(date.Substring(9, 2), UsCulture);
                        int      minute = int.Parse(date.Substring(12, 2), UsCulture);//19980717T14:08:55
                        int      sec    = int.Parse(date.Substring(15, 2), UsCulture);
                        DateTime time   = new DateTime(year, month, day, hour, minute, sec);
                        return(new XmlRpcValueBasic(time, XmlRpcBasicValueType.dateTime_iso8601));
                    }
                    else if (xmlReader.Name == "base64" && xmlReader.IsStartElement())
                    {
                        return(new XmlRpcValueBasic(BitConverter.ToInt64(Convert.FromBase64String(xmlReader.ReadString()), 0)
                                                    , XmlRpcBasicValueType.Double));
                    }
                    else if (xmlReader.Name == "struct" && xmlReader.IsStartElement())
                    {
                        XmlRpcValueStruct strct = new XmlRpcValueStruct(new List <XmlRpcStructMember>());
                        // Read members...
                        while (xmlReader.Read())
                        {
                            if (xmlReader.Name == "member" && xmlReader.IsStartElement())
                            {
                                XmlRpcStructMember member = new XmlRpcStructMember("", null);
                                xmlReader.Read();// read name
                                member.Name = xmlReader.ReadString();

                                IXmlRpcValue val = ReadValue(xmlReader);
                                if (val != null)
                                {
                                    member.Data = val;
                                    strct.Members.Add(member);
                                }
                            }
                            else if (xmlReader.Name == "struct" && !xmlReader.IsStartElement())
                            {
                                return(strct);
                            }
                        }
                        return(strct);
                    }
                    else if (xmlReader.Name == "array" && xmlReader.IsStartElement())
                    {
                        XmlRpcValueArray array = new XmlRpcValueArray();
                        // Read members...
                        while (xmlReader.Read())
                        {
                            if (xmlReader.Name == "array" && !xmlReader.IsStartElement())
                            {
                                return(array);
                            }
                            else
                            {
                                IXmlRpcValue val = ReadValue(xmlReader);
                                if (val != null)
                                {
                                    array.Values.Add(val);
                                }
                            }
                        }
                        return(array);
                    }
                }
                else
                {
                    break;
                }
            }
            return(null);
        }
예제 #3
0
 private static void WriteArrayValue(XmlWriter XMLwrt, XmlRpcValueArray val)
 {
     XMLwrt.WriteStartElement("value");//value
     XMLwrt.WriteStartElement("array");//array
     XMLwrt.WriteStartElement("data");//data
     foreach (IXmlRpcValue o in val.Values)
     {
         if (o is XmlRpcValueBasic)
         {
             WriteBasicValue(XMLwrt, (XmlRpcValueBasic)o);
         }
         else if (o is XmlRpcValueStruct)
         {
             WriteStructValue(XMLwrt, (XmlRpcValueStruct)o);
         }
         else if (o is XmlRpcValueArray)
         {
             WriteArrayValue(XMLwrt, (XmlRpcValueArray)o);
         }
     }
     XMLwrt.WriteEndElement();//data
     XMLwrt.WriteEndElement();//array
     XMLwrt.WriteEndElement();//value
 }
예제 #4
0
        private static IXmlRpcValue ReadValue(XmlReader xmlReader)
        {
            while (xmlReader.Read())
            {
                if (xmlReader.Name == "value" && xmlReader.IsStartElement())
                {
                    xmlReader.Read();
                    if (xmlReader.Name == "string" && xmlReader.IsStartElement())
                    {
                        return new XmlRpcValueBasic(xmlReader.ReadString(), XmlRpcBasicValueType.String);
                    }
                    else if (xmlReader.Name == "int" && xmlReader.IsStartElement())
                    {
                        return new XmlRpcValueBasic(int.Parse(xmlReader.ReadString(), UsCulture), XmlRpcBasicValueType.Int);
                    }
                    else if (xmlReader.Name == "boolean" && xmlReader.IsStartElement())
                    {
                        return new XmlRpcValueBasic(xmlReader.ReadString() == "1", XmlRpcBasicValueType.Boolean);
                    }
                    else if (xmlReader.Name == "double" && xmlReader.IsStartElement())
                    {
                        return new XmlRpcValueBasic(double.Parse(xmlReader.ReadString(), UsCulture), XmlRpcBasicValueType.Double);
                    }
                    else if (xmlReader.Name == "dateTime.iso8601" && xmlReader.IsStartElement())
                    {
                        string date = xmlReader.ReadString();
                        int year = int.Parse(date.Substring(0, 4), UsCulture);
                        int month = int.Parse(date.Substring(4, 2), UsCulture);
                        int day = int.Parse(date.Substring(6, 2), UsCulture);
                        int hour = int.Parse(date.Substring(9, 2), UsCulture);
                        int minute = int.Parse(date.Substring(12, 2), UsCulture);//19980717T14:08:55
                        int sec = int.Parse(date.Substring(15, 2), UsCulture);
                        DateTime time = new DateTime(year, month, day, hour, minute, sec);
                        return new XmlRpcValueBasic(time, XmlRpcBasicValueType.dateTime_iso8601);
                    }
                    else if (xmlReader.Name == "base64" && xmlReader.IsStartElement())
                    {
                        return new XmlRpcValueBasic(BitConverter.ToInt64(Convert.FromBase64String(xmlReader.ReadString()), 0)
                            , XmlRpcBasicValueType.Double);
                    }
                    else if (xmlReader.Name == "struct" && xmlReader.IsStartElement())
                    {
                        XmlRpcValueStruct strct = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
                        // Read members...
                        while (xmlReader.Read())
                        {
                            if (xmlReader.Name == "member" && xmlReader.IsStartElement())
                            {
                                XmlRpcStructMember member = new XmlRpcStructMember("", null);
                                xmlReader.Read();// read name
                                member.Name = xmlReader.ReadString();

                                IXmlRpcValue val = ReadValue(xmlReader);
                                if (val != null)
                                {
                                    member.Data = val;
                                    strct.Members.Add(member);
                                }
                            }
                            else if (xmlReader.Name == "struct" && !xmlReader.IsStartElement())
                            {
                                return strct;
                            }
                        }
                        return strct;
                    }
                    else if (xmlReader.Name == "array" && xmlReader.IsStartElement())
                    {
                        XmlRpcValueArray array = new XmlRpcValueArray();
                        // Read members...
                        while (xmlReader.Read())
                        {
                            if (xmlReader.Name == "array" && !xmlReader.IsStartElement())
                            {
                                return array;
                            }
                            else
                            {
                                IXmlRpcValue val = ReadValue(xmlReader);
                                if (val != null)
                                    array.Values.Add(val);
                            }
                        }
                        return array;
                    }
                }
                else break;
            }
            return null;
        }
예제 #5
0
 public XmlRpcValueArray(XmlRpcValueArray[] arrays) :
     base()
 {
     values = new List<IXmlRpcValue>();
     foreach (XmlRpcValueArray val in arrays)
     {
         values.Add(val);
     }
 }
예제 #6
0
        /// <summary>
        /// Schedule a periodical search for subtitles matching given video files, send results to user's e-mail address.
        /// </summary>
        /// <param name="languageIDS">The language 3 lenght ids array</param>
        /// <param name="movies">The movies parameters</param>
        /// <returns>Status of the call operation. If the call success the response will be 'MethodResponseSearchToMail'</returns>
        public static IMethodResponse SearchToMail(string[] languageIDS, SearchToMailMovieParameter[] movies)
        {
            if (TOKEN == "")
            {
                OSHConsole.WriteLine("Can't do this call, 'token' value not set. Please use Log In method first.", DebugCode.Error);
                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>();
            parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String));
            // Array of sub langs
            XmlRpcValueArray 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>());
                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);

            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. 
                XmlRpcMethodCall[] calls = XmlRpcGenerator.DecodeMethodResponse(response);
                if (calls.Length > 0)
                {
                    if (calls[0].Parameters.Count > 0)
                    {
                        XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
                        // Create the response, we'll need it later
                        MethodResponseSearchToMail R = new MethodResponseSearchToMail();

                        // To make sure response is not currepted by server, do it in loop
                        foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
                        {
                            switch (MEMBER.Name)
                            {
                                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;
                            }
                        }
                        // Return the response to user !!
                        return R;
                    }
                }
            }
            else
            {
                OSHConsole.WriteLine(response, DebugCode.Error);
                return new MethodResponseError("Fail", response);
            }
            return new MethodResponseError("Fail", "SearchToMail call failed !");
        }
예제 #7
0
        /// <summary>
        /// Returns comments for subtitles
        /// </summary>
        /// <param name="subIDS">The subtitle IDS (an array of IDSubtitleFile value that given by server as SearchSubtiles results)</param>
        /// <returns>Status of the call operation. If the call success the response will be 'MethodResponseGetComments'</returns>
        public static IMethodResponse GetComments(int[] subIDS)
        {
            if (TOKEN == "")
            {
                OSHConsole.WriteLine("Can't do this call, 'token' value not set. Please use Log In method first.", DebugCode.Error);
                return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first.");
            }
            if (subIDS == null)
            {
                OSHConsole.UpdateLine("No subtitle id passed !!", DebugCode.Error);
                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"); ;
            }
            // Method call ..
            List<IXmlRpcValue> 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);
            // Add the array to the parameters
            parms.Add(array);
            // Call !
            XmlRpcMethodCall 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. 
                XmlRpcMethodCall[] calls = XmlRpcGenerator.DecodeMethodResponse(response);
                if (calls.Length > 0)
                {
                    if (calls[0].Parameters.Count > 0)
                    {
                        XmlRpcValueStruct mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
                        // Create the response, we'll need it later
                        MethodResponseGetComments R = new MethodResponseGetComments();

                        // To make sure response is not currepted by server, do it in loop
                        foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
                        {
                            if (MEMBER.Name == "status")
                            {
                                R.Status = (string)MEMBER.Data.Data;
                                OSHConsole.WriteLine("Status= " + R.Status);
                            }
                            else if (MEMBER.Name == "seconds")
                            {
                                R.Seconds = (double)MEMBER.Data.Data;
                                OSHConsole.WriteLine("Seconds= " + R.Seconds);
                            }
                            else if (MEMBER.Name == "data")
                            {
                                if (MEMBER.Data is XmlRpcValueArray)
                                {
                                    OSHConsole.WriteLine("Comments results:");
                                    XmlRpcValueArray rarray = (XmlRpcValueArray)MEMBER.Data;
                                    foreach (IXmlRpcValue commentStruct in rarray.Values)
                                    {
                                        if (commentStruct == null) continue;
                                        if (!(commentStruct is XmlRpcValueStruct)) continue;

                                        GetCommentsResult 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..
                                            switch (commentmember.Name)
                                            {
                                                case "IDSubtitle": result.IDSubtitle = (string)commentmember.Data.Data; break;
                                                case "UserID": result.UserID = (string)commentmember.Data.Data; break;
                                                case "UserNickName": result.UserNickName = (string)commentmember.Data.Data; break;
                                                case "Comment": result.Comment = (string)commentmember.Data.Data; break;
                                                case "Created": result.Created = (string)commentmember.Data.Data; break;
                                            }
                                        }
                                        R.Results.Add(result);
                                        OSHConsole.WriteLine("> IDSubtitle= " + result.ToString());
                                    }
                                }
                                else// Unknown data ?
                                {
                                    OSHConsole.WriteLine("Data= " + MEMBER.Data.Data.ToString(), DebugCode.Warning);
                                }
                            }
                        }
                        // Return the response to user !!
                        return R;
                    }
                }
            }
            else
            {
                OSHConsole.WriteLine(response, DebugCode.Error);
                return new MethodResponseError("Fail", response);
            }
            return new MethodResponseError("Fail", "GetComments call failed !");
        }
예제 #8
0
        public static async Task<IMethodResponse> DownloadSubtitlesAsync(int[] subIDS, CancellationToken cancellationToken)
        {
            if (TOKEN == "")
            {
                OSHConsole.WriteLine("Can't do this call, 'token' value not set. Please use Log In method first.", DebugCode.Error);
                return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first.");
            }
            if (subIDS == null)
            {
                OSHConsole.UpdateLine("No subtitle id passed !!", DebugCode.Error);
                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"); ;
            }
            // Method call ..
            List<IXmlRpcValue> 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();
            foreach (int id in subIDS)
            {
                array.Values.Add(new XmlRpcValueBasic(id, XmlRpcBasicValueType.Int));
            }
            // Add the array to the parameters
            parms.Add(array);
            // Call !
            XmlRpcMethodCall call = new XmlRpcMethodCall("DownloadSubtitles", parms);
            OSHConsole.WriteLine("Sending DownloadSubtitles request to the server ...", DebugCode.Good);
            // Send the request to the server

            var httpResponse = await Utilities.SendRequestAsync(XmlRpcGenerator.Generate(call), XML_PRC_USERAGENT, cancellationToken).ConfigureAwait(false);

            string response = Utilities.GetStreamString(httpResponse);
            if (!response.Contains("ERROR:"))
            {
                // No error occur, get and decode the response. 
                XmlRpcMethodCall[] calls = XmlRpcGenerator.DecodeMethodResponse(response);
                if (calls.Length > 0)
                {
                    if (calls[0].Parameters.Count > 0)
                    {
                        // We expect Struct of 3 members:
                        //* 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];
                        // Create the response, we'll need it later
                        MethodResponseSubtitleDownload R = new MethodResponseSubtitleDownload();

                        // To make sure response is not currepted by server, do it in loop
                        foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
                        {
                            if (MEMBER.Name == "status")
                            {
                                R.Status = (string)MEMBER.Data.Data;
                                OSHConsole.WriteLine("Status= " + R.Status);
                            }
                            else if (MEMBER.Name == "seconds")
                            {
                                R.Seconds = (double)MEMBER.Data.Data;
                                OSHConsole.WriteLine("Seconds= " + R.Seconds);
                            }
                            else if (MEMBER.Name == "data")
                            {
                                if (MEMBER.Data is XmlRpcValueArray)
                                {
                                    OSHConsole.WriteLine("Download results:");
                                    XmlRpcValueArray rarray = (XmlRpcValueArray)MEMBER.Data;
                                    foreach (IXmlRpcValue subStruct in rarray.Values)
                                    {
                                        if (subStruct == null) continue;
                                        if (!(subStruct is XmlRpcValueStruct)) continue;

                                        SubtitleDownloadResult 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..
                                            switch (submember.Name)
                                            {
                                                case "idsubtitlefile": result.IdSubtitleFile = (string)submember.Data.Data; break;
                                                case "data": result.Data = (string)submember.Data.Data; break;
                                            }
                                        }
                                        R.Results.Add(result);
                                        OSHConsole.WriteLine("> IDSubtilteFile= " + result.ToString());
                                    }
                                }
                                else// Unknown data ?
                                {
                                    OSHConsole.WriteLine("Data= " + MEMBER.Data.Data.ToString(), DebugCode.Warning);
                                }
                            }
                        }
                        // Return the response to user !!
                        return R;
                    }
                }
            }
            else
            {
                OSHConsole.WriteLine(response, DebugCode.Error);
                return new MethodResponseError("Fail", response);
            }
            return new MethodResponseError("Fail", "DownloadSubtitles call failed !");
        }
예제 #9
0
        public static async Task<IMethodResponse> SearchSubtitlesAsync(SubtitleSearchParameters[] parameters, CancellationToken cancellationToken)
        {
            if (TOKEN == "")
            {
                OSHConsole.WriteLine("Can't do this call, 'token' value not set. Please use Log In method first.", DebugCode.Error);
                return new MethodResponseError("Fail", "Can't do this call, 'token' value not set. Please use Log In method first.");
            }
            if (parameters == null)
            {
                OSHConsole.UpdateLine("No subtitle search parameter passed !!", DebugCode.Error);
                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"); ;
            }
            // Method call ..
            List<IXmlRpcValue> 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();
            foreach (SubtitleSearchParameters param in parameters)
            {
                XmlRpcValueStruct strct = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
                // sublanguageid member
                XmlRpcStructMember member = new XmlRpcStructMember("sublanguageid",
                    new XmlRpcValueBasic(param.SubLangaugeID, XmlRpcBasicValueType.String));
                strct.Members.Add(member);
                // moviehash member
                if (param.MovieHash.Length > 0 && param.MovieByteSize > 0)
                {
                    member = new XmlRpcStructMember("moviehash",
                        new XmlRpcValueBasic(param.MovieHash, XmlRpcBasicValueType.String));
                    strct.Members.Add(member);
                    // moviehash member
                    member = new XmlRpcStructMember("moviebytesize",
                        new XmlRpcValueBasic(param.MovieByteSize, XmlRpcBasicValueType.Int));
                    strct.Members.Add(member);
                }
                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);
                }

                // imdbid member
                if (param.IMDbID.Length > 0)
                {
                    member = new XmlRpcStructMember("imdbid",
                        new XmlRpcValueBasic(param.IMDbID, XmlRpcBasicValueType.String));
                    strct.Members.Add(member);
                }
                // Add the struct to the array
                array.Values.Add(strct);
            }
            // Add the array to the parameters
            parms.Add(array);
            // Call !
            XmlRpcMethodCall 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. 
                XmlRpcMethodCall[] calls = XmlRpcGenerator.DecodeMethodResponse(response);
                if (calls.Length > 0)
                {
                    if (calls[0].Parameters.Count > 0)
                    {
                        // We expect Struct of 3 members:
                        //* 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];
                        // Create the response, we'll need it later
                        MethodResponseSubtitleSearch R = new MethodResponseSubtitleSearch();
                        // To make sure response is not currepted by server, do it in loop
                        foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
                        {
                            if (MEMBER.Name == "status")
                            {
                                R.Status = (string)MEMBER.Data.Data;
                                OSHConsole.WriteLine("Status= " + R.Status);
                            }
                            else if (MEMBER.Name == "seconds")
                            {
                                R.Seconds = (double)MEMBER.Data.Data;
                                OSHConsole.WriteLine("Seconds= " + R.Seconds);
                            }
                            else if (MEMBER.Name == "data")
                            {
                                if (MEMBER.Data is XmlRpcValueArray)
                                {
                                    OSHConsole.WriteLine("Search results: ");

                                    XmlRpcValueArray rarray = (XmlRpcValueArray)MEMBER.Data;
                                    foreach (IXmlRpcValue subStruct in rarray.Values)
                                    {
                                        if (subStruct == null) continue;
                                        if (!(subStruct is XmlRpcValueStruct)) continue;

                                        SubtitleSearchResult 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..
                                            switch (submember.Name)
                                            {
                                                case "IDMovie": result.IDMovie = submember.Data.Data.ToString(); break;
                                                case "IDMovieImdb": result.IDMovieImdb = submember.Data.Data.ToString(); break;
                                                case "IDSubMovieFile": result.IDSubMovieFile = submember.Data.Data.ToString(); break;
                                                case "IDSubtitle": result.IDSubtitle = submember.Data.Data.ToString(); break;
                                                case "IDSubtitleFile": result.IDSubtitleFile = submember.Data.Data.ToString(); break;
                                                case "ISO639": result.ISO639 = submember.Data.Data.ToString(); break;
                                                case "LanguageName": result.LanguageName = submember.Data.Data.ToString(); break;
                                                case "MovieByteSize": result.MovieByteSize = submember.Data.Data.ToString(); break;
                                                case "MovieHash": result.MovieHash = submember.Data.Data.ToString(); break;
                                                case "MovieImdbRating": result.MovieImdbRating = submember.Data.Data.ToString(); break;
                                                case "MovieName": result.MovieName = submember.Data.Data.ToString(); break;
                                                case "MovieNameEng": result.MovieNameEng = submember.Data.Data.ToString(); break;
                                                case "MovieReleaseName": result.MovieReleaseName = submember.Data.Data.ToString(); break;
                                                case "MovieTimeMS": result.MovieTimeMS = submember.Data.Data.ToString(); break;
                                                case "MovieYear": result.MovieYear = submember.Data.Data.ToString(); break;
                                                case "SubActualCD": result.SubActualCD = submember.Data.Data.ToString(); break;
                                                case "SubAddDate": result.SubAddDate = submember.Data.Data.ToString(); break;
                                                case "SubAuthorComment": result.SubAuthorComment = submember.Data.Data.ToString(); break;
                                                case "SubBad": result.SubBad = submember.Data.Data.ToString(); break;
                                                case "SubDownloadLink": result.SubDownloadLink = submember.Data.Data.ToString(); break;
                                                case "SubDownloadsCnt": result.SubDownloadsCnt = submember.Data.Data.ToString(); break;
                                                case "SeriesEpisode": result.SeriesEpisode = submember.Data.Data.ToString(); break;
                                                case "SeriesSeason": result.SeriesSeason = submember.Data.Data.ToString(); break;
                                                case "SubFileName": result.SubFileName = submember.Data.Data.ToString(); break;
                                                case "SubFormat": result.SubFormat = submember.Data.Data.ToString(); break;
                                                case "SubHash": result.SubHash = submember.Data.Data.ToString(); break;
                                                case "SubLanguageID": result.SubLanguageID = submember.Data.Data.ToString(); break;
                                                case "SubRating": result.SubRating = submember.Data.Data.ToString(); break;
                                                case "SubSize": result.SubSize = submember.Data.Data.ToString(); break;
                                                case "SubSumCD": result.SubSumCD = submember.Data.Data.ToString(); break;
                                                case "UserID": result.UserID = submember.Data.Data.ToString(); break;
                                                case "UserNickName": result.UserNickName = submember.Data.Data.ToString(); break;
                                                case "ZipDownloadLink": result.ZipDownloadLink = submember.Data.Data.ToString(); break;
                                            }
                                        }
                                        R.Results.Add(result);
                                        OSHConsole.WriteLine(">" + result.ToString());
                                    }
                                }
                                else// Unknown data ?
                                {
                                    OSHConsole.WriteLine("Data= " + MEMBER.Data.Data.ToString(), DebugCode.Warning);
                                }
                            }
                        }
                        // Return the response to user !!
                        return R;
                    }
                }
            }
            else
            {
                OSHConsole.WriteLine(response, DebugCode.Error);
                return new MethodResponseError("Fail", response);
            }
            return new MethodResponseError("Fail", "Search Subtitles call failed !");
        }