Beispiel #1
0
        public static PebbleAppOutput Import(PebbleAppInternal i)
        {
            //This function is really gross!
            PebbleAppOutput o = new PebbleAppOutput();
            //Copy and convert when needed
            PebbleApp r = i.basalt; //Refrence for most data.

            if (r == null)
            {
                r = i.diorite;
            }
            if (r == null)
            {
                r = i.emery;
            }
            if (r == null)
            {
                r = i.chalk;
            }
            if (r == null)
            {
                r = i.aplite;
            }
            if (r == null)
            {
                //I give up. No platforms
                Console.WriteLine("App was skipped because it has NO valid platforms. How did it even get here!?");
            }

            o.author         = r.author;
            o.category_id    = r.category_id;
            o.category_name  = r.category_name;
            o.category_color = r.category_color;
            o.changelog      = r.changelog;
            o.companions     = r.companions;
            o.compatibility  = r.compatibility;
            o.created_at     = r.created_at;
            o.description    = r.description;
            o.developer_id   = r.developer_id;
            o.header_images  = r.header_images;
            o.hearts         = r.hearts;
            o.id             = r.id;
            o.links          = r.links;
            o.published_date = r.published_date;
            o.source         = r.source;
            o.title          = r.title;
            o.type           = r.type;
            o.uuid           = r.uuid;
            o.website        = r.website;

            //Convert
            o.icon_image = new PebbleAppOutput_IconImages();
            if (i.aplite != null)
            {
                o.icon_image.aplite = i.aplite.icon_image;
            }
            if (i.basalt != null)
            {
                o.icon_image.basalt = i.basalt.icon_image;
            }
            if (i.chalk != null)
            {
                o.icon_image.chalk = i.chalk.icon_image;
            }
            if (i.diorite != null)
            {
                o.icon_image.diorite = i.diorite.icon_image;
            }
            if (i.emery != null)
            {
                o.icon_image.emery = i.emery.icon_image;
            }
            //Convert
            o.latest_release = new PebbleAppOutput_Releases();
            if (i.aplite != null)
            {
                o.latest_release.aplite = i.aplite.latest_release;
            }
            if (i.basalt != null)
            {
                o.latest_release.basalt = i.basalt.latest_release;
            }
            if (i.chalk != null)
            {
                o.latest_release.chalk = i.chalk.latest_release;
            }
            if (i.diorite != null)
            {
                o.latest_release.diorite = i.diorite.latest_release;
            }
            if (i.emery != null)
            {
                o.latest_release.emery = i.emery.latest_release;
            }
            //Convert
            o.list_image = new PebbleAppOutput_ListImages();
            if (i.aplite != null)
            {
                o.list_image.aplite = i.aplite.list_image;
            }
            if (i.basalt != null)
            {
                o.list_image.basalt = i.basalt.list_image;
            }
            if (i.chalk != null)
            {
                o.list_image.chalk = i.chalk.list_image;
            }
            if (i.diorite != null)
            {
                o.list_image.diorite = i.diorite.list_image;
            }
            if (i.emery != null)
            {
                o.list_image.emery = i.emery.list_image;
            }
            //Convert
            o.screenshot_images = new PebbleAppOutput_ScreenshotImages();
            if (i.aplite != null)
            {
                o.screenshot_images.aplite = i.aplite.screenshot_images;
            }
            if (i.basalt != null)
            {
                o.screenshot_images.basalt = i.basalt.screenshot_images;
            }
            if (i.chalk != null)
            {
                o.screenshot_images.chalk = i.chalk.screenshot_images;
            }
            if (i.diorite != null)
            {
                o.screenshot_images.diorite = i.diorite.screenshot_images;
            }
            if (i.emery != null)
            {
                o.screenshot_images.emery = i.emery.screenshot_images;
            }

            //Queue asset downloads
            if (o.icon_image.aplite != null)
            {
                QueueAndChangeFilename(ref o.icon_image.aplite._48x48, r, WatchHardware.aplite, "icon.png");
            }
            if (o.latest_release.aplite != null)
            {
                QueueAndChangeFilename(ref o.latest_release.aplite.pbw_file, r, WatchHardware.aplite, "app.pbw");
            }
            if (o.list_image.aplite != null)
            {
                QueueAndChangeFilename(ref o.list_image.aplite._144x144, r, WatchHardware.aplite, "list.png");
            }

            if (o.icon_image.basalt != null)
            {
                QueueAndChangeFilename(ref o.icon_image.basalt._48x48, r, WatchHardware.basalt, "icon.png");
            }
            if (o.latest_release.basalt != null)
            {
                QueueAndChangeFilename(ref o.latest_release.basalt.pbw_file, r, WatchHardware.basalt, "app.pbw");
            }
            if (o.list_image.basalt != null)
            {
                QueueAndChangeFilename(ref o.list_image.basalt._144x144, r, WatchHardware.basalt, "list.png");
            }

            if (o.icon_image.chalk != null)
            {
                QueueAndChangeFilename(ref o.icon_image.chalk._48x48, r, WatchHardware.chalk, "icon.png");
            }
            if (o.latest_release.chalk != null)
            {
                QueueAndChangeFilename(ref o.latest_release.chalk.pbw_file, r, WatchHardware.chalk, "app.pbw");
            }
            if (o.list_image.chalk != null)
            {
                QueueAndChangeFilename(ref o.list_image.chalk._144x144, r, WatchHardware.chalk, "list.png");
            }

            if (o.icon_image.diorite != null)
            {
                QueueAndChangeFilename(ref o.icon_image.diorite._48x48, r, WatchHardware.diorite, "icon.png");
            }
            if (o.latest_release.diorite != null)
            {
                QueueAndChangeFilename(ref o.latest_release.diorite.pbw_file, r, WatchHardware.diorite, "app.pbw");
            }
            if (o.list_image.diorite != null)
            {
                QueueAndChangeFilename(ref o.list_image.diorite._144x144, r, WatchHardware.diorite, "list.png");
            }

            if (o.icon_image.emery != null)
            {
                QueueAndChangeFilename(ref o.icon_image.emery._48x48, r, WatchHardware.emery, "icon.png");
            }
            if (o.latest_release.emery != null)
            {
                QueueAndChangeFilename(ref o.latest_release.emery.pbw_file, r, WatchHardware.emery, "app.pbw");
            }
            if (o.list_image.emery != null)
            {
                QueueAndChangeFilename(ref o.list_image.emery._144x144, r, WatchHardware.emery, "list.png");
            }



            int ii = 0;

            while (ii < 50)
            {
                //Change each screenshot
                string name = "screenshot_" + ii.ToString() + ".png";

                if (o.screenshot_images.aplite != null)
                {
                    if (ii < o.screenshot_images.aplite.Length)
                    {
                        QueueAndChangeFilename(ref o.screenshot_images.aplite[ii]._144x168, r, WatchHardware.aplite, name);
                    }
                }
                if (o.screenshot_images.basalt != null)
                {
                    if (ii < o.screenshot_images.basalt.Length)
                    {
                        QueueAndChangeFilename(ref o.screenshot_images.basalt[ii]._144x168, r, WatchHardware.basalt, name);
                    }
                }
                if (o.screenshot_images.chalk != null)
                {
                    if (ii < o.screenshot_images.chalk.Length)
                    {
                        QueueAndChangeFilename(ref o.screenshot_images.chalk[ii]._144x168, r, WatchHardware.chalk, name);
                    }
                }
                if (o.screenshot_images.diorite != null)
                {
                    if (ii < o.screenshot_images.diorite.Length)
                    {
                        QueueAndChangeFilename(ref o.screenshot_images.diorite[ii]._144x168, r, WatchHardware.diorite, name);
                    }
                }
                if (o.screenshot_images.emery != null)
                {
                    if (ii < o.screenshot_images.emery.Length)
                    {
                        QueueAndChangeFilename(ref o.screenshot_images.emery[ii]._144x168, r, WatchHardware.emery, name);
                    }
                }
                ii++;
            }

            //Return
            return(o);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            while (true)
            {
                Console.WriteLine("PebbleRipper 3 by RomanPort");
                Console.WriteLine("\r\nPlease copy a folder to place files. Make sure it is empty and has more than 5 GB of free space. You can press the right click button to paste.");
                savePath = Console.ReadLine().TrimEnd('\\') + "\\";
                Console.Clear();
                if (Directory.Exists(savePath))
                {
                    break;
                }
                else
                {
                    Console.WriteLine("That folder wasn't found. \r\n");
                }
            }
            Console.Clear();
            Console.WriteLine("Finding apps...");

            SeekAll();
            Console.WriteLine("Converting apps...");
            List <PebbleAppOutput> output = new List <PebbleAppOutput>();

            rawApps.Values.AsParallel().ForAll(delegate(PebbleAppInternal app)
            {
                var o = PebbleAppOutput.Import(app);
                lock (output)
                {
                    output.Add(o);
                }
            });
            Console.WriteLine("\r\nExporting and saving database... ");
            //Save
            string ser = SerializeObject(output);

            File.WriteAllText(savePath + "data.json", ser);


            Console.WriteLine("\r\nDownloading assets... (" + assets.Count + " assets queued)");

            Console.Write("\r\nPlease wait.");
            Thread updateThread = new Thread(new ThreadStart(UpdateDownloadProgress));

            updateThread.Start();

            assets.AsParallel().ForAll(delegate(AssetToDownload asset)
            {
                try
                {
                    //Make folder
                    string[] paths = asset.filename.Split('\\');
                    Directory.CreateDirectory(asset.filename.Substring(0, asset.filename.Length - paths[paths.Length - 1].Length));
                    //Download
                    using (var client = new WebClient())
                    {
                        client.DownloadFile(asset.url, asset.filename);
                    }
                    asset.done = true;
                }
                catch (Exception ex)
                {
                    assetFails.Add("Failed to download URL at " + asset.url + " with filename " + asset.filename + " with error " + ex.Message + "\r\n");
                    asset.done = true;
                }
            });
            //Write errors
            File.WriteAllLines(savePath + "errors.txt", assetFails.ToArray());
            //Stop thread
            updateThread.Abort();
            Console.WriteLine("Done. " + assetFails.Count + " download errors occurred. Check /errors.txt for more info.");
            Console.ReadLine();
        }