-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathhow-much.py
45 lines (29 loc) · 1.13 KB
/
how-much.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import sys
import yaml
from domain.client import DomainClient
if __name__ == "__main__":
dc = DomainClient("client_credentials.yaml")
# TODO: Check if it's a listing ID or URL
address_parts = sys.argv[1:]
if len(address_parts) == 1:
try:
recent_listing_id = int(address_parts[0])
except:
# URL
None
else:
input_address = " ".join(sys.argv[1:])
properties_suggest = dc.properties_suggest(input_address)
if properties_suggest[0]["relativeScore"] < 100:
raise a
property_ = dc.properties(properties_suggest[0]["id"])
# Get most recent listing.
try:
recent_listing_id = sorted(set([ph["advertId"] for ph in property_.get("photos", [])]))[-1]
except IndexError:
raise ValueError(f"no property listings found for {property_['address']}")
# Get sold details.
listing = dc.listings(recent_listing_id)
details = dict(addressParts=listing["addressParts"],
saleDetails=listing["saleDetails"])
print(yaml.dump(details, sort_keys=True, indent=2))