Exemple #1
0
        public List<SearchResult> FileSearch(string filename, string lang)
        {
            var client = new XmlRpcRequest {MethodName = "SearchSubtitles"};
            client.Params.Add(_token);
            var query = new ArrayList();
            var qhash = new Hashtable();
            string moviehash;
            try
            {
                moviehash = MovieHasher.GetHash(filename);
            }
            catch
            {

                return TitleSearch(filename, lang);
            }
            long moviebytes = MovieHasher.GetByteSize(filename);
            qhash.Add("moviehash", moviehash);
            qhash.Add("moviebytesize", moviebytes);
            qhash.Add("sublanguageid", lang);
            query.Add(qhash);
            client.Params.Add(query);
            var result = (Hashtable) client.Invoke(Apiurl);
            bool hasdata;
            if (bool.TryParse(result["data"].ToString(), out hasdata))
                return TitleSearch(filename, lang);
            return ParseSearchResult(result);
        }
Exemple #2
0
 public string Login()
 {
     var client = new XmlRpcRequest {MethodName = "LogIn"};
     client.Params.Add("");
     client.Params.Add("");
     client.Params.Add("en");
     client.Params.Add(Useragent);
     var result = (Hashtable) client.Invoke(Apiurl);
     if (result["status"].ToString() == "200 OK")
     {
         return result["token"].ToString();
     }
     return string.Empty;
 }
Exemple #3
0
 public ArrayList GetSubLanguages()
 {
     var client = new XmlRpcRequest {MethodName = "GetSubLanguages"};
     var result = (Hashtable) client.Invoke(Apiurl);
     return (ArrayList) result["data"];
 }
Exemple #4
0
 public List<SearchResult> TitleSearch(string filename, string lang)
 {
     var client = new XmlRpcRequest {MethodName = "SearchSubtitles"};
     client.Params.Add(_token);
     var query = new ArrayList();
     var qhash = new Hashtable();
     string movietitle = Path.GetFileNameWithoutExtension(filename);
     qhash.Add("query", movietitle);
     qhash.Add("sublanguageid", lang);
     query.Add(qhash);
     client.Params.Add(query);
     var result = (Hashtable) client.Invoke(Apiurl);
     bool hasdata;
     return bool.TryParse(result["data"].ToString(), out hasdata) ? new List<SearchResult>() : ParseSearchResult(result);
 }
Exemple #5
0
 public bool Logout()
 {
     if (string.IsNullOrEmpty(_token))
         return false;
     var client = new XmlRpcRequest {MethodName = "LogOut"};
     client.Params.Add(_token);
     client.Params.Add(Useragent);
     var result = (Hashtable) client.Invoke(Apiurl);
     return (result["status"].ToString() == "200 OK");
 }