diff options
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/python/opentable_restaurants.py | 6 | ||||
-rwxr-xr-x | tools/unix/generate_planet.sh | 10 |
2 files changed, 13 insertions, 3 deletions
diff --git a/tools/python/opentable_restaurants.py b/tools/python/opentable_restaurants.py index b4392827aa..4ed17b3b30 100755 --- a/tools/python/opentable_restaurants.py +++ b/tools/python/opentable_restaurants.py @@ -33,7 +33,7 @@ class OpentableDownloader(object): def download(self): headers = self._add_auth_header({'Content-Type': 'application/json'}) - url = 'https://platform.otqa.com/sync/listings' + url = 'https://platform.opentable.com/sync/listings' with open(self.opentable_filename, 'w') as f: offset = 0 @@ -57,7 +57,7 @@ class OpentableDownloader(object): offset += items_count def _get_token(self): - url = 'https://oauth-pp.opentable.com/api/v2/oauth/token?grant_type=client_credentials' + url = 'https://oauth.opentable.com/api/v2/oauth/token?grant_type=client_credentials' headers = self._add_auth_header({}) request = urllib2.Request(url, headers=headers) logging.debug('Fetching token with headers %s', str(headers)) @@ -111,7 +111,7 @@ if __name__ == '__main__': loader.download() if args.tsv is not None: data = open(args.opentable_data) - tsv = open(args.tsv) if args.tsv else sys.stdout + tsv = open(args.tsv, 'w') if args.tsv else sys.stdout try: make_tsv(data, tsv) finally: diff --git a/tools/unix/generate_planet.sh b/tools/unix/generate_planet.sh index 74c18ed928..0d6749bb5a 100755 --- a/tools/unix/generate_planet.sh +++ b/tools/unix/generate_planet.sh @@ -170,6 +170,8 @@ ROADS_SCRIPT="$PYTHON_SCRIPTS_PATH/road_runner.py" HIERARCHY_SCRIPT="$PYTHON_SCRIPTS_PATH/hierarchy_to_countries.py" BOOKING_SCRIPT="$PYTHON_SCRIPTS_PATH/booking_hotels.py" BOOKING_FILE="${BOOKING_FILE:-$INTDIR/hotels.csv}" +OPENTABLE_SCRIPT="$PYTHON_SCRIPTS_PATH/opentable_restaurants.py" +OPENTABLE_FILE="${OPENTABLE_FILE:-$INTDIR/restaurants.csv}" TESTING_SCRIPT="$SCRIPTS_PATH/test_planet.sh" PYTHON="$(which python2.7)" MWM_VERSION_FORMAT="%s" @@ -255,6 +257,13 @@ if [ "$MODE" == "coast" ]; then echo "Hotels have been downloaded. Please ensure this line is before Step 4." >> "$PLANET_LOG" fi + # Download opentable.com restaurants. This takes around 30 minutes. + if [ ! -f "$OPENTABLE_FILE" -a -n "${OPENTABLE_USER-}" -a -n "${OPENTABLE_PASS-}" ]; then + log "STATUS" "Step C: Starting background restaurants downloading" + $PYTHON $OPENTABLE_SCRIPT --client $OPENTABLE_USER --secrete $OPENTABLE_PASS --opentable_data "$INTDIR"/opentable.json --download --tsv "$OPENTABLE_FILE" 2>"$LOG_PATH"/opentable.log & + echo "Hotels have been downloaded. Please ensure this line is before Step 4." >> "$PLANET_LOG" + fi + [ ! -x "$OSMCTOOLS/osmupdate" ] && cc -x c "$OMIM_PATH/tools/osmctools/osmupdate.c" -o "$OSMCTOOLS/osmupdate" [ ! -x "$OSMCTOOLS/osmfilter" ] && cc -x c -O3 "$OMIM_PATH/tools/osmctools/osmfilter.c" -o "$OSMCTOOLS/osmfilter" if [ -n "$OPT_DOWNLOAD" ]; then @@ -400,6 +409,7 @@ if [ "$MODE" == "features" ]; then [ -n "$OPT_WORLD" ] && PARAMS_SPLIT="$PARAMS_SPLIT -generate_world" [ -n "$OPT_WORLD" -a "$NODE_STORAGE" == "map" ] && log "WARNING: generating world files with NODE_STORAGE=map may lead to an out of memory error. Try NODE_STORAGE=mem if it fails." [ -f "$BOOKING_FILE" ] && PARAMS_SPLIT="$PARAMS_SPLIT --booking_data=$BOOKING_FILE" + [ -f "$OPENTABLE_FILE" ] && PARAMS_SPLIT="$PARAMS_SPLIT --opentable_data=$OPENTABLE_FILE" "$GENERATOR_TOOL" --intermediate_data_path="$INTDIR/" --node_storage=$NODE_STORAGE --osm_file_type=o5m --osm_file_name="$PLANET" \ --data_path="$TARGET" --user_resource_path="$DATA_PATH/" $PARAMS_SPLIT 2>> "$PLANET_LOG" MODE=mwm |