stavros-s
2/19/2013 - 1:26 PM

OpenSubtitles.org login operations

OpenSubtitles.org login operations

public class OSdbLoginOperations
{

        private const string TxtUrl 
            = "http://api.opensubtitles.org/xml-rpc";


        internal static IOpenSubtitlesRemoteFunctions Proxy;

        public static string Token 
            = "#";


        public bool ServerInfo()
        {

            CreateProxy();

            try
            {
                Proxy.ServerInfo();
                return true;
            }
            catch (Exception ex)
            {

                Debugger.LogMessageToFile
                    (ex.Message);

                return false;

            }

        }


        public LoginResult SiteLogin()
        {

            CreateProxy();

            const string userAgent
                = "OS Test User Agent";

            LoginResult loginresult
                = Proxy.LogIn
                (string.Empty,
                 string.Empty,
                 "eng",
                 userAgent);

            return loginresult;
        }



        private static void CreateProxy()
        {

            Proxy = XmlRpcProxyGen
                .Create<IOpenSubtitlesRemoteFunctions>();

            Proxy.Timeout = 5000;
            
            Proxy.UserAgent
                = "Mozilla/5.0" +
                  " (Windows; U; Windows NT 5.1;" +
                  " en-US; rv:1.8.1.4)" +
                  " Gecko/20070515 Firefox/2.0.0.4";


            Proxy.UserAgent
                = "OS Test User Agent";
            
            Proxy.Url = TxtUrl;
        
        }


}