#!/bin/bash

# wminfo plugin: currencies exchange rates of Polish zloty (average)

# command: wminfo -p currencies-pl-avg.wmi -b#333251 -f#ffffff

lynx --source localhost/wminfo/currencies-pl-avg.html | \
    perl -pe 's/\n//;s/<td class=(.*)?>/\n<td class=$1>/g' | \
    grep 'td class' | grep -E 'symbol|average' | \
    perl -pe 's/<\/strong>.*/<\/strong>/g;s/<\/a><\/strong>\n//' | \
    tr '\r\t' ' ' | \
    perl -pe 's/<.*?>/ /g;s/ +/ /g' | \
    perl -pe 's/ [0-9]+ ([A-Z]+) \n/$1/' | \
    perl -pe 's/CLP (.)\.(....)/CLP 0.0$1$2/;s/INR (.)\.(....)/INR 0.0$1$2/' | \
    perl -pe 's/ISK (.)\.(....)/ISK 0.0$1$2/;s/JPY (.)\.(....)/JPY 0.0$1$2/' | \
    perl -pe 's/KRW (.)\.(....)/KRW 0.0$1$2/;s/HUF (.)\.(....)/HUF 0.0$1$2/' | \
    perl -pe 's/IDR (.)\.(....)/IDR 0.000$1$2/' | \
    sort
echo
