cs2tracker 2.1.4__tar.gz → 2.1.6__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.1.4 → cs2tracker-2.1.6}/.gitignore +2 -1
- {cs2tracker-2.1.4 → cs2tracker-2.1.6}/.pylintrc +0 -1
- {cs2tracker-2.1.4 → cs2tracker-2.1.6}/PKG-INFO +17 -11
- cs2tracker-2.1.6/README.md +53 -0
- cs2tracker-2.1.6/assets/icons8-counter-strike-bubbles-96.png +0 -0
- {cs2tracker-2.1.4 → cs2tracker-2.1.6}/cs2tracker/_version.py +2 -2
- cs2tracker-2.1.6/cs2tracker/application.py +207 -0
- cs2tracker-2.1.6/cs2tracker/constants.py +553 -0
- cs2tracker-2.1.6/cs2tracker/data/config.ini +198 -0
- cs2tracker-2.1.6/cs2tracker/data/output.csv +0 -0
- cs2tracker-2.1.6/cs2tracker/main.py +34 -0
- cs2tracker-2.1.6/cs2tracker/padded_console.py +22 -0
- {cs2tracker-2.1.4 → cs2tracker-2.1.6}/cs2tracker/scraper.py +51 -32
- {cs2tracker-2.1.4 → cs2tracker-2.1.6}/cs2tracker.egg-info/PKG-INFO +17 -11
- {cs2tracker-2.1.4 → cs2tracker-2.1.6}/cs2tracker.egg-info/SOURCES.txt +4 -1
- cs2tracker-2.1.4/README.md +0 -47
- cs2tracker-2.1.4/cs2tracker/application.py +0 -109
- cs2tracker-2.1.4/cs2tracker/constants.py +0 -273
- cs2tracker-2.1.4/cs2tracker/data/config.ini +0 -113
- cs2tracker-2.1.4/cs2tracker/main.py +0 -43
- {cs2tracker-2.1.4 → cs2tracker-2.1.6}/.flake8 +0 -0
- {cs2tracker-2.1.4 → cs2tracker-2.1.6}/.isort.cfg +0 -0
- {cs2tracker-2.1.4 → cs2tracker-2.1.6}/.pre-commit-config.yaml +0 -0
- {cs2tracker-2.1.4 → cs2tracker-2.1.6}/LICENSE.md +0 -0
- {cs2tracker-2.1.4 → cs2tracker-2.1.6}/MANIFEST.in +0 -0
- {cs2tracker-2.1.4 → cs2tracker-2.1.6}/cs2tracker/__init__.py +0 -0
- {cs2tracker-2.1.4 → cs2tracker-2.1.6}/cs2tracker/__main__.py +0 -0
- {cs2tracker-2.1.4 → cs2tracker-2.1.6}/cs2tracker.egg-info/dependency_links.txt +0 -0
- {cs2tracker-2.1.4 → cs2tracker-2.1.6}/cs2tracker.egg-info/entry_points.txt +0 -0
- {cs2tracker-2.1.4 → cs2tracker-2.1.6}/cs2tracker.egg-info/requires.txt +0 -0
- {cs2tracker-2.1.4 → cs2tracker-2.1.6}/cs2tracker.egg-info/top_level.txt +0 -0
- {cs2tracker-2.1.4 → cs2tracker-2.1.6}/pyproject.toml +0 -0
- {cs2tracker-2.1.4 → cs2tracker-2.1.6}/requirements.txt +0 -0
- {cs2tracker-2.1.4 → cs2tracker-2.1.6}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cs2tracker
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.6
|
|
4
4
|
Summary: Tracking the steam market prices of CS2 items
|
|
5
5
|
Home-page: https://github.com/ashiven/cs2tracker
|
|
6
6
|
Author: Jannik Novak
|
|
@@ -40,29 +40,35 @@ Dynamic: license-file
|
|
|
40
40
|
|
|
41
41
|
### Prerequisites
|
|
42
42
|
|
|
43
|
-
-
|
|
44
|
-
-
|
|
43
|
+
- Download and install the latest versions of [Python](https://www.python.org/downloads/) and [Pip](https://pypi.org/project/pip/). (Required for Linux)
|
|
44
|
+
- Register for the [Crawlbase Smart Proxy API](https://crawlbase.com/) and retrieve your API key. (Optional)
|
|
45
45
|
|
|
46
46
|
### Setup
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
#### Windows Executable *(no color support)*
|
|
49
|
+
|
|
50
|
+
- Simply [download the latest executable](https://github.com/ashiven/cs2tracker/releases/latest/download/cs2tracker-windows.zip) and run it.
|
|
51
|
+
|
|
52
|
+
#### Install via Pip
|
|
53
|
+
|
|
54
|
+
1. Install the program:
|
|
49
55
|
|
|
50
56
|
```bash
|
|
51
|
-
pip install
|
|
57
|
+
pip install cs2tracker
|
|
52
58
|
```
|
|
53
59
|
|
|
54
|
-
2.
|
|
60
|
+
2. Run it:
|
|
55
61
|
```bash
|
|
56
62
|
cs2tracker
|
|
57
63
|
```
|
|
58
64
|
|
|
59
65
|
### Options
|
|
60
66
|
|
|
61
|
-
-
|
|
62
|
-
-
|
|
63
|
-
-
|
|
64
|
-
-
|
|
65
|
-
-
|
|
67
|
+
- `Run!` to gather the current market prices of your items and calculate the total amount in USD and EUR.
|
|
68
|
+
- `Edit Config` to change the specific numbers of each item you own and then save the config file.
|
|
69
|
+
- `Show History` to see a price chart consisting of past calculations. A new data point is generated once a day upon running the program.
|
|
70
|
+
- `Daily Background Calculation` to automatically run a daily calculation of your investment in the background and save the results such that they can later be viewed via `Show History`.
|
|
71
|
+
- If you want to prevent your requests from being rate limited by the steamcommunity server, register for an API key on [Crawlbase](crawlbase.com) and enter it into the `API_Key` field in the config file. This will route every request through a different proxy server.
|
|
66
72
|
|
|
67
73
|
---
|
|
68
74
|
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
|
+
[](https://github.com/ashiven/cs2tracker/releases)
|
|
5
|
+
[](https://badge.fury.io/py/cs2tracker)
|
|
6
|
+
[](https://github.com/ashiven/cs2tracker/issues)
|
|
7
|
+
[](https://github.com/ashiven/cs2tracker/pulls)
|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
</div>
|
|
11
|
+
|
|
12
|
+
## About
|
|
13
|
+
|
|
14
|
+
**CS2Tracker** is a tool that can be used to keep track of the steam market prices of your CS2 investment.
|
|
15
|
+
|
|
16
|
+
## Getting Started
|
|
17
|
+
|
|
18
|
+
### Prerequisites
|
|
19
|
+
|
|
20
|
+
- Download and install the latest versions of [Python](https://www.python.org/downloads/) and [Pip](https://pypi.org/project/pip/). (Required for Linux)
|
|
21
|
+
- Register for the [Crawlbase Smart Proxy API](https://crawlbase.com/) and retrieve your API key. (Optional)
|
|
22
|
+
|
|
23
|
+
### Setup
|
|
24
|
+
|
|
25
|
+
#### Windows Executable *(no color support)*
|
|
26
|
+
|
|
27
|
+
- Simply [download the latest executable](https://github.com/ashiven/cs2tracker/releases/latest/download/cs2tracker-windows.zip) and run it.
|
|
28
|
+
|
|
29
|
+
#### Install via Pip
|
|
30
|
+
|
|
31
|
+
1. Install the program:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install cs2tracker
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
2. Run it:
|
|
38
|
+
```bash
|
|
39
|
+
cs2tracker
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Options
|
|
43
|
+
|
|
44
|
+
- `Run!` to gather the current market prices of your items and calculate the total amount in USD and EUR.
|
|
45
|
+
- `Edit Config` to change the specific numbers of each item you own and then save the config file.
|
|
46
|
+
- `Show History` to see a price chart consisting of past calculations. A new data point is generated once a day upon running the program.
|
|
47
|
+
- `Daily Background Calculation` to automatically run a daily calculation of your investment in the background and save the results such that they can later be viewed via `Show History`.
|
|
48
|
+
- If you want to prevent your requests from being rate limited by the steamcommunity server, register for an API key on [Crawlbase](crawlbase.com) and enter it into the `API_Key` field in the config file. This will route every request through a different proxy server.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
> GitHub [@ashiven](https://github.com/Ashiven) ·
|
|
53
|
+
> Twitter [ashiven\_](https://twitter.com/ashiven_)
|
|
Binary file
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import tkinter as tk
|
|
2
|
+
from subprocess import Popen
|
|
3
|
+
from threading import Thread
|
|
4
|
+
from typing import cast
|
|
5
|
+
|
|
6
|
+
import matplotlib.pyplot as plt
|
|
7
|
+
from matplotlib.axes import Axes
|
|
8
|
+
from matplotlib.dates import DateFormatter
|
|
9
|
+
|
|
10
|
+
from cs2tracker.constants import (
|
|
11
|
+
CONFIG_FILE,
|
|
12
|
+
OS,
|
|
13
|
+
OUTPUT_FILE,
|
|
14
|
+
PYTHON_EXECUTABLE,
|
|
15
|
+
RUNNING_IN_EXE,
|
|
16
|
+
TEXT_EDITOR,
|
|
17
|
+
OSType,
|
|
18
|
+
)
|
|
19
|
+
from cs2tracker.scraper import Scraper
|
|
20
|
+
|
|
21
|
+
WINDOW_TITLE = "CS2Tracker"
|
|
22
|
+
WINDOW_SIZE = "450x380"
|
|
23
|
+
BACKGROUND_COLOR = "#1e1e1e"
|
|
24
|
+
BUTTON_COLOR = "#3c3f41"
|
|
25
|
+
BUTTON_HOVER_COLOR = "#505354"
|
|
26
|
+
BUTTON_ACTIVE_COLOR = "#5c5f61"
|
|
27
|
+
FONT_STYLE = "Segoe UI"
|
|
28
|
+
FONT_COLOR = "white"
|
|
29
|
+
|
|
30
|
+
SCRAPER_WINDOW_TITLE = "CS2Tracker"
|
|
31
|
+
SCRAPER_WINDOW_HEIGHT = 40
|
|
32
|
+
SCRAPER_WINDOW_WIDTH = 100
|
|
33
|
+
SCRAPER_WINDOW_BACKGROUND_COLOR = "Black"
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class Application:
|
|
37
|
+
def __init__(self):
|
|
38
|
+
self.scraper = Scraper()
|
|
39
|
+
|
|
40
|
+
def run(self):
|
|
41
|
+
"""Run the main application window with buttons for scraping prices, editing the
|
|
42
|
+
configuration, showing history in a chart, and editing the log file.
|
|
43
|
+
"""
|
|
44
|
+
application_window = self._configure_window()
|
|
45
|
+
application_window.mainloop()
|
|
46
|
+
|
|
47
|
+
def _add_button(self, frame, text, command):
|
|
48
|
+
"""Create and style a button for the main application window."""
|
|
49
|
+
button_style = {
|
|
50
|
+
"font": (FONT_STYLE, 12),
|
|
51
|
+
"fg": FONT_COLOR,
|
|
52
|
+
"bg": BUTTON_COLOR,
|
|
53
|
+
"activebackground": BUTTON_ACTIVE_COLOR,
|
|
54
|
+
}
|
|
55
|
+
button = tk.Button(frame, text=text, command=command, **button_style)
|
|
56
|
+
button.pack(pady=5, fill="x")
|
|
57
|
+
button.bind("<Enter>", lambda _: button.config(bg=BUTTON_HOVER_COLOR))
|
|
58
|
+
button.bind("<Leave>", lambda _: button.config(bg=BUTTON_COLOR))
|
|
59
|
+
return button
|
|
60
|
+
|
|
61
|
+
def _configure_window(self):
|
|
62
|
+
"""Configure the main application window UI and add buttons for the main
|
|
63
|
+
functionalities.
|
|
64
|
+
"""
|
|
65
|
+
window = tk.Tk()
|
|
66
|
+
window.title(WINDOW_TITLE)
|
|
67
|
+
window.geometry(WINDOW_SIZE)
|
|
68
|
+
window.configure(bg=BACKGROUND_COLOR)
|
|
69
|
+
|
|
70
|
+
frame = tk.Frame(window, bg=BACKGROUND_COLOR, padx=30, pady=30)
|
|
71
|
+
frame.pack(expand=True, fill="both")
|
|
72
|
+
|
|
73
|
+
label = tk.Label(
|
|
74
|
+
frame,
|
|
75
|
+
text=f"Welcome to {WINDOW_TITLE}!",
|
|
76
|
+
font=(FONT_STYLE, 16, "bold"),
|
|
77
|
+
fg=FONT_COLOR,
|
|
78
|
+
bg=BACKGROUND_COLOR,
|
|
79
|
+
)
|
|
80
|
+
label.pack(pady=(0, 30))
|
|
81
|
+
|
|
82
|
+
self._add_button(frame, "Run!", self.scrape_prices)
|
|
83
|
+
self._add_button(frame, "Edit Config", self._edit_config)
|
|
84
|
+
self._add_button(frame, "Show History (Chart)", self._draw_plot)
|
|
85
|
+
self._add_button(frame, "Show History (File)", self._edit_log_file)
|
|
86
|
+
|
|
87
|
+
background_checkbox_value = tk.BooleanVar(value=self.scraper.identify_background_task())
|
|
88
|
+
background_checkbox = tk.Checkbutton(
|
|
89
|
+
frame,
|
|
90
|
+
text="Daily Background Calculation",
|
|
91
|
+
variable=background_checkbox_value,
|
|
92
|
+
command=lambda: self._toggle_background_task(background_checkbox_value.get()),
|
|
93
|
+
bg=BACKGROUND_COLOR,
|
|
94
|
+
fg=FONT_COLOR,
|
|
95
|
+
selectcolor=BUTTON_COLOR,
|
|
96
|
+
activebackground=BACKGROUND_COLOR,
|
|
97
|
+
font=(FONT_STYLE, 10),
|
|
98
|
+
)
|
|
99
|
+
background_checkbox.pack(pady=20)
|
|
100
|
+
|
|
101
|
+
return window
|
|
102
|
+
|
|
103
|
+
def _construct_scraper_command_windows(self):
|
|
104
|
+
"""Construct the command to run the scraper in a new window for Windows."""
|
|
105
|
+
set_utf8_encoding = (
|
|
106
|
+
"[Console]::InputEncoding = [Console]::OutputEncoding = [System.Text.Encoding]::UTF8;"
|
|
107
|
+
)
|
|
108
|
+
get_size = "$size = $Host.UI.RawUI.WindowSize;"
|
|
109
|
+
set_size = "$Host.UI.RawUI.WindowSize = $size;"
|
|
110
|
+
set_window_title = f"$Host.UI.RawUI.WindowTitle = '{SCRAPER_WINDOW_TITLE}';"
|
|
111
|
+
set_window_width = (
|
|
112
|
+
f"$size.Width = [Math]::Min({SCRAPER_WINDOW_WIDTH}, $Host.UI.RawUI.BufferSize.Width);"
|
|
113
|
+
)
|
|
114
|
+
set_window_height = f"$size.Height = {SCRAPER_WINDOW_HEIGHT};"
|
|
115
|
+
set_background_color = (
|
|
116
|
+
f"$Host.UI.RawUI.BackgroundColor = '{SCRAPER_WINDOW_BACKGROUND_COLOR}';"
|
|
117
|
+
)
|
|
118
|
+
clear = "Clear-Host;"
|
|
119
|
+
|
|
120
|
+
if RUNNING_IN_EXE:
|
|
121
|
+
# The python executable is set as the executable itself in PyInstaller
|
|
122
|
+
scraper_cmd = f"{PYTHON_EXECUTABLE} --only-scrape | Out-Host -Paging"
|
|
123
|
+
else:
|
|
124
|
+
scraper_cmd = f"{PYTHON_EXECUTABLE} -m cs2tracker --only-scrape"
|
|
125
|
+
|
|
126
|
+
cmd = (
|
|
127
|
+
'start powershell -NoExit -Command "& {'
|
|
128
|
+
+ set_utf8_encoding
|
|
129
|
+
+ set_window_title
|
|
130
|
+
+ get_size
|
|
131
|
+
+ set_window_width
|
|
132
|
+
+ set_window_height
|
|
133
|
+
+ set_size
|
|
134
|
+
+ set_background_color
|
|
135
|
+
+ clear
|
|
136
|
+
+ scraper_cmd
|
|
137
|
+
+ '}"'
|
|
138
|
+
)
|
|
139
|
+
return cmd
|
|
140
|
+
|
|
141
|
+
def _construct_scraper_command(self):
|
|
142
|
+
"""Construct the command to run the scraper in a new window."""
|
|
143
|
+
if OS == OSType.WINDOWS:
|
|
144
|
+
return self._construct_scraper_command_windows()
|
|
145
|
+
else:
|
|
146
|
+
# TODO: Implement for Linux
|
|
147
|
+
return ""
|
|
148
|
+
|
|
149
|
+
def scrape_prices(self):
|
|
150
|
+
"""Scrape prices from the configured sources, print the total, and save the
|
|
151
|
+
results to a file.
|
|
152
|
+
"""
|
|
153
|
+
if OS == OSType.WINDOWS:
|
|
154
|
+
scraper_cmd = self._construct_scraper_command()
|
|
155
|
+
Popen(scraper_cmd, shell=True)
|
|
156
|
+
else:
|
|
157
|
+
# TODO: implement external window for Linux
|
|
158
|
+
self.scraper.scrape_prices()
|
|
159
|
+
|
|
160
|
+
def _edit_config(self):
|
|
161
|
+
"""Edit the configuration file using the specified text editor."""
|
|
162
|
+
_popen_and_call(
|
|
163
|
+
popen_args={"args": [TEXT_EDITOR, CONFIG_FILE], "shell": True},
|
|
164
|
+
callback=self.scraper.parse_config,
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
def _draw_plot(self):
|
|
168
|
+
"""Draw a plot of the scraped prices over time."""
|
|
169
|
+
dates, dollars, euros = self.scraper.read_price_log()
|
|
170
|
+
|
|
171
|
+
fig, ax_raw = plt.subplots(figsize=(10, 8), num="CS2Tracker Price History")
|
|
172
|
+
fig.suptitle("CS2Tracker Price History", fontsize=16)
|
|
173
|
+
fig.autofmt_xdate()
|
|
174
|
+
|
|
175
|
+
ax = cast(Axes, ax_raw)
|
|
176
|
+
ax.plot(dates, dollars, label="Dollars")
|
|
177
|
+
ax.plot(dates, euros, label="Euros")
|
|
178
|
+
ax.legend()
|
|
179
|
+
date_formatter = DateFormatter("%d-%m-%Y")
|
|
180
|
+
ax.xaxis.set_major_formatter(date_formatter)
|
|
181
|
+
|
|
182
|
+
plt.show()
|
|
183
|
+
|
|
184
|
+
def _edit_log_file(self):
|
|
185
|
+
"""Opens the file containing past price calculations."""
|
|
186
|
+
Popen([TEXT_EDITOR, OUTPUT_FILE], shell=True)
|
|
187
|
+
|
|
188
|
+
def _toggle_background_task(self, enabled: bool):
|
|
189
|
+
"""Toggle whether a daily price calculation should run in the background."""
|
|
190
|
+
self.scraper.toggle_background_task(enabled)
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def _popen_and_call(popen_args, callback):
|
|
194
|
+
"""
|
|
195
|
+
Runs the given args in a subprocess.Popen, and then calls the function callback when
|
|
196
|
+
the subprocess completes.
|
|
197
|
+
|
|
198
|
+
Source: https://stackoverflow.com/questions/2581817/python-subprocess-callback-when-cmd-exits
|
|
199
|
+
"""
|
|
200
|
+
|
|
201
|
+
def process_and_callback(popen_args, callback):
|
|
202
|
+
process = Popen(**popen_args)
|
|
203
|
+
process.wait()
|
|
204
|
+
callback()
|
|
205
|
+
|
|
206
|
+
thread = Thread(target=process_and_callback, args=(popen_args, callback), daemon=True)
|
|
207
|
+
thread.start()
|