Erwin %!s(int64=5) %!d(string=hai) anos
pai
achega
e3bb3abab2
Modificáronse 6 ficheiros con 256 adicións e 163 borrados
  1. 10 1
      Cargo.toml
  2. 124 124
      accounts.json
  3. BIN=BIN
      guntrader
  4. 1 15
      src/main.rs
  5. 50 23
      src/query.rs
  6. 71 0
      src/test.rs

+ 10 - 1
Cargo.toml

@@ -3,6 +3,7 @@ name = "guntrader"
 version = "0.1.0"
 authors = ["Johann Woelper <woelper@gmail.com>"]
 edition = "2018"
+default-run = "guntrader"
 
 [dependencies]
 reqwest = "0.9.18"
@@ -19,4 +20,12 @@ url = "*"
 [dependencies.rocket_contrib]
 version = "0.4.1"
 default-features = false
-features = ["json", "serve"]
+features = ["json", "serve"]
+
+[[bin]]
+name = "guntrader"
+path = "src/main.rs"
+
+[[bin]]
+name = "test"
+path = "src/test.rs"

+ 124 - 124
accounts.json

@@ -1,90 +1,132 @@
 {
+  "test": {
+    "queries": {
+      "http://www.egun.de/market/list_items.php?mode=qry&plusdescr=off&query=schusssichere+weste": {
+        "auctions": {
+          "http://egun.de/market/item.php?id=7567346": {
+            "price": 96.0,
+            "desc": "Stichschutzweste-Stichschutz-schusssichere-k",
+            "gcal": "http://www.google.com/calendar/event?action=TEMPLATE&dates=20190805T165100/20190805T165100&text=Stichschutzweste-Stichschutz-schusssichere-k&location=&details=",
+            "thumb": "http://egun.de/market/cache/aucimg/100x100/5.7567346.1031537147.jpg",
+            "remaining": 863700,
+            "url": "http://egun.de/market/item.php?id=7567346",
+            "timestamp": 1565016676,
+            "is_price_final": false
+          }
+        },
+        "avg_price": 96.0
+      }
+    }
+  },
   "johann": {
     "queries": {
-      "http://www.egun.de/market/list_items.php?mode=qry&plusdescr=off&query=m14+luxdef&ewb=1&minprice=200": {
-        "auctions": {},
-        "avg_price": null
-      },
       "http://www.egun.de/market/list_items.php?mode=qry&query=308+enfield&plusdescr=off&wheremode=and&ewb=1": {
         "auctions": {
           "http://egun.de/market/item.php?id=7545805": {
             "price": 412.0,
             "desc": "Seltene Lee Enfield Ishapore 2A1 im Kal. 308 Win",
             "gcal": "",
-            "thumb": "http://egun.de/market/cache/aucimg/64x64/0.7545805.565137928.jpg",
+            "thumb": "http://egun.de/market/cache/aucimg/100x100/0.7545805.565137928.jpg",
             "remaining": 0,
             "url": "http://egun.de/market/item.php?id=7545805",
             "timestamp": 0,
             "is_price_final": true
           },
-          "http://egun.de/market/item.php?id=7547250": {
-            "price": 482.0,
-            "desc": "Original Enfield No4 Conversion auf 7.62×51mm NATO/ 308 Große Bilder",
-            "gcal": "http://www.google.com/calendar/event?action=TEMPLATE&dates=20190802T221200/20190802T221200&text=Original+Enfield+No4+Conversion+auf+7.62%C3%9751mm+NATO%2F+308+Gro%C3%9Fe+Bilder&location=&details=",
-            "thumb": "http://egun.de/market/images/picture.gif",
-            "remaining": 346800,
-            "url": "http://egun.de/market/item.php?id=7547250",
-            "timestamp": 1564776777,
-            "is_price_final": false
-          },
           "http://egun.de/market/item.php?id=7550217": {
             "price": 1069.0,
             "desc": "Rep. - Büchse .308 Win.; Enfield AIA M10 No.4 Mk.IV top Präzision Sniper Einzelstück selten Rarität",
             "gcal": "http://www.google.com/calendar/event?action=TEMPLATE&dates=20190716T211100/20190716T211100&text=Rep.+-+B%C3%BCchse+.308+Win.%3B+Enfield+AIA+M10+No.4+Mk.IV+top+Pr%C3%A4zision+Sniper+Einzelst%C3%BCck+selten+Rarit%C3%A4t&location=&details=",
-            "thumb": "http://egun.de/market/cache/aucimg/64x64/4.7550217.1231953745.jpg",
+            "thumb": "http://egun.de/market/cache/aucimg/100x100/4.7550217.1231953745.jpg",
             "remaining": 80100,
             "url": "http://egun.de/market/item.php?id=7550217",
             "timestamp": 1563304315,
             "is_price_final": true
+          },
+          "http://egun.de/market/item.php?id=7547250": {
+            "price": 483.0,
+            "desc": "Original Enfield No4 Conversion auf 7.62×51mm NATO/ 308 Große Bilder",
+            "gcal": "http://www.google.com/calendar/event?action=TEMPLATE&dates=20190802T221300/20190802T221300&text=Original+Enfield+No4+Conversion+auf+7.62%C3%9751mm+NATO%2F+308+Gro%C3%9Fe+Bilder&location=&details=",
+            "thumb": "http://egun.de/market/cache/aucimg/100x100/1.7547250.734856355.jpg",
+            "remaining": 284400,
+            "url": "http://egun.de/market/item.php?id=7547250",
+            "timestamp": 1564776793,
+            "is_price_final": false
           }
         },
         "avg_price": 654.3333
       },
-      "http://www.egun.de/market/list_items.php?mode=qry&plusdescr=off&query=sig+550&ewb=1&minprice=250&type=1": {
+      "http://www.egun.de/market/list_items.php?mode=qry&plusdescr=off&query=m14+luxdef&ewb=1&minprice=200": {
+        "auctions": {},
+        "avg_price": null
+      },
+      "http://www.egun.de/market/list_items.php?mode=qry&query=m305&plusdescr=off&wheremode=and&ewb=1": {
+        "auctions": {},
+        "avg_price": null
+      },
+      "http://www.egun.de/market/list_items.php?mode=qry&plusdescr=off&query=Steyr+scout&ewb=1": {
         "auctions": {
-          "http://egun.de/market/item.php?id=7566331": {
-            "price": 3850.0,
-            "desc": "SIG 550 Sport 223 Rem. Set Top viel Zubehör",
-            "gcal": "http://www.google.com/calendar/event?action=TEMPLATE&dates=20190824T192600/20190824T192600&text=SIG+550+Sport+223+Rem.+Set+Top+viel+Zubeh%C3%B6r&location=&details=",
-            "thumb": "http://egun.de/market/images/picture.gif",
-            "remaining": 2237640,
-            "url": "http://egun.de/market/item.php?id=7566331",
-            "timestamp": 1566667618,
+          "http://egun.de/market/item.php?id=7038461": {
+            "price": 595.0,
+            "desc": "Rep.Büchse .22lr Steyr Mannlicher SCOUT RFR 510mm Lauf/ Mündungsgewinde (1/2-20) Geradezug (.22lfB)",
+            "gcal": "http://www.google.com/calendar/event?action=TEMPLATE&dates=20190812T185300/20190812T185300&text=Rep.B%C3%BCchse+.22lr+Steyr+Mannlicher+SCOUT+RFR+510mm+Lauf%2F+M%C3%BCndungsgewinde+%281%2F2-20%29+Geradezug+%28.22lfB%29&location=&details=",
+            "thumb": "http://egun.de/market/cache/aucimg/100x100/2.7038461.546939400.jpg",
+            "remaining": 1136400,
+            "url": "http://egun.de/market/item.php?id=7038461",
+            "timestamp": 1565628792,
             "is_price_final": false
-          },
+          }
+        },
+        "avg_price": 595.0
+      },
+      "http://www.egun.de/market/list_items.php?mode=qry&query=smith+wesson+r8&plusdescr=off&wheremode=and&ewb=1": {
+        "auctions": {},
+        "avg_price": null
+      },
+      "http://www.egun.de/market/list_items.php?mode=qry&plusdescr=off&query=sig+550&ewb=1&minprice=250&type=1": {
+        "auctions": {
           "http://egun.de/market/item.php?id=7550521": {
-            "price": 1385.0,
+            "price": 1395.0,
             "desc": "Selbstladebüchse SIG Sport 550 Kal. .223 rem",
-            "gcal": "http://www.google.com/calendar/event?action=TEMPLATE&dates=20190806T122600/20190806T122600&text=Selbstladeb%C3%BCchse+SIG+Sport+550+Kal.+.223+rem&location=&details=",
-            "thumb": "http://egun.de/market/cache/aucimg/64x64/5.7550521.99022556.jpg",
-            "remaining": 657240,
+            "gcal": "http://www.google.com/calendar/event?action=TEMPLATE&dates=20190806T122700/20190806T122700&text=Selbstladeb%C3%BCchse+SIG+Sport+550+Kal.+.223+rem&location=&details=",
+            "thumb": "http://egun.de/market/cache/aucimg/100x100/5.7550521.99022556.jpg",
+            "remaining": 594840,
             "url": "http://egun.de/market/item.php?id=7550521",
-            "timestamp": 1565087218,
+            "timestamp": 1565087234,
+            "is_price_final": false
+          },
+          "http://egun.de/market/item.php?id=7566331": {
+            "price": 3900.0,
+            "desc": "SIG 550 Sport 223 Rem. Set Top viel Zubehör",
+            "gcal": "http://www.google.com/calendar/event?action=TEMPLATE&dates=20190824T192700/20190824T192700&text=SIG+550+Sport+223+Rem.+Set+Top+viel+Zubeh%C3%B6r&location=&details=",
+            "thumb": "http://egun.de/market/cache/aucimg/100x100/4.7566331.1312216270.jpg",
+            "remaining": 2175240,
+            "url": "http://egun.de/market/item.php?id=7566331",
+            "timestamp": 1566667634,
             "is_price_final": false
           }
         },
         "avg_price": 2617.5
       },
-      "http://www.egun.de/market/list_items.php?mode=qry&plusdescr=off&query=accuracy+international&minprice=250&type=1": {
+      "http://www.egun.de/market/list_items.php?mode=qry&plusdescr=off&query=stgw+57&ewb=1": {
+        "auctions": {},
+        "avg_price": null
+      },
+      "http://www.egun.de/market/list_items.php?mode=qry&plusdescr=off&query=SG+510&ewb=1": {
         "auctions": {
-          "http://egun.de/market/item.php?id=7557075": {
-            "price": 605.0,
-            "desc": "Accuracy International klappbarer Schaft Remington 700 short action (G22 Schaft)",
-            "gcal": "http://www.google.com/calendar/event?action=TEMPLATE&dates=20190807T211800/20190807T211800&text=Accuracy+International+klappbarer+Schaft+Remington+700+short+action+%28G22+Schaft%29&location=&details=",
-            "thumb": "http://egun.de/market/images/picture.gif",
-            "remaining": 775560,
-            "url": "http://egun.de/market/item.php?id=7557075",
-            "timestamp": 1565205539,
+          "http://egun.de/market/item.php?id=7038461": {
+            "price": 595.0,
+            "desc": "Rep.Büchse .22lr Steyr Mannlicher SCOUT RFR 510mm Lauf/ Mündungsgewinde (1/2-20) Geradezug (.22lfB)",
+            "gcal": "http://www.google.com/calendar/event?action=TEMPLATE&dates=20190812T185300/20190812T185300&text=Rep.B%C3%BCchse+.22lr+Steyr+Mannlicher+SCOUT+RFR+510mm+Lauf%2F+M%C3%BCndungsgewinde+%281%2F2-20%29+Geradezug+%28.22lfB%29&location=&details=",
+            "thumb": "http://egun.de/market/cache/aucimg/100x100/2.7038461.546939400.jpg",
+            "remaining": 1136400,
+            "url": "http://egun.de/market/item.php?id=7038461",
+            "timestamp": 1565628794,
             "is_price_final": false
           }
         },
-        "avg_price": 605.0
-      },
-      "http://www.egun.de/market/list_items.php?mode=qry&plusdescr=off&query=stgw+57&ewb=1": {
-        "auctions": {},
-        "avg_price": null
+        "avg_price": 595.0
       },
-      "http://www.egun.de/market/list_items.php?mode=qry&query=m305&plusdescr=off&wheremode=and&ewb=1": {
+      "http://www.egun.de/market/list_items.php?mode=qry&plusdescr=off&query=m1a&ewb=1&type=1": {
         "auctions": {},
         "avg_price": null
       },
@@ -94,48 +136,29 @@
             "price": 149.0,
             "desc": "Sig Arms SHR 970 Magazin, 30/06 ,7x64, 9,3x62 usw. Neu",
             "gcal": "http://www.google.com/calendar/event?action=TEMPLATE&dates=20190806T083500/20190806T083500&text=Sig+Arms+SHR+970+Magazin%2C+30%2F06+%2C7x64%2C+9%2C3x62+usw.+Neu&location=&details=",
-            "thumb": "http://egun.de/market/cache/aucimg/64x64/2.7506617.943962973.jpg",
-            "remaining": 643380,
+            "thumb": "http://egun.de/market/cache/aucimg/100x100/2.7506617.943962973.jpg",
+            "remaining": 580920,
             "url": "http://egun.de/market/item.php?id=7506617",
-            "timestamp": 1565073357,
+            "timestamp": 1565073313,
             "is_price_final": false
           }
         },
         "avg_price": 149.0
       },
-      "http://www.egun.de/market/list_items.php?mode=qry&plusdescr=off&query=SG+510&ewb=1": {
-        "auctions": {
-          "http://egun.de/market/item.php?id=7038461": {
-            "price": 595.0,
-            "desc": "Rep.Büchse .22lr Steyr Mannlicher SCOUT RFR 510mm Lauf/ Mündungsgewinde (1/2-20) Geradezug (.22lfB)",
-            "gcal": "http://www.google.com/calendar/event?action=TEMPLATE&dates=20190812T185200/20190812T185200&text=Rep.B%C3%BCchse+.22lr+Steyr+Mannlicher+SCOUT+RFR+510mm+Lauf%2F+M%C3%BCndungsgewinde+%281%2F2-20%29+Geradezug+%28.22lfB%29&location=&details=",
-            "thumb": "http://egun.de/market/cache/aucimg/64x64/2.7038461.546939400.jpg",
-            "remaining": 1198800,
-            "url": "http://egun.de/market/item.php?id=7038461",
-            "timestamp": 1565628776,
-            "is_price_final": false
-          }
-        },
-        "avg_price": 595.0
-      },
-      "http://www.egun.de/market/list_items.php?mode=qry&plusdescr=off&query=Steyr+scout&ewb=1": {
+      "http://www.egun.de/market/list_items.php?mode=qry&plusdescr=off&query=accuracy+international&minprice=250&type=1": {
         "auctions": {
-          "http://egun.de/market/item.php?id=7038461": {
-            "price": 595.0,
-            "desc": "Rep.Büchse .22lr Steyr Mannlicher SCOUT RFR 510mm Lauf/ Mündungsgewinde (1/2-20) Geradezug (.22lfB)",
-            "gcal": "http://www.google.com/calendar/event?action=TEMPLATE&dates=20190812T185200/20190812T185200&text=Rep.B%C3%BCchse+.22lr+Steyr+Mannlicher+SCOUT+RFR+510mm+Lauf%2F+M%C3%BCndungsgewinde+%281%2F2-20%29+Geradezug+%28.22lfB%29&location=&details=",
-            "thumb": "http://egun.de/market/cache/aucimg/64x64/2.7038461.546939400.jpg",
-            "remaining": 1198800,
-            "url": "http://egun.de/market/item.php?id=7038461",
-            "timestamp": 1565628776,
+          "http://egun.de/market/item.php?id=7557075": {
+            "price": 610.0,
+            "desc": "Accuracy International klappbarer Schaft Remington 700 short action (G22 Schaft)",
+            "gcal": "http://www.google.com/calendar/event?action=TEMPLATE&dates=20190807T211900/20190807T211900&text=Accuracy+International+klappbarer+Schaft+Remington+700+short+action+%28G22+Schaft%29&location=&details=",
+            "thumb": "http://egun.de/market/cache/aucimg/100x100/3.7557075.185135632.jpg",
+            "remaining": 713160,
+            "url": "http://egun.de/market/item.php?id=7557075",
+            "timestamp": 1565205552,
             "is_price_final": false
           }
         },
-        "avg_price": 595.0
-      },
-      "http://www.egun.de/market/list_items.php?mode=qry&plusdescr=off&query=m1a&ewb=1&type=1": {
-        "auctions": {},
-        "avg_price": null
+        "avg_price": 605.0
       },
       "http://www.egun.de/market/list_items.php?mode=qry&plusdescr=off&query=aics+-magazin&minprice=350": {
         "auctions": {
@@ -143,17 +166,17 @@
             "price": 1392.0,
             "desc": "Accuracy International Chassis System (AICS-AX 2.0) FDE Remington 700 SA .308 Repetierbüchsen",
             "gcal": "http://www.google.com/calendar/event?action=TEMPLATE&dates=20190806T035100/20190806T035100&text=Accuracy+International+Chassis+System+%28AICS-AX+2.0%29+FDE+Remington+700+SA+.308+Repetierb%C3%BCchsen&location=&details=",
-            "thumb": "http://egun.de/market/images/picture.gif",
-            "remaining": 626280,
+            "thumb": "http://egun.de/market/cache/aucimg/100x100/0.7020521.1109967068.jpg",
+            "remaining": 563880,
             "url": "http://egun.de/market/item.php?id=7020521",
-            "timestamp": 1565056260,
+            "timestamp": 1565056274,
             "is_price_final": false
           },
           "http://egun.de/market/item.php?id=7547554": {
             "price": 1699.0,
             "desc": "Remington 700 Police .308Win. 66cm Lauf, AICS/Accuracy International Klappschaft, EBIARMS-Bremse",
             "gcal": "http://www.google.com/calendar/event?action=TEMPLATE&dates=20190808T131600/20190808T131600&text=Remington+700+Police+.308Win.+66cm+Lauf%2C+AICS%2FAccuracy+International+Klappschaft%2C+EBIARMS-Bremse&location=&details=",
-            "thumb": "http://egun.de/market/images/picture.gif",
+            "thumb": "http://egun.de/market/cache/aucimg/100x100/2.7547554.616577857.jpg",
             "remaining": 1184040,
             "url": "http://egun.de/market/item.php?id=7547554",
             "timestamp": 1565262974,
@@ -161,29 +184,6 @@
           }
         },
         "avg_price": 1545.5
-      },
-      "http://www.egun.de/market/list_items.php?mode=qry&query=smith+wesson+r8&plusdescr=off&wheremode=and&ewb=1": {
-        "auctions": {},
-        "avg_price": null
-      }
-    }
-  },
-  "test": {
-    "queries": {
-      "http://www.egun.de/market/list_items.php?mode=qry&plusdescr=off&query=schusssichere+weste": {
-        "auctions": {
-          "http://egun.de/market/item.php?id=7567346": {
-            "price": 95.0,
-            "desc": "Stichschutzweste-Stichschutz-schusssichere-k",
-            "gcal": "http://www.google.com/calendar/event?action=TEMPLATE&dates=20190805T165100/20190805T165100&text=Stichschutzweste-Stichschutz-schusssichere-k&location=&details=",
-            "thumb": "http://egun.de/market/images/picture.gif",
-            "remaining": 863700,
-            "url": "http://egun.de/market/item.php?id=7567346",
-            "timestamp": 1565016676,
-            "is_price_final": false
-          }
-        },
-        "avg_price": 95.0
       }
     }
   },
@@ -194,41 +194,41 @@
           "http://egun.de/market/item.php?id=7570916": {
             "price": 2100.0,
             "desc": "Desert Eagle 50 AE",
-            "gcal": "http://www.google.com/calendar/event?action=TEMPLATE&dates=20190803T175300/20190803T175300&text=Desert+Eagle+50+AE&location=&details=",
-            "thumb": "http://egun.de/market/images/picture.gif",
-            "remaining": 417660,
+            "gcal": "http://www.google.com/calendar/event?action=TEMPLATE&dates=20190803T175400/20190803T175400&text=Desert+Eagle+50+AE&location=&details=",
+            "thumb": "http://egun.de/market/cache/aucimg/100x100/1.7570916.713150939.jpg",
+            "remaining": 355260,
             "url": "http://egun.de/market/item.php?id=7570916",
-            "timestamp": 1564847634,
+            "timestamp": 1564847655,
             "is_price_final": false
           },
           "http://egun.de/market/item.php?id=7539610": {
             "price": 1510.0,
             "desc": "Desert Eagle IMI IXI Chro. 6 Zoll in .44 Mag.",
             "gcal": "",
-            "thumb": "http://egun.de/market/images/picture.gif",
+            "thumb": "http://egun.de/market/cache/aucimg/100x100/2.7539610.708605059.png",
             "remaining": 0,
             "url": "http://egun.de/market/item.php?id=7539610",
             "timestamp": 0,
             "is_price_final": true
           },
+          "http://egun.de/market/item.php?id=7565498": {
+            "price": 1035.0,
+            "desc": "Pistole IMI Magnum Research Desert Eagle Kal. .50 Action Express, Bj. 1995, mit Wechsellauf, schön!",
+            "gcal": "http://www.google.com/calendar/event?action=TEMPLATE&dates=20190818T214600/20190818T214600&text=Pistole+IMI+Magnum+Research+Desert+Eagle+Kal.+.50+Action+Express%2C+Bj.+1995%2C+mit+Wechsellauf%2C+sch%C3%B6n%21&location=&details=",
+            "thumb": "http://egun.de/market/cache/aucimg/100x100/3.7565498.164056026.jpg",
+            "remaining": 1665180,
+            "url": "http://egun.de/market/item.php?id=7565498",
+            "timestamp": 1566157575,
+            "is_price_final": false
+          },
           "http://egun.de/market/item.php?id=7310815": {
             "price": 2690.0,
             "desc": "IMI Desert Eagle Kal. .50AE in Silbern mit Gold, Abzug gemacht, verst. Visier, Holzgriff",
-            "gcal": "http://www.google.com/calendar/event?action=TEMPLATE&dates=20190811T174700/20190811T174700&text=IMI+Desert+Eagle+Kal.+.50AE+in+Silbern+mit+Gold%2C+Abzug+gemacht%2C+verst.+Visier%2C+Holzgriff&location=&details=",
-            "thumb": "http://egun.de/market/cache/aucimg/64x64/3.7310815.51406938.jpg",
-            "remaining": 1108500,
+            "gcal": "http://www.google.com/calendar/event?action=TEMPLATE&dates=20190811T174800/20190811T174800&text=IMI+Desert+Eagle+Kal.+.50AE+in+Silbern+mit+Gold%2C+Abzug+gemacht%2C+verst.+Visier%2C+Holzgriff&location=&details=",
+            "thumb": "http://egun.de/market/cache/aucimg/100x100/3.7310815.51406938.jpg",
+            "remaining": 1046100,
             "url": "http://egun.de/market/item.php?id=7310815",
-            "timestamp": 1565538474,
-            "is_price_final": false
-          },
-          "http://egun.de/market/item.php?id=7565498": {
-            "price": 1025.0,
-            "desc": "Pistole IMI Magnum Research Desert Eagle Kal. .50 Action Express, Bj. 1995, mit Wechsellauf, schön!",
-            "gcal": "http://www.google.com/calendar/event?action=TEMPLATE&dates=20190818T214500/20190818T214500&text=Pistole+IMI+Magnum+Research+Desert+Eagle+Kal.+.50+Action+Express%2C+Bj.+1995%2C+mit+Wechsellauf%2C+sch%C3%B6n%21&location=&details=",
-            "thumb": "http://egun.de/market/cache/aucimg/64x64/3.7565498.164056026.jpg",
-            "remaining": 1727580,
-            "url": "http://egun.de/market/item.php?id=7565498",
-            "timestamp": 1566157554,
+            "timestamp": 1565538495,
             "is_price_final": false
           }
         },

BIN=BIN
guntrader


+ 1 - 15
src/main.rs

@@ -56,21 +56,7 @@ fn daemon() {
 }
 
 fn main() {
-
-
-    // let mut accounts: HashMap<String, Account> = HashMap::new();
-    // let mut acc = Account::default();
-    // accounts.insert("test".to_string(), acc);
-
-    // let mut q = Query::default();
-    // let auction = Auction::default();
-    // q.auctions.insert("sdsd".to_string(), auction);
-
-    // let mut queries: HashMap<String, Query> = HashMap::new();
-    // queries.insert("http://bla".to_string(), q);
-
-    // let j = serde_json::to_string_pretty(&accounts).unwrap();
-    // print!("{}", j);
+    
 
     match File::open(DBFILE) {
         Ok(f) => {

+ 50 - 23
src/query.rs

@@ -19,6 +19,7 @@ pub struct Auction {
     pub is_price_final: bool,
 }
 
+
 impl Auction {
     fn update(&mut self) {
         // println!("now: {:?} auction: {:?}", Utc::now().with_timezone(&Local).timestamp(), self.timestamp);
@@ -26,9 +27,19 @@ impl Auction {
         self.is_price_final = Utc::now().with_timezone(&Local).timestamp() > self.timestamp;
         // self.price = price_from_auction(&self.url)
         // TODO: delete ^^ and enable lines below
-        if was_not_final != self.is_price_final {
-            self.price = price_from_auction(&self.url)
-        }
+        if cfg!(debug_assertions) {
+            dbg!(&self.price);
+        } 
+
+        *self = auction_details(&self);
+
+        // if was_not_final != self.is_price_final {
+        //     self.price = auction_details(&self.url);
+        //     if cfg!(debug_assertions) {
+        //         dbg!(&self.price);
+        //     } 
+
+        // }
     }
 }
 
@@ -48,7 +59,7 @@ impl Query {
     fn detect_expired(&self) -> HashMap<String, Auction> {
         self.auctions
             .iter()
-            .map(|(u, mut a)| {
+            .map(|(u, a)| {
                 let mut a1 = a.clone();
                 a1.update();
                 (u.clone(), a1)
@@ -73,6 +84,9 @@ impl Account {
                 (url.clone(), {
                     query.auctions.extend(auctions_from_url(&url));
                     query.avg_price = query.get_avg_price();
+                    if cfg!(debug_assertions) {
+                        // dbg!(&query);
+                    } 
                     query
                 })
             })
@@ -112,6 +126,8 @@ fn parse_remaining(timestring: &String) -> Option<Duration> {
 fn parse_price(price: &str) -> Option<f32> {
     price
         .to_string()
+        .replace("\n", "")
+        .replace("\t", "")
         .replace(".", "")
         .replace(",", ".")
         .replace(" EUR", "")
@@ -120,51 +136,62 @@ fn parse_price(price: &str) -> Option<f32> {
 }
 
 
-fn price_from_auction(url: &str) -> f32 {
+fn auction_details(auction: &Auction) -> Auction {
+    let mut updated_auction = auction.clone();
+
+
     let client = reqwest::Client::builder()
         .timeout(Some(core::time::Duration::from_secs(2)))
         .build()
         .unwrap();
 
 
-    match client.get(url).send() {
+    match client.get(&auction.url).send() {
         Ok(mut resp) => {
             if !resp.status().is_success() {
                 println!("ERR {:?}", resp.text());
-                
             }
 
             let text = resp.text().unwrap_or("".to_string());
 
             for node in Document::from_read(text.as_bytes())
                 .unwrap()
-                // .find(Name("a"))
-                // .filter(|n| n.attr("href").is_some())
-                // .filter(|n| n.attr("href").unwrap().contains("item.php?id="))
                 .find(Name("b"))
                 .flat_map(|x| x.children())
                 .map(|x| x.text())
                 .filter(|x| x.contains("EUR"))
-                
-                // .filter(|x| x.attr("bgcolor").is_some())
+            {
+                if let Some(p) = parse_price(&node) {
+                    updated_auction.price = p;
+                }
+            }
 
+            for node in Document::from_read(text.as_bytes())
+                .unwrap()
+                .find(Name("img"))
+                .filter(|x| x.attr("id") == Some("item_top_img"))
+                .map(|x| x.attr("src").unwrap_or("http://egun.de/market/images/picture.gif"))
+                // .filter(|x| x)
             {
-                let price: f32 = node
-                    .replace("\n", "")
-                    .replace("\t", "")
-                    .replace(".","")
-                    .replace(",",".")
-                    .replace(" EUR", "").parse().unwrap_or(0.0);
-                return price;
-                // Get auction name
-                
+                // dbg!(&node);
+                updated_auction.thumb = abs_image_url(node);
             }
+        
+        
         }
+
+        
+
+
         Err(e) => println!("{:?}", e),
     }
 
-    0.0
+    updated_auction
+
+}
 
+fn abs_image_url(rel_url: &str) -> String {
+    format!("http://egun.de/market/{}", rel_url)
 }
 
 
@@ -235,7 +262,7 @@ fn auctions_from_url(url: &str) -> HashMap<String, Auction> {
                         .collect::<Vec<_>>()
                         .get(0)
                     {
-                        auction.thumb = format!("http://egun.de/market/{}", img);
+                        auction.thumb = abs_image_url(img);
                     }
 
                     // get price

+ 71 - 0
src/test.rs

@@ -0,0 +1,71 @@
+#![feature(proc_macro_hygiene, decl_macro)]
+#[macro_use]
+extern crate serde_derive;
+#[macro_use]
+extern crate rocket;
+#[macro_use]
+extern crate rocket_contrib;
+#[macro_use]
+extern crate lazy_static;
+extern crate serde_json;
+
+// use serde_json;
+use std::collections::HashMap;
+use std::fs::File;
+use std::io::BufReader;
+use std::io::BufWriter;
+use std::sync::Mutex;
+use std::{thread, time};
+
+/// Fucking egun is a mess. It does not even use css and is built using tables. This is an attempt to parse it.
+mod query;
+use query::*;
+mod server;
+const DBFILE: &str = "accounts.json";
+
+
+lazy_static! {
+    static ref ACCOUNTS: Mutex<HashMap<String, Account>> = Mutex::new(HashMap::new());
+}
+
+
+fn daemon() {
+    println!(">>> Running update...");
+
+        let accounts_unlocked = ACCOUNTS.lock().unwrap().clone();
+
+        for (account_name, account) in accounts_unlocked {
+            dbg!(&account_name);
+            let mut accounts = ACCOUNTS.lock().unwrap();
+            accounts.insert(account_name.to_string(), account.updated());
+        }
+
+
+    let accounts_unlocked = ACCOUNTS.lock().unwrap();
+    let writer = BufWriter::new(File::create(DBFILE).unwrap());
+    serde_json::to_writer_pretty(writer, &*accounts_unlocked).unwrap();
+
+    println!(">>> Done.");
+}
+
+fn main() {
+    
+
+    match File::open(DBFILE) {
+        Ok(f) => {
+            match serde_json::from_reader::<_, HashMap<String, Account>>(BufReader::new(f)) {
+                Ok(accounts) => {
+                    {
+                        // Lock once, shove loaded ccounts in
+                        let mut accounts_unlocked = ACCOUNTS.lock().unwrap();
+                        *accounts_unlocked = accounts;
+                    }
+                    // start daemon before running web server
+                        daemon();
+                },
+                Err(e) => println!("Parsing account da'a has failed: {:?}", e)
+            }
+        }
+        Err(e) => println!("Opening accounts file failed. {:?}", e),
+    }
+}