Exemplo n.º 1
0
        public PebbleApp emery;   //Pebble Time 2

        public void Set(PebbleApp app, WatchHardware hardware)
        {
            switch (hardware)
            {
            case WatchHardware.aplite:
                aplite = app;
                break;

            case WatchHardware.basalt:
                basalt = app;
                break;

            case WatchHardware.chalk:
                chalk = app;
                break;

            case WatchHardware.diorite:
                diorite = app;
                break;

            case WatchHardware.emery:
                emery = app;
                break;
            }
        }
Exemplo n.º 2
0
 private static void QueueAndChangeFilename(ref string path, PebbleApp app, WatchHardware hardware, string name)
 {
     if (path != null)
     {
         if (path.Length > 2)
         {
             string save   = CreateFilename(name, hardware, app);
             string newUrl = "%rootUrl%files/" + app.id + "/" + hardware.ToString() + "/" + name;
             Program.AddWebAsset(save, path);
             path = newUrl;
         }
     }
 }
Exemplo n.º 3
0
        public static PebbleApp[] GetPage(int offset, WatchHardware hardware, FetchType type, int limit = 100)
        {
            //Create a GET request here and get the data.
            string url = "https://api2.getpebble.com/v2/apps/collection/all/" + type.ToString().Replace('_', '-') + "?platform=all&hardware=" + hardware.ToString() + "&filter_hardware=false&image_ratio=1&limit=" + limit.ToString() + "&offset=" + offset.ToString();
            //Request
            string raw = DoGetRequest(url);

            //Save
            SaveAsset(savePath + "raw_pages\\" + type.ToString() + "_" + hardware.ToString() + "_" + offset.ToString() + ".json", Encoding.UTF8.GetBytes(raw));
            //Deserialize JSON.
            PebbleApp_Page page = (PebbleApp_Page)DeserializeObject(raw, typeof(PebbleApp_Page));

            //Extract data and return it
            return(page.data);
        }
Exemplo n.º 4
0
 public static void UpdateApp(PebbleApp app, WatchHardware hardware)
 {
     if (rawApps.ContainsKey(app.id))
     {
         //Update
         rawApps[app.id].Set(app, hardware);
     }
     else
     {
         //Add
         PebbleAppInternal i = new PebbleAppInternal();
         i.Set(app, hardware);
         rawApps.Add(app.id, i);
     }
 }
Exemplo n.º 5
0
        public static PebbleApp[] GetAppsForHardware(FetchType type, WatchHardware hardware, int max = -1)
        {
            List <PebbleApp> found = new List <PebbleApp>();

            while (true)
            {
                PebbleApp[] got = GetPage(found.Count, hardware, type);
                found.AddRange(got);
                //Refresh the UI or something
                if ((max != -1 && found.Count > max) || got.Length < 100)
                {
                    break;
                }
            }
            return(found.ToArray());
        }
Exemplo n.º 6
0
        public static void SeekEntireType(FetchType type)
        {
            int platform = 0;

            while (platform < 5)
            {
                //Ran for each platform
                WatchHardware hw = (WatchHardware)platform;
                Console.WriteLine("Getting apps for " + type.ToString() + " on hardware " + hw.ToString());
                //Get apps and add them
                foreach (PebbleApp app in GetAppsForHardware(type, hw))
                {
                    UpdateApp(app, hw);
                }
                platform++;
            }
        }
Exemplo n.º 7
0
 private static string CreateFilename(string name, WatchHardware hardware, PebbleApp app)
 {
     return(Program.savePath + "files\\" + app.id + "\\" + hardware.ToString() + "\\" + name);
 }