cs2tracker 2.1.15__py3-none-any.whl → 2.1.16__py3-none-any.whl

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/_version.py CHANGED
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '2.1.15'
21
- __version_tuple__ = version_tuple = (2, 1, 15)
20
+ __version__ = version = '2.1.16'
21
+ __version_tuple__ = version_tuple = (2, 1, 16)
cs2tracker/constants.py CHANGED
@@ -18,19 +18,36 @@ except ImportError:
18
18
  class OSType(enum.Enum):
19
19
  WINDOWS = "Windows"
20
20
  LINUX = "Linux"
21
+ MACOS = "MacOS"
21
22
 
22
23
 
23
- OS = OSType.WINDOWS if sys.platform.startswith("win") else OSType.LINUX
24
- PYTHON_EXECUTABLE = sys.executable
24
+ if sys.platform.startswith("win"):
25
+ OS = OSType.WINDOWS
26
+ elif sys.platform.startswith("linux"):
27
+ OS = OSType.LINUX
28
+ elif sys.platform.startswith("darwin"):
29
+ OS = OSType.MACOS
30
+ else:
31
+ raise NotImplementedError(f"Unsupported OS: {sys.platform}")
25
32
 
26
33
 
34
+ PYTHON_EXECUTABLE = sys.executable
27
35
  RUNNING_IN_EXE = getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS")
28
36
 
29
37
  if RUNNING_IN_EXE:
30
38
  MEIPASS_DIR = sys._MEIPASS # type: ignore pylint: disable=protected-access
31
39
  MODULE_DIR = MEIPASS_DIR
32
40
  PROJECT_DIR = MEIPASS_DIR
33
- APP_DATA_DIR = os.path.join(os.path.expanduser("~"), "AppData", "Local")
41
+
42
+ if OS == OSType.WINDOWS:
43
+ APP_DATA_DIR = os.path.join(os.path.expanduser("~"), "AppData", "Local")
44
+ elif OS == OSType.LINUX:
45
+ APP_DATA_DIR = os.environ.get(
46
+ "XDG_DATA_HOME", os.path.join(os.path.expanduser("~"), ".local", "share")
47
+ )
48
+ else:
49
+ raise NotImplementedError(f"Unsupported OS: {OS}")
50
+
34
51
  DATA_DIR = os.path.join(APP_DATA_DIR, "cs2tracker", "data")
35
52
  os.makedirs(DATA_DIR, exist_ok=True)
36
53
 
@@ -1,5 +1,5 @@
1
1
  import os
2
- from subprocess import DEVNULL, call
2
+ from subprocess import DEVNULL, STDOUT, CalledProcessError, call, check_output, run
3
3
 
4
4
  from cs2tracker.constants import (
5
5
  BATCH_FILE,
@@ -18,6 +18,18 @@ WIN_BACKGROUND_TASK_CMD = (
18
18
  f"powershell -WindowStyle Hidden -Command \"Start-Process '{BATCH_FILE}' -WindowStyle Hidden\""
19
19
  )
20
20
 
21
+ LINUX_BACKGROUND_TASK_SCHEDULE = "0 12 * * *"
22
+ LINUX_BACKGROUND_TASK_CMD = (
23
+ f"bash -c 'cd {PROJECT_DIR} && {PYTHON_EXECUTABLE} -m cs2tracker --only-scrape'"
24
+ )
25
+ LINUX_BACKGROUND_TASK_CMD_EXE = f"bash -c 'cd {PROJECT_DIR} && {PYTHON_EXECUTABLE} --only-scrape'"
26
+
27
+ if RUNNING_IN_EXE:
28
+ LINUX_CRON_JOB = f"{LINUX_BACKGROUND_TASK_SCHEDULE} {LINUX_BACKGROUND_TASK_CMD_EXE}"
29
+ else:
30
+ LINUX_CRON_JOB = f"{LINUX_BACKGROUND_TASK_SCHEDULE} {LINUX_BACKGROUND_TASK_CMD}"
31
+
32
+
21
33
  console = get_console()
22
34
 
23
35
 
@@ -34,8 +46,17 @@ class BackgroundTask:
34
46
  return_code = call(cmd, stdout=DEVNULL, stderr=DEVNULL)
35
47
  found = return_code == 0
36
48
  return found
49
+ elif OS == OSType.LINUX:
50
+ try:
51
+ existing_jobs = (
52
+ check_output(["crontab", "-l"], stderr=STDOUT).decode("utf-8").strip()
53
+ )
54
+ except CalledProcessError:
55
+ existing_jobs = ""
56
+
57
+ found = LINUX_CRON_JOB in existing_jobs.splitlines()
58
+ return found
37
59
  else:
38
- # TODO: implement finder for cron jobs
39
60
  return False
40
61
 
41
62
  @classmethod
@@ -83,17 +104,69 @@ class BackgroundTask:
83
104
  ]
84
105
  return_code = call(cmd, stdout=DEVNULL, stderr=DEVNULL)
85
106
  if return_code == 0:
86
- console.print("[bold green][+] Background task enabled.")
107
+ console.info("Background task enabled.")
87
108
  else:
88
109
  console.error("Failed to enable background task.")
89
110
  else:
90
111
  cmd = ["schtasks", "/delete", "/tn", WIN_BACKGROUND_TASK_NAME, "/f"]
91
112
  return_code = call(cmd, stdout=DEVNULL, stderr=DEVNULL)
92
113
  if return_code == 0:
93
- console.print("[bold green][-] Background task disabled.")
114
+ console.info("Background task disabled.")
94
115
  else:
95
116
  console.error("Failed to disable background task.")
96
117
 
118
+ @classmethod
119
+ def _toggle_linux(cls, enabled: bool):
120
+ """
121
+ Create or delete a daily background task that runs the scraper on Linux.
122
+
123
+ :param enabled: If True, the task will be created; if False, the task will be
124
+ deleted.
125
+ """
126
+ try:
127
+ existing_jobs = check_output(["crontab", "-l"], stderr=STDOUT).decode("utf-8").strip()
128
+ except CalledProcessError:
129
+ existing_jobs = ""
130
+
131
+ cron_lines = existing_jobs.splitlines()
132
+
133
+ if enabled and LINUX_CRON_JOB not in cron_lines:
134
+ updated_jobs = (
135
+ existing_jobs + "\n" + LINUX_CRON_JOB + "\n"
136
+ if existing_jobs
137
+ else LINUX_CRON_JOB + "\n"
138
+ )
139
+ try:
140
+ run(
141
+ ["crontab", "-"],
142
+ input=updated_jobs.encode("utf-8"),
143
+ stdout=DEVNULL,
144
+ stderr=DEVNULL,
145
+ check=True,
146
+ )
147
+ console.info("Background task enabled.")
148
+ except CalledProcessError:
149
+ console.error("Failed to enable background task.")
150
+
151
+ elif not enabled and LINUX_CRON_JOB in cron_lines:
152
+ updated_jobs = "\n".join(
153
+ line for line in cron_lines if line.strip() != LINUX_CRON_JOB
154
+ ).strip()
155
+ try:
156
+ if updated_jobs:
157
+ run(
158
+ ["crontab", "-"],
159
+ input=(updated_jobs + "\n").encode("utf-8"),
160
+ stdout=DEVNULL,
161
+ stderr=DEVNULL,
162
+ check=True,
163
+ )
164
+ else:
165
+ run(["crontab", "-r"], stdout=DEVNULL, stderr=DEVNULL, check=True)
166
+ console.info("Background task disabled.")
167
+ except CalledProcessError:
168
+ console.error("Failed to disable background task.")
169
+
97
170
  @classmethod
98
171
  def toggle(cls, enabled: bool):
99
172
  """
@@ -104,6 +177,7 @@ class BackgroundTask:
104
177
  """
105
178
  if OS == OSType.WINDOWS:
106
179
  cls._toggle_windows(enabled)
180
+ elif OS == OSType.LINUX:
181
+ cls._toggle_linux(enabled)
107
182
  else:
108
- # TODO: implement toggle for cron jobs
109
183
  pass
@@ -127,7 +127,7 @@ class CSGOTraderParser(BaseParser):
127
127
  CSGOTRADER_PRICE_LIST = "https://prices.csgotrader.app/latest/{}.json"
128
128
  PRICE_INFO = "Owned: {:<10} {:<10}: ${:<10} Total: ${:<10}"
129
129
  NEEDS_TIMEOUT = False
130
- SOURCES = [PriceSource.STEAM, PriceSource.BUFF163, PriceSource.YOUPIN898]
130
+ SOURCES = [PriceSource.STEAM, PriceSource.BUFF163, PriceSource.CSFLOAT]
131
131
 
132
132
  @classmethod
133
133
  def get_item_page_url(cls, item_href, source=PriceSource.STEAM):
@@ -176,6 +176,12 @@ class CSGOTraderParser(BaseParser):
176
176
  raise ValueError(
177
177
  f"CSGOTrader: Could not find recent youpin898 price: {url_decoded_name}"
178
178
  )
179
+ elif source == PriceSource.CSFLOAT:
180
+ price = price_info.get("price")
181
+ if not price:
182
+ raise ValueError(
183
+ f"CSGOTrader: Could not find recent csfloat price: {url_decoded_name}"
184
+ )
179
185
  else:
180
186
  price = price_info.get("starting_at")
181
187
  if not price:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cs2tracker
3
- Version: 2.1.15
3
+ Version: 2.1.16
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
@@ -49,8 +49,8 @@ Dynamic: license-file
49
49
 
50
50
  - [Features](#features)
51
51
  - [Getting Started](#getting-started)
52
- - [Prerequisites](#prerequisites)
53
52
  - [Installation](#installation)
53
+ - [Additional Setup](#additional-setup)
54
54
  - [Usage](#usage)
55
55
  - [Configuration](#configuration)
56
56
  - [Advanced Features](#advanced-features)
@@ -60,7 +60,7 @@ Dynamic: license-file
60
60
  ## Features
61
61
 
62
62
  - ⚡ Rapidly import your Storage Units
63
- - 🔍 Track prices on Steam, Buff163, Youpin898
63
+ - 🔍 Track prices on Steam, Buff163, CSFloat
64
64
  - 📈 View investment price history
65
65
  - 🧾 Export/Import history data
66
66
  - 📤 Discord notifications on updates
@@ -69,19 +69,15 @@ Dynamic: license-file
69
69
 
70
70
  ## Getting Started
71
71
 
72
- ### Prerequisites
73
-
74
- - Download and install the latest versions of [Python](https://www.python.org/downloads/) and [Pip](https://pypi.org/project/pip/). (Required on Linux)
75
- - Register for the [Crawlbase Smart Proxy API](https://crawlbase.com/) and retrieve your API key. (Optional)
76
- - Create a [Discord Webhook](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks) to be notified about recent price updates. (Optional)
77
-
78
72
  ### Installation
79
73
 
80
- #### Option 1: Windows Executable
74
+ #### Method 1: Executable
81
75
 
82
- - Simply [download the latest executable](https://github.com/ashiven/cs2tracker/releases/latest/download/cs2tracker-windows.zip) and run it.
76
+ Simply download the program and run it:
77
+ - [Windows](https://github.com/ashiven/cs2tracker/releases/latest/download/cs2tracker-windows.zip)
78
+ - [Linux](https://github.com/ashiven/cs2tracker/releases/latest/download/cs2tracker-linux.zip)
83
79
 
84
- #### Option 2: Install via Pip
80
+ #### Method 2: Install via Pip
85
81
 
86
82
  1. Install the program:
87
83
 
@@ -94,10 +90,14 @@ Dynamic: license-file
94
90
  ```bash
95
91
  cs2tracker
96
92
  ```
93
+ ### Additional Setup
94
+
95
+ - Register for the [Crawlbase Smart Proxy API](https://crawlbase.com/) and retrieve your API key. (Optional)
96
+ - Create a [Discord Webhook](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks) to be notified about recent price updates. (Optional)
97
97
 
98
98
  ## Usage
99
99
 
100
- - Click **Run!** to gather the current market prices of your items and calculate the total amount in USD and EUR.
100
+ - Click **Run!** to gather the current market prices of your items and calculate the total amount in USD and your selected currency.
101
101
  - The generated Excel sheet can be saved by right-clicking and then selecting **Save Sheet**.
102
102
  - Use **Edit Config** to specify the numbers of items owned in the configuration.
103
103
  - Click **Show History** to see a price chart consisting of past calculations.
@@ -1,8 +1,8 @@
1
1
  cs2tracker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  cs2tracker/__main__.py,sha256=Ub--oSMv48YzfWF1CZqYlkn1-HvZ7Bhxoc7urn1oY6o,249
3
- cs2tracker/_version.py,sha256=B5GTyfnCcU_OVejGvc44yPuiU01UHMzbmUciqEKsU_4,513
3
+ cs2tracker/_version.py,sha256=rudGT5E5yeJvX5boBvUebroVntBjuBLjwwGBYa7WCrQ,513
4
4
  cs2tracker/config.py,sha256=iab4WqKLl8-rfV7_MAd-96lfp_edMe6QQHW_m76FvD8,11011
5
- cs2tracker/constants.py,sha256=9E1CPVEohDmV_F2PLLrPRmtYAHHVDimbUFfohhjci1c,6742
5
+ cs2tracker/constants.py,sha256=QqjApGtPd5SEP3ONMp4WdDOSr02sKbnSpPFFUkXFxKk,7228
6
6
  cs2tracker/logs.py,sha256=K6uLoGjhHTlb6HLKIj6C5mz6R6bnZgltA6xwNVJ7Z8Y,6004
7
7
  cs2tracker/main.py,sha256=9Jjn8-Hv9AzQLYjCjA6pwAmThE4HH1u3akF_c7atyl4,1046
8
8
  cs2tracker/app/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -15,17 +15,17 @@ cs2tracker/data/convert_inventory.js,sha256=CbMXnw52cOxhN2Ee2-kP3qX6pgwxrv4pi6_I
15
15
  cs2tracker/data/get_inventory.js,sha256=OMntZhDE_x4qsqCWqcU7SqDFuMWz_VK_umxt_4i2znQ,6304
16
16
  cs2tracker/data/output.csv,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  cs2tracker/scraper/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
- cs2tracker/scraper/background_task.py,sha256=pCLMt3XVVduaqYRdXtV3HIHinL3WnULP4Riwc3tL9f0,3686
18
+ cs2tracker/scraper/background_task.py,sha256=4m1mr9veS3PUErTJhJVQNuBvmK1B8G9rPyVF_d8Cb9Q,6443
19
19
  cs2tracker/scraper/discord_notifier.py,sha256=1DaGQVHfeE9AsQ09uKvVyDEbIdQwhVEh7MonJK0n0So,3074
20
- cs2tracker/scraper/parser.py,sha256=FGbR60WISxnlJ8T7srhB5lU4m73rcfo9fjYDMpLaiKs,6770
20
+ cs2tracker/scraper/parser.py,sha256=s1kY8cogKExWmG5X0OKuvTbqZebFrEjgUbQJ-1We_iY,7025
21
21
  cs2tracker/scraper/scraper.py,sha256=D_NlJTZyIXDhEkHGqjyrc5LYakcfiaT7Dl7dWLSC02k,11377
22
22
  cs2tracker/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
23
  cs2tracker/util/currency_conversion.py,sha256=h_VdipCFPzcgybWZ2VYknOd1VjHiqsFbEVed95FOe7U,2199
24
24
  cs2tracker/util/padded_console.py,sha256=ZEbU5MxDA7Xbd-_SXIyezwGvb349OgAtjNPjFT_wrZw,1774
25
25
  cs2tracker/util/tkinter.py,sha256=yR6rog4P7t_rDgH6ctssfQeJYFbqFXboiRv1V9c1vk4,1518
26
- cs2tracker-2.1.15.dist-info/licenses/LICENSE,sha256=doPNswWMPXbkhplb9cnZLwJoqqS72pJPhkSib8kIF08,19122
27
- cs2tracker-2.1.15.dist-info/METADATA,sha256=VVNiDycjDEoGrL5dVChE5Pm0tMRI9jcJf15lh75CWvg,5657
28
- cs2tracker-2.1.15.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
29
- cs2tracker-2.1.15.dist-info/entry_points.txt,sha256=K8IwDIkg8QztSB9g9c89B9jR_2pG4QyJGrNs4z5RcZw,63
30
- cs2tracker-2.1.15.dist-info/top_level.txt,sha256=2HB4xDDOxaU5BDc_yvdi9UlYLgL768n8aR-hRhFM6VQ,11
31
- cs2tracker-2.1.15.dist-info/RECORD,,
26
+ cs2tracker-2.1.16.dist-info/licenses/LICENSE,sha256=doPNswWMPXbkhplb9cnZLwJoqqS72pJPhkSib8kIF08,19122
27
+ cs2tracker-2.1.16.dist-info/METADATA,sha256=6lI3JbZeL8_DH9Yxl1iNmAvMmsP4Jbc-oEY1Dnc_d2M,5619
28
+ cs2tracker-2.1.16.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
29
+ cs2tracker-2.1.16.dist-info/entry_points.txt,sha256=K8IwDIkg8QztSB9g9c89B9jR_2pG4QyJGrNs4z5RcZw,63
30
+ cs2tracker-2.1.16.dist-info/top_level.txt,sha256=2HB4xDDOxaU5BDc_yvdi9UlYLgL768n8aR-hRhFM6VQ,11
31
+ cs2tracker-2.1.16.dist-info/RECORD,,