diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/geojson/fetch_shops.sh | 10 | ||||
-rwxr-xr-x | scripts/geojson/fetch_single.sh | 10 | ||||
-rwxr-xr-x | scripts/geojson/fetch_stations.sh | 10 |
3 files changed, 26 insertions, 4 deletions
diff --git a/scripts/geojson/fetch_shops.sh b/scripts/geojson/fetch_shops.sh new file mode 100755 index 0000000..84a9f3f --- /dev/null +++ b/scripts/geojson/fetch_shops.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +json=`curl 'https://wiki.linux-forks.de/mediawiki/api.php?action=query&format=json&list=categorymembers&cmtitle=Category:Shops&cmlimit=1000' 2>/dev/null` +cities=`echo "$json" | json_reformat | sed -n 's/.*"title":\s*"\([^"]*\).*/\1/p' | tr ' ' '_' | tr '\n' ' '` + +echo "[" +for city in $cities; do + ./fetch_single.sh "$city" +done +echo "{}]" diff --git a/scripts/geojson/fetch_single.sh b/scripts/geojson/fetch_single.sh index 61ab79d..e669f68 100755 --- a/scripts/geojson/fetch_single.sh +++ b/scripts/geojson/fetch_single.sh @@ -1,9 +1,11 @@ #!/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" | sed -s "s/\\\\\\\\n//g"` +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'` -image=`echo "$json" | sed -n "s/.*image = \([^|]*\).*/\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"` @@ -19,7 +21,7 @@ if [[ "$coord_x" != "" && "$coord_y" != "" ]]; then \"name\": \"$title\",\ \"amenity\": \"City\",\ \"description\": \"$description\",\ - \"image\": \"https://wiki.linux-forks.de/mediawiki/images/thumb/0/0e/$image/250px-$image\"\ + \"image\": \"$image\"\ },\ \"geometry\": {\ \"type\": \"Point\",\ diff --git a/scripts/geojson/fetch_stations.sh b/scripts/geojson/fetch_stations.sh new file mode 100755 index 0000000..8b76428 --- /dev/null +++ b/scripts/geojson/fetch_stations.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +json=`curl 'https://wiki.linux-forks.de/mediawiki/api.php?action=query&format=json&list=categorymembers&cmtitle=Category:Stations&cmlimit=1000' 2>/dev/null` +cities=`echo "$json" | json_reformat | sed -n 's/.*"title":\s*"\([^"]*\).*/\1/p' | tr ' ' '_' | tr '\n' ' '` + +echo "[" +for city in $cities; do + ./fetch_single.sh "$city" +done +echo "{}]" |