Exemple #1
0
        public static void Main(string[] args)
        {
            var wc = new WebClient();

            Console.WriteLine("Initialized Pebble Language Downloader. By github/ardaozkal");
            Console.WriteLine("Rest in Peace, Pebble.");
            try
            {
                var LanguagesFile = wc.DownloadString("http://lp.getpebble.com/v1/languages");
                Console.WriteLine("Successfully downloaded language file. Attempting to write that in a file called \"languages.json\".");
                File.WriteAllText("languages.json", LanguagesFile);
                Console.WriteLine("Successfully wrote down language file. Starting download of language files.");
                var LanguagesList = StringOperations.FindAllBetween(LanguagesFile, "\"file\":\"", "\"", true);
                foreach (var language in LanguagesList)
                {
                    Console.WriteLine("Downloading: " + language);
                    var FileName = StringOperations.After(language, "/", true, true);
                    wc.DownloadFile(language, FileName);
                }
                Console.WriteLine("Successfully downloaded everything.");
            }
            catch
            {
                Console.WriteLine("Couldn't download language file. Rip pebble servers.");
            }
        }
        public static void Main(string[] args)
        {
            var wc = new WebClient();

            Console.WriteLine("Initialized Pebble Firmware Downloader. By github/ardaozkal");
            Console.WriteLine("Rest in Peace, Pebble.");
            foreach (var hardwarevariation in hardwarevariations)
            {
                foreach (var releasechannel in releasechannels)
                {
                    var currentlink = link.Replace("%1", hardwarevariation).Replace("%2", releasechannel);
                    try
                    {
                        Console.WriteLine("Trying to download json: " + currentlink);
                        var thejson = wc.DownloadString(currentlink);

                        if (!Directory.Exists(hardwarevariation))
                        {
                            Directory.CreateDirectory(hardwarevariation);
                        }

                        if (!Directory.Exists(hardwarevariation + "/" + releasechannel))
                        {
                            Directory.CreateDirectory(hardwarevariation + "/" + releasechannel);
                        }

                        var dirdiff = hardwarevariation + "/" + releasechannel + "/";

                        File.WriteAllText(dirdiff + "latest.json", thejson);

                        var FirmwaresList = StringOperations.FindAllBetween(thejson, "\"url\": \"", "\"", true);
                        foreach (var firmware in FirmwaresList)
                        {
                            Console.WriteLine("Downloading: " + firmware);
                            var FileName = dirdiff + StringOperations.After(firmware, "/", true, true);
                            wc.DownloadFile(firmware, FileName);
                        }
                    }
                    catch
                    {
                        Console.WriteLine("Error on " + currentlink);
                    }
                }
            }
        }