thbkrkr
3/12/2013 - 4:34 PM

playSongWhenNewMantis.sh

#!/bin/bash

company="xxxxx"

url="http://v-ideoproject.${company}.fr/mantis/extension/search/?s=e&id_project=164"

mv .current_mantis .last_mantis

raw=$(curl -s "$url" | grep 'mantis/' | iconv -f iso8859-1 -t utf-8)

echo "$raw"  | sed "s/.* did=\"\([0-9]*\)\" dtype=\"\(.*\)\" dstatus=\"\(.*\)\" dtitle=\"\(.*\)\" dusername=\"\(.*\)\" dseverity=\"\(.*\)\" dpriority=\"\(.*\)\" dcategory=\"\(.*\)\" dstep=\"\(.*\)\" target.*/\1@\2@\3@\4@\5@\6@\7@\8@\9/" > .current_mantis

is_new=$(diff .current_mantis .last_mantis | grep -c "<.*Nouveau")

if [ $is_new != 0 ]; then

        new=$(diff .current_mantis .last_mantis | grep "< .*Nouveau" | sed "s/^< //")

        sid=$(echo "$new" | cut -d "@" -f1)
        stype=$(echo "$new" | cut -d "@" -f2)
        sstatus=$(echo "$new" | cut -d "@" -f3)
        stitle=$(echo "$new" | cut -d "@" -f4 | sed "s/[\[-\]]*//g")
        susername=$(echo "$new" | cut -d "@" -f5)
        dseverity=$(echo "$new" | cut -d "@" -f6)
        dpriority=$(echo "$new" | cut -d "@" -f7)
        dcategory=$(echo "$new" | cut -d "@" -f8)
        dstep=$(echo "$new" | cut -d "@" -f9)

        TEXT="Attention! Le nouveau mantisse, étape $dstep, catégorie $dcategory, type $stype, numéro $sid, séverité $dseverity, priorité $dpriority, rapporté par $susername, est arrivé en gare du $company, poil au kiki"

        TEXT=$(echo "$TEXT" | sed "s/ /%20/g")

        curl "http://www.ispeech.org/p/generic/getaudio?text=${TEXT}%2C&voice=eurfrenchfemale&speed=0&action=convert" > ~/zikbox/newMantis/newmantis.mp3

        mocp -S; mocp -c -m ~/zikbox/newMantis/ -a -p
fi