Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch currency conversion errors #76

Merged
merged 1 commit into from
Apr 8, 2024
Merged
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
22 changes: 13 additions & 9 deletions discogs_alert/loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ def loop(
time.sleep(60)

for listing in client_anon.get_marketplace_listings(release.id):
listing = listing.convert_currency(currency) # convert —> the base currency
try:
listing = listing.convert_currency(currency) # convert —> the base currency
except: # noqa: E722
logger.warning("Currency conversion failed, => continuing without.", exc_info=True)

# if listing is definitely unavailable, move to the next listing
if listing.is_definitely_unavailable(country):
Expand All @@ -101,14 +104,15 @@ def loop(
continue

# if the price is above our threshold, move to the next listing
if listing.price_is_above_threshold(release.price_threshold):
if verbose:
logger.info(
f"Listing found that's above the price threshold:\n"
f"\tRelease: {release.display_title}\n"
f"\tListing: {listing.url}"
)
continue
if listing.price.currency == currency:
if listing.price_is_above_threshold(release.price_threshold):
if verbose:
logger.info(
f"Listing found that's above the price threshold:\n"
f"\tRelease: {release.display_title}\n"
f"\tListing: {listing.url}"
)
continue

valid_listings.append(listing)

Expand Down
Loading