lifo-dijkstraserv/scripts/geojson/fetch_single.sh
Gabriel Pérez-Cerezo 19435b1d99 Fancy icons, shops, stations
Added fancy actions (TODO: include script to install)

* added fetcher script for shops
* added fetcher script for stations
* fixed thumbnails
2020-04-15 01:08:31 +02:00

32 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
json=`curl "https://wiki.linux-forks.de/mediawiki/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=$1&rvsection=0&rvslots=main" 2>/dev/null | sed -s "s/\\\\\\\\n//g"`
title=`echo $json | sed -n 's/.*"title":\s*"\([^"]\+\).*/\1/p'`
img=$(curl "https://wiki.linux-forks.de/mediawiki/index.php/$1" 2>/dev/null | sed s/\"/\\n/g | grep /thumb/ | head -n 1)
image="https://wiki.linux-forks.de$img"
coords=`echo "$json" | sed -n "s/.*coordinates = {{Co|\([^}]*\).*/\1/p"`
coord_x=`echo "$coords" | sed -n "s/\([^|]\+\).*/\1/p"`
coord_y=`echo "$coords" | sed -n "s/.*|\([^|]\+\).*/\1/p"`
description=`echo $json | sed -n "s/.*coordinates.*[^']*'''\([^']*\)'''\([^\.]*\).*/\1\2./p"
`
if [[ "$coord_x" != "" && "$coord_y" != "" ]]; then
echo "{\
\"type\": \"Feature\",\
\"properties\": {\
\"name\": \"$title\",\
\"amenity\": \"City\",\
\"description\": \"$description\",\
\"image\": \"$image\"\
},\
\"geometry\": {\
\"type\": \"Point\",\
\"coordinates\": [$coord_x, $coord_y]\
}\
},"
fi