Skip to content

Commit

Permalink
Merge pull request #7 from nihalsid/flathunters_official
Browse files Browse the repository at this point in the history
Slight clean up around enabling distance API
  • Loading branch information
codders authored May 25, 2020
2 parents 2292ef3 + 4155536 commit 5438b81
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions config.yaml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,11 @@ message: |
# The URL should most probably just kept like that.
# To use the Google Maps API, an API key is required. You can obtain one
# without costs from the Google App Console (just google for it).
# Additionally, to enable the API calls in the code, set the 'enable' key to True
google_maps_api:
key: YOUR_API_KEY
url: https://maps.googleapis.com/maps/api/distancematrix/json?origins={origin}&destinations={dest}&mode={mode}&sensor=true&key={key}&arrival_time={arrival}
enable: False

# Sending messages using Telegram requires a Telegram Bot configured.
# Telegram.org offers a good documentation about how to create a bot.
Expand Down
10 changes: 6 additions & 4 deletions flathunter/hunter.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,19 @@ def hunt_flats(self, searchers, id_watch):
self.__log__.debug("Loaded address %s for url %s" % (address, url))
break

# calculdate durations
# calculate durations if enabled
durations_enabled = "google_maps_api" in self.config and self.config["google_maps_api"]["enable"]
if durations_enabled:
durations = self.get_formatted_durations(self.config, address).strip()

message = self.config.get('message', "").format(
title=expose['title'],
rooms=expose['rooms'],
size=expose['size'],
price=expose['price'],
url=expose['url'],
address=address,
durations="").strip()
# UNCOMMENT below and COMMENT Above to enable duration feature
# durations=self.get_formatted_durations(config, address)).strip()
durations="" if not durations_enabled else durations).strip()

# if no excludes, send messages
if len(self.excluded_titles) == 0:
Expand Down

0 comments on commit 5438b81

Please sign in to comment.