2020-04-14 18:10:19 +02:00
#!/bin/bash
2020-04-15 01:08:31 +02:00
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" `
2020-04-14 18:10:19 +02:00
title = ` echo $json | sed -n 's/.*"title":\s*"\([^"]\+\).*/\1/p' `
2020-04-15 01:08:31 +02:00
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 "
2020-04-14 18:10:19 +02:00
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" `
2020-04-15 19:47:23 +02:00
description = ` curl " https://wiki.linux-forks.de/mediawiki/api.php?action=parse&page= $1 §ion=0&prop=text&format=json " 2>/dev/null | sed -z -n "s/<\/p><p>//g;s/.*<p>\(.*\)<\/p>.*/\1/p" | sed s,\" /mediawiki/index.php,\" https://wiki.linux-forks.de/mediawiki/index.php,g`
2020-04-15 19:14:03 +02:00
2020-04-14 18:10:19 +02:00
if [ [ " $coord_x " != "" && " $coord_y " != "" ] ] ; then
echo " {\
\" type\" : \" Feature\" ,\
\" properties\" : { \
\" name\" : \" $title \" ,\
\" amenity\" : \" City\" ,\
\" description\" : \" $description \" ,\
2020-04-15 01:08:31 +02:00
\" image\" : \" $image \" \
2020-04-14 18:10:19 +02:00
} ,\
\" geometry\" : { \
\" type\" : \" Point\" ,\
\" coordinates\" : [ $coord_x , $coord_y ] \
} \
} ,"
fi