-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Labels
Description
The json parsing seen below is not the most adequate in regards to good practices:
Lines 17 to 26 in 1e2bf53
| ip=`sed -nr 's/.+"ip":"([0-9\.]+).+/\1/p' "$tempfile"` | |
| continent=`sed -nr 's/.+"continent_code":"([^"]*).+/\1/p' "$tempfile"` | |
| city=`sed -nr 's/.+"city":"([^"]*).+/\1/p' "$tempfile"` | |
| isp=`sed -nr 's/.+"organization":"([^"]*).+/\1/p' "$tempfile"` | |
| country=`sed -nr 's/.+"country":"([^"]*).+/\1/p' "$tempfile"` | |
| timezone=`sed -nr 's/.+"timezone":"([^"]*).+/\1/p' "$tempfile"` | |
| latitude=`sed -nr 's/.+"latitude":([^,]*).+/\1/p' "$tempfile"` | |
| longitude=`sed -nr 's/.+"longitude":([^,]*).+/\1/p' "$tempfile"` | |
| asn=`sed -nr 's/.+"asn":([^,]*).+/\1/p' "$tempfile"` | |
| region=`sed -nr 's/.+"region":"([^"]*).+/\1/p' "$tempfile"` |
It should probably be refactored using associative arrays (dictionaries) and a loop. There are some minor tricks to this - the regex pattern isn't always the same - but it could be done without much hassle. I propose this to anyone who wants to contribute. :)
@trakBan, would be great if you could label this with "Suggestion" or something like that. + "Help wanted" or "Good first issue".