Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pr_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest # [macos-latest, windows-latest]
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "pypy-3.9"]
python-version: ["3.8", "3.9", "3.10", "3.11", "pypy-3.9"]
name: "ruff (Python ${{ matrix.python-version }})"
steps:
- uses: actions/checkout@v3
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ dist
nohup.out
poetry.lock
.tox

.telegram_alerts.pklz
.currency_cache
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ If you have suggestions or ideas, please reach out! So far I've bought more than

## Requirements

- Python >= 3.7
- Python >= 3.8
- [Chromedriver](https://chromedriver.chromium.org/). If you have Google Chrome or any Chromium browser installed on your computer, you'll be fine.

## Installation & Setup
Expand Down
21 changes: 20 additions & 1 deletion discogs_alert/alert/telegram.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,40 @@
import logging
import os
import pickle
from pathlib import Path

import requests

from discogs_alert.alert.base import AlertDict, Alerter

logger = logging.getLogger(__name__)

TELEGRAM_ALERT_FILE_PATH = os.path.join(
os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))),
".telegram_alerts.pklz",
)


class TelegramAlerter(Alerter):
def __init__(self, telegram_token: str, telegram_chat_id: str):
self.bot_token = telegram_token
self.bot_chat_id = telegram_chat_id

if not os.path.exists(TELEGRAM_ALERT_FILE_PATH):
pickle.dump({}, Path(TELEGRAM_ALERT_FILE_PATH).open("wb"))

def get_all_alerts(self) -> AlertDict:
return {}
return pickle.load(Path(TELEGRAM_ALERT_FILE_PATH).open("rb"))

def send_alert(self, message_title: str, message_body: str):
# add the alert to the local alerts dict
alert_dict: AlertDict = pickle.load(Path(TELEGRAM_ALERT_FILE_PATH).open("rb"))
if message_title in alert_dict:
alert_dict[message_title].add(message_body)
else:
alert_dict[message_title] = {message_body}
pickle.dump(alert_dict, Path(TELEGRAM_ALERT_FILE_PATH).open("wb"))

requests.get(
"https://api.telegram.org/bot"
+ self.bot_token
Expand Down
8 changes: 6 additions & 2 deletions discogs_alert/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,5 +165,9 @@ def get_driver_path(self):
def get_marketplace_listings(self, release_id: int) -> da_entities.Listings:
"""Get list of listings currently for sale for particular release (by release's discogs ID)"""

self.driver.get(f"{self._base_url_non_api}/sell/release/{release_id}?ev=rb&sort=price%2Casc")
return da_scrape.scrape_listings_from_marketplace(self.driver.page_source, release_id)
self.driver.get(f"{self._base_url_non_api}/sell/release/{release_id}?sort=price%2Casc")
try:
return da_scrape.scrape_listings_from_marketplace(self.driver.page_source, release_id)
except:
print(self.driver.page_source)
raise
2 changes: 2 additions & 0 deletions discogs_alert/loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ def loop(

wantlist_items = load_wantlist(list_id, user_token_client, wantlist_path)
random.shuffle(wantlist_items)

logger.info("We are loopin' !")
for idx, release in enumerate(wantlist_items):
valid_listings: List[da_entities.Listing] = []

Expand Down
29 changes: 13 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "discogs_alert"
version = "0.0.21"
version = "0.0.22"
description = "Configurable, real-time alerts for your discogs wantlist"
license = "MIT"
authors = ["mhsb <michael.h.s.ball@gmail.com>"]
Expand All @@ -12,29 +12,26 @@ readme = "README.md"

[tool.poetry.dependencies]
python = "^3.8"
beautifulsoup4 = "^4.11.2"
click = "^8.1.3"
dacite = "^1.8.0"
beautifulsoup4 = "^4.14.3"
click = "^8.3.1"
dacite = "^1.9.2"
fake-useragent = "^1.1.1"
freecurrencyapi = "^0.1.0"
pre-commit = "^2.20.0"
psutil = "^5.9.7"
requests = "^2.28.2"
ruff = "^0.0.253"
schedule = "^1.1.0"
pre-commit = "^4.5.1"
psutil = "^7.2.2"
requests = "^2.32.5"
ruff = "^0.14.14"
schedule = "^1.2.2"
selenium = "^4.14.0"
tox = [
{version = "^3", python = "<3.8"}, # because fake-useragent has a importlib-metadata constraint that conflicts
{version = "^4.4.5", python = ">=3.8"}
]
tox = "^4.34.1"
webdriver-manager = "~4"

[tool.poetry.dev-dependencies]
pytest = "^7.2.1"
pytest-sugar = "^0.9.6"
pytest = "^9.0.2"
pytest-sugar = "^1.1.1"

[build-system]
requires = ["poetry-core>=1.9.0"]
requires = ["poetry-core>=2.3.0"]
build-backend = "poetry.core.masonry.api"

[tool.poetry2conda]
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tox]
requires =
tox>=4
env_list = python{3.7,3.8}, py{39,310,311}
env_list = python{3.8}, py{39,310,311}

[testenv]
description = Run test suite using different Python versions
Expand Down
Loading