cs2tracker 2.0.9__tar.gz → 2.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of cs2tracker might be problematic. Click here for more details.
- {cs2tracker-2.0.9 → cs2tracker-2.1.0}/PKG-INFO +1 -1
- {cs2tracker-2.0.9 → cs2tracker-2.1.0}/cs2tracker/_version.py +2 -2
- {cs2tracker-2.0.9 → cs2tracker-2.1.0}/cs2tracker/application.py +2 -2
- {cs2tracker-2.0.9 → cs2tracker-2.1.0}/cs2tracker/main.py +3 -1
- {cs2tracker-2.0.9 → cs2tracker-2.1.0}/cs2tracker/scraper.py +46 -15
- {cs2tracker-2.0.9 → cs2tracker-2.1.0}/cs2tracker.egg-info/PKG-INFO +1 -1
- {cs2tracker-2.0.9 → cs2tracker-2.1.0}/.flake8 +0 -0
- {cs2tracker-2.0.9 → cs2tracker-2.1.0}/.gitignore +0 -0
- {cs2tracker-2.0.9 → cs2tracker-2.1.0}/.isort.cfg +0 -0
- {cs2tracker-2.0.9 → cs2tracker-2.1.0}/.pre-commit-config.yaml +0 -0
- {cs2tracker-2.0.9 → cs2tracker-2.1.0}/LICENSE.md +0 -0
- {cs2tracker-2.0.9 → cs2tracker-2.1.0}/MANIFEST.in +0 -0
- {cs2tracker-2.0.9 → cs2tracker-2.1.0}/README.md +0 -0
- {cs2tracker-2.0.9 → cs2tracker-2.1.0}/cs2tracker/__init__.py +0 -0
- {cs2tracker-2.0.9 → cs2tracker-2.1.0}/cs2tracker/__main__.py +0 -0
- {cs2tracker-2.0.9 → cs2tracker-2.1.0}/cs2tracker/constants.py +0 -0
- {cs2tracker-2.0.9 → cs2tracker-2.1.0}/cs2tracker/data/config.ini +0 -0
- {cs2tracker-2.0.9 → cs2tracker-2.1.0}/cs2tracker.egg-info/SOURCES.txt +0 -0
- {cs2tracker-2.0.9 → cs2tracker-2.1.0}/cs2tracker.egg-info/dependency_links.txt +0 -0
- {cs2tracker-2.0.9 → cs2tracker-2.1.0}/cs2tracker.egg-info/entry_points.txt +0 -0
- {cs2tracker-2.0.9 → cs2tracker-2.1.0}/cs2tracker.egg-info/requires.txt +0 -0
- {cs2tracker-2.0.9 → cs2tracker-2.1.0}/cs2tracker.egg-info/top_level.txt +0 -0
- {cs2tracker-2.0.9 → cs2tracker-2.1.0}/pyproject.toml +0 -0
- {cs2tracker-2.0.9 → cs2tracker-2.1.0}/requirements.txt +0 -0
- {cs2tracker-2.0.9 → cs2tracker-2.1.0}/setup.cfg +0 -0
|
@@ -57,8 +57,8 @@ class Application:
|
|
|
57
57
|
|
|
58
58
|
def _edit_config(self):
|
|
59
59
|
subprocess.call([TEXT_EDITOR, CONFIG_FILE])
|
|
60
|
-
config = self.scraper.
|
|
61
|
-
self.scraper.
|
|
60
|
+
config = self.scraper.parse_config()
|
|
61
|
+
self.scraper.set_config(config)
|
|
62
62
|
|
|
63
63
|
def _draw_plot(self):
|
|
64
64
|
datesp, dollars, euros = self._parse_output()
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
|
|
1
3
|
import urllib3
|
|
2
4
|
from rich.console import Console
|
|
3
5
|
|
|
@@ -23,7 +25,7 @@ def main():
|
|
|
23
25
|
|
|
24
26
|
|
|
25
27
|
"""
|
|
26
|
-
+ f"Version: v{version} -
|
|
28
|
+
+ f"Version: v{version} - {datetime.today().strftime('%Y/%m/%d')} - Jannik Novak @ashiven_\n"
|
|
27
29
|
)
|
|
28
30
|
|
|
29
31
|
application = Application()
|
|
@@ -23,7 +23,7 @@ from .constants import (
|
|
|
23
23
|
OUTPUT_FILE,
|
|
24
24
|
)
|
|
25
25
|
|
|
26
|
-
MAX_LINE_LEN =
|
|
26
|
+
MAX_LINE_LEN = 72
|
|
27
27
|
PADDING_LEN = MAX_LINE_LEN // 2 - 1
|
|
28
28
|
PADDING = "-" * PADDING_LEN
|
|
29
29
|
|
|
@@ -60,8 +60,8 @@ class Scraper:
|
|
|
60
60
|
|
|
61
61
|
self.console = Console()
|
|
62
62
|
|
|
63
|
-
config = self.
|
|
64
|
-
self.
|
|
63
|
+
config = self.parse_config()
|
|
64
|
+
self.set_config(config)
|
|
65
65
|
|
|
66
66
|
def scrape_prices(self):
|
|
67
67
|
for capsule_page_url in CAPSULE_PAGES:
|
|
@@ -124,18 +124,22 @@ class Scraper:
|
|
|
124
124
|
)
|
|
125
125
|
|
|
126
126
|
def print_total(self):
|
|
127
|
-
usd_string =
|
|
127
|
+
usd_string = "USD Total".center(
|
|
128
|
+
MAX_LINE_LEN, "-"
|
|
129
|
+
) # f"{PADDING}USD Total{PADDING}"[:MAX_LINE_LEN]
|
|
128
130
|
self.console.print(f"[bold green]{usd_string}")
|
|
129
131
|
self.console.print(f"${self.total_price:.2f}")
|
|
130
132
|
|
|
131
133
|
self.total_price_euro = CurrencyConverter().convert(
|
|
132
134
|
self.total_price, "USD", "EUR"
|
|
133
135
|
)
|
|
134
|
-
eur_string =
|
|
136
|
+
eur_string = "EUR Total".center(
|
|
137
|
+
MAX_LINE_LEN, "-"
|
|
138
|
+
) # f"{PADDING}EUR Total{PADDING}"[:MAX_LINE_LEN]
|
|
135
139
|
self.console.print(f"[bold green]{eur_string}")
|
|
136
140
|
self.console.print(f"€{self.total_price_euro:.2f}")
|
|
137
141
|
end_string = f"{PADDING}{PADDING}{PADDING}"[:MAX_LINE_LEN]
|
|
138
|
-
self.console.print(f"[bold green]{end_string}")
|
|
142
|
+
self.console.print(f"[bold green]{end_string}\n")
|
|
139
143
|
|
|
140
144
|
def save_to_file(self):
|
|
141
145
|
now = datetime.datetime.now()
|
|
@@ -163,17 +167,32 @@ class Scraper:
|
|
|
163
167
|
writer.writerow([today, total])
|
|
164
168
|
writer.writerow([today, total_euro])
|
|
165
169
|
|
|
166
|
-
|
|
170
|
+
# reset total prices for next run
|
|
171
|
+
self.total_price = 0
|
|
172
|
+
self.total_price_euro = 0
|
|
173
|
+
|
|
174
|
+
def parse_config(self):
|
|
167
175
|
config = configparser.ConfigParser()
|
|
168
176
|
config.read(CONFIG_FILE)
|
|
169
177
|
return config
|
|
170
178
|
|
|
171
|
-
def
|
|
179
|
+
def set_config(self, config):
|
|
172
180
|
self.use_proxy = (
|
|
173
181
|
False if config.get("Proxy API Key", "Use_Proxy") == "False" else True
|
|
174
182
|
)
|
|
175
183
|
self.api_key = config.get("Proxy API Key", "API_Key")
|
|
176
184
|
|
|
185
|
+
# reset all quantities in case this is called at runtime (edit config)
|
|
186
|
+
self.case_quantities = []
|
|
187
|
+
self.rmr_quantities = []
|
|
188
|
+
self.stockholm_quantities = []
|
|
189
|
+
self.antwerp_quantities = []
|
|
190
|
+
self.rio_quantities = []
|
|
191
|
+
self.paris_quantities = []
|
|
192
|
+
self.copenhagen_quantities = []
|
|
193
|
+
self.shanghai_quantities = []
|
|
194
|
+
self.austin_quantities = []
|
|
195
|
+
|
|
177
196
|
for capsule_name in CAPSULE_NAMES:
|
|
178
197
|
config_capsule_name = capsule_name.replace(" ", "_")
|
|
179
198
|
if "RMR" in capsule_name:
|
|
@@ -236,7 +255,9 @@ class Scraper:
|
|
|
236
255
|
capsule_quantities,
|
|
237
256
|
):
|
|
238
257
|
if any([quantity > 0 for quantity in capsule_quantities]):
|
|
239
|
-
title_string =
|
|
258
|
+
title_string = capsule_name.center(
|
|
259
|
+
MAX_LINE_LEN, "-"
|
|
260
|
+
) # f"{PADDING}{capsule_name}{PADDING}"[:MAX_LINE_LEN]
|
|
240
261
|
self.console.print(f"[bold magenta]{title_string}")
|
|
241
262
|
|
|
242
263
|
page = self._get_page(capsule_page_url)
|
|
@@ -265,23 +286,29 @@ class Scraper:
|
|
|
265
286
|
float(capsule_quantities[href_index] * price), 2
|
|
266
287
|
)
|
|
267
288
|
|
|
268
|
-
self.console.print(capsule_names_generic[href_index])
|
|
269
289
|
self.console.print(
|
|
270
|
-
f"
|
|
290
|
+
f"[bold red]{capsule_names_generic[href_index]}"
|
|
291
|
+
)
|
|
292
|
+
self.console.print(
|
|
293
|
+
f"Owned: {capsule_quantities[href_index]} Steam market price: ${price} Total: ${price_total}"
|
|
271
294
|
)
|
|
272
295
|
|
|
273
296
|
self.total_price += price_total
|
|
274
297
|
|
|
275
|
-
except
|
|
298
|
+
except Exception:
|
|
276
299
|
self.console.print("[bold red][!] Failed to find price listing")
|
|
277
300
|
break
|
|
278
301
|
|
|
302
|
+
self.console.print("\n")
|
|
303
|
+
|
|
279
304
|
def _scrape_prices_case(
|
|
280
305
|
self, case_quantities, case_page_urls, case_hrefs, case_names
|
|
281
306
|
):
|
|
282
307
|
for index, case_quantity in enumerate(case_quantities):
|
|
283
308
|
if case_quantity > 0:
|
|
284
|
-
title_string =
|
|
309
|
+
title_string = case_names[index].center(
|
|
310
|
+
MAX_LINE_LEN, "-"
|
|
311
|
+
) # f"{PADDING}{case_names[index]}{PADDING}"[:MAX_LINE_LEN]
|
|
285
312
|
self.console.print(f"[bold magenta]{title_string}")
|
|
286
313
|
|
|
287
314
|
page = self._get_page(case_page_urls[index])
|
|
@@ -306,12 +333,16 @@ class Scraper:
|
|
|
306
333
|
price = float(price_str.replace("$", ""))
|
|
307
334
|
price_total = round(float(case_quantity * price), 2)
|
|
308
335
|
|
|
309
|
-
self.console.print(
|
|
336
|
+
self.console.print(
|
|
337
|
+
f"Owned: {case_quantity} Steam market price: ${price} Total: ${price_total}"
|
|
338
|
+
)
|
|
310
339
|
|
|
311
340
|
self.total_price += price_total
|
|
312
341
|
|
|
313
|
-
except
|
|
342
|
+
except Exception:
|
|
314
343
|
self.console.print("[bold red][!] Failed to find price listing")
|
|
315
344
|
|
|
345
|
+
self.console.print("\n")
|
|
346
|
+
|
|
316
347
|
if not self.use_proxy:
|
|
317
348
|
time.sleep(1)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|