forked from mraza007/yelp-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
100 lines (95 loc) · 2.98 KB
/
main.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
from __future__ import print_function, unicode_literals
import regex
import os
from pprint import pprint
import emoji
from PyInquirer import style_from_dict, Token, prompt, Separator
from examples import custom_style_2
import json
from termcolor import colored
from yelpapi import YelpAPI
api_key = os.environ['API_KEY']
yelp_api = YelpAPI(api_key)
questions = [
{
'type': 'input',
'name': 'food',
'message': emoji.emojize('What are you looking to eat ? :sushi:,:pizza:,:hamburger:'),
},
{
'type': 'list',
'name': 'city',
'message': 'Choose your City',
'choices': [
"New York City",
"Los Angeles",
"Chicago",
"Houston",
"Philadelphia",
"Phoenix",
"San Antonio",
"San Diego",
"Dallas",
"San Jose",
"Austin",
"Jacksonville",
"San Francisco",
"Indianapolis",
"Columbus",
"Fort Worth",
"Charlotte",
"Detroit",
"El Paso",
"Seattle ",
"Denver ",
"Washington",
"Memphis",
"Boston ",
"Nashville-Davidson",
"Baltimore",
"Not Listed"
]
},
]
answers = prompt(questions, style=custom_style_2)
if answers['city'] == 'Not Listed':
x = input("What\'s your city: ")
search_results = yelp_api.search_query(
term=answers['food'],
location=answers['city'],
sort_by='rating',
limit=5)
print('Here are few restaurants I found ')
for nums in search_results['businesses']:
print('Name : ' +
colored(nums['name'], 'white', attrs=['bold']) +
'\n' +
'Phone: ' +
colored(nums['phone'], 'green', attrs=['bold']) +
'\n' +
'Address: ' +
colored(nums['location']['address1'],'cyan',attrs=['bold']) +
'\n' +
colored('Yelp url: ','red',attrs=['bold']) +
nums['url']
)
else:
search_results = yelp_api.search_query(
term=answers['food'],
location=answers['city'],
sort_by='rating',
limit=5)
print('Here are few restaurants I found ')
for nums in search_results['businesses']:
print('Name : ' +
colored(nums['name'], 'white', attrs=['bold']) +
'\n' +
'Phone: ' +
colored(nums['phone'], 'green', attrs=['bold']) +
'\n' +
'Address: ' +
colored(nums['location']['address1'],'cyan',attrs=['bold']) +
'\n' +
colored('Yelp url: ','red',attrs=['bold']) +
nums['url']
)