Пример #1
0
        /// <summary>
        /// Gets the current MakeMKV Key from the API
        /// </summary>
        /// <returns>MakeMKV Key (null on problems)</returns>
        private static string GetKey()
        {
            HttpWebRequest WReq = WebRequest.CreateHttp("https://cable.ayra.ch/makemkv/api.php?raw");
            WebResponse    WRes;

            //If you modify the tool, please add some personal twist to the user agent string
            WReq.UserAgent = string.Format("MakeMKV-Tool/{0} ({1}/{2};{3})",
                                           GetVersion(),
                                           Environment.OSVersion.Platform,
                                           Environment.OSVersion.Version,
                                           Environment.OSVersion.VersionString);
            try
            {
                WRes = WReq.GetResponse();
            }
            catch
            {
                return(null);
            }
            using (WRes)
            {
                using (var S = WRes.GetResponseStream())
                {
                    using (var SR = new StreamReader(S))
                    {
                        return(SR.ReadToEnd().Trim());
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Gets the current MakeMKV Key from the API
        /// </summary>
        /// <returns>MakeMKV Key (null on problems)</returns>
        private static MakeMKV GetKey()
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            HttpWebRequest WReq = WebRequest.CreateHttp("https://cable.ayra.ch/makemkv/api.php?xml");
            WebResponse    WRes;

            //If you modify the tool, please add some personal twist to the user agent string
            WReq.UserAgent = string.Format("AyrA/MakeMKVUpdater-{0} ({1}/{2};{3}) +https://github.com/AyrA/MakeMKV",
                                           Settings.GetVersion(),
                                           Environment.OSVersion.Platform,
                                           Environment.OSVersion.Version,
                                           Environment.OSVersion.VersionString);
            try
            {
                WRes = WReq.GetResponse();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Print(ex.Message);
                return(default(MakeMKV));
            }
            using (WRes)
            {
                using (var S = WRes.GetResponseStream())
                {
                    using (var SR = new StreamReader(S))
                    {
                        var Ser = new XmlSerializer(typeof(MakeMKV));
                        try
                        {
                            return((MakeMKV)Ser.Deserialize(SR));
                        }
                        catch
                        {
                            return(default(MakeMKV));
                        }
                    }
                }
            }
        }