Skip to content

Commit

Permalink
release v1.1.2 (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeN220 authored May 21, 2023
2 parents 0ddc6d1 + e1a971c commit 2db917a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repos:
name: flake8

- repo: https://github.com/pycqa/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
name: isort
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,6 @@ A - Да. Для этого вам нужно перечислить ссылк

Q - Можно ли уменьшить задержку между запросами? <br>
A - Нет, это ограничение идет со стороны Market API и обойти его никак нельзя.

Q - У меня при работе приложения вылезла ошибка "Получена неизвестная ошибка". Что делать? <br>
A - Конкретных решений данной проблемы нет. Но чаще всего она появляется из-за слишком частых запросов. Возможно, у вас работает дополнительно другое приложение, которое также взаимодействует с торговой площадкой. В данном случае вам придется отключить одно из приложений.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "lolz-auto-buyer"
version = "1.1.1"
version = "1.1.2"
description = "Application for buying accounts from market lolzteam forum"
authors = ["ZeN220 <[email protected]>"]

Expand Down
5 changes: 2 additions & 3 deletions src/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from src.telegram import TelegramAPI

TELEGRAM_MESSAGE = (
'👷 Приобретен аккаунт: <a href="https://lzt.market/{item_id}">'
'🎊 Приобретен аккаунт: <a href="https://lzt.market/{item_id}">'
"{title}</a>\n"
"💲 Цена: <code>{price}₽</code>\n"
'👷 Продавец: <a href="https://zelenka.guru/members/{seller_id}">'
Expand Down Expand Up @@ -42,8 +42,7 @@ def main():
len(items),
)

for item in items:
item_id = item["item_id"]
for item_id, item in items.items():
market_item = MarketItem(item, lolzteam_token)
try:
logging.info("Покупаю аккаунт %s", item_id)
Expand Down
14 changes: 13 additions & 1 deletion src/market/base.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import json
import logging
import time
from socket import error as socket_error
from typing import Optional
from urllib import error, parse, request

from .errors import MarketBuyError

logger = logging.getLogger(__name__)


class BaseMarketAPI:
API_URL: str = "https://api.lzt.market/"
Expand Down Expand Up @@ -45,7 +48,16 @@ def api_request(

except error.HTTPError as http_error:
error_response = http_error.read().decode("utf-8")
error_response = json.loads(error_response).get("errors")
logger.warning("Получена ошибка: %s", error_response)
try:
error_response = json.loads(error_response).get("errors")
except json.decoder.JSONDecodeError:
"""
Some errors return body as HTML,
so error is logged and called MarketBuyError
to stop application
"""
raise MarketBuyError("Получена неизвестная ошибка")
raise MarketBuyError(error_response[0])
except (error.URLError, socket_error):
"""
Expand Down

0 comments on commit 2db917a

Please sign in to comment.