Skip to content

Commit

Permalink
- Multiple patterns in config now working
Browse files Browse the repository at this point in the history
  • Loading branch information
sotolko committed Mar 10, 2023
1 parent 6dd2a8f commit 1b9aae1
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pip install -r /path/to/requirements.txt
```
***
## Usage
Open config.yaml file ,and fill this file based on example provided.
Open settinngs/config.yaml file ,and fill this file based on example provided.

```yaml
# Example configuration file for program
Expand Down
6 changes: 5 additions & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
def load_config():
print("Loading config file...")

with open('config.yaml', 'r') as f:
with open('settings/config.yaml', 'r') as f:
config = yaml.safe_load(f)

url_info = [[None]*6 for _ in range(len(config['skins']))]
Expand All @@ -21,6 +21,10 @@ def load_config():
if url_info[idx][5] == None:
print("There is skin that have URL empty in config.yaml.\nExiting...")
return None

if url_info[idx][1] is not None:
if type(url_info[idx][1]) == str:
url_info[idx][1] = url_info[idx][1].split(', ')

print(f"Loaded {len(url_info)} skins!")
return url_info
13 changes: 7 additions & 6 deletions functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,13 @@ def check_item_parameters(item_float, item_pattern, whole, count, url_info):
return False

if url_info[count][1] is not None:
for pattern in url_info[count][1]:
if int(pattern) == item_pattern:
match = True
break
if not match:
return False
if type(url_info[count][1]) is not int:
for pattern in url_info[count][1]:
if int(pattern) == item_pattern:
match = True
break
if not match:
return False

if url_info[count][2] is not None:
if not check_stickers(whole, url_info[count][2]):
Expand Down
12 changes: 6 additions & 6 deletions config.yaml → settings/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ skins:
- url: https://steamcommunity.com/market/listings/730/MP7%20%7C%20Army%20Recon%20%28Field-Tested%29
float: 0.2
price: 100
number_of_stickers: # Leave empty for ANY
pages: 2
number_of_stickers: 4
pages:
pattern: 502, 947
- url: https://steamcommunity.com/market/listings/730/UMP-45%20%7C%20Urban%20DDPAT%20%28Factory%20New%29
float:
price:
number_of_stickers:
pages: 2
float: 0.1
price: 100
number_of_stickers: 4
pages:
pattern: 123
5 changes: 4 additions & 1 deletion requirements.txt → settings/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
selenium
requests
chromedriver-autoinstaller
pyyaml
pyyaml
html5lib
bs4
fake_headers

0 comments on commit 1b9aae1

Please sign in to comment.