Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #function: test_image_day
- test_image_day () {
- case $1 in
- su)
- echo 1su
- ;;
- msu)
- echo 2msu
- ;;
- psu)
- echo 3psu
- ;;
- ic)
- echo 4ic
- ;;
- h)
- echo 5h
- ;;
- mc)
- echo 6mc
- ;;
- c)
- echo 7c
- ;;
- d)
- echo 8d
- ;;
- f)
- echo 9f
- ;;
- s)
- echo 10s
- ;;
- mcs)
- echo 11mcs
- ;;
- psus)
- echo 12psus
- ;;
- t)
- echo 13t
- ;;
- mct)
- echo 14mct
- ;;
- psut)
- echo 15psut
- ;;
- r)
- echo 16r
- ;;
- fl)
- echo 17fl
- ;;
- mcfl)
- echo 18mcfl
- ;;
- psfl)
- echo 19psfl
- ;;
- sn)
- echo 20sn
- ;;
- mcsn)
- echo 21mcsn
- ;;
- i)
- echo 22i
- ;;
- sl)
- echo 23sl
- ;;
- fr)
- echo 24fr
- ;;
- rsn)
- echo 25rsn
- ;;
- w)
- echo 26w
- ;;
- ho)
- echo 27ho
- ;;
- co)
- echo 28co
- ;;
- cl)
- echo 29cl
- ;;
- mcl)
- echo 31mcl
- ;;
- pc)
- echo 32pc
- ;;
- pcs)
- echo 36pcs
- ;;
- pct)
- echo 38pct
- ;;
- esac
- }
- #function: test_image_night
- test_image_night () {
- case $1 in
- su)
- echo 1su
- ;;
- msu)
- echo 2msu
- ;;
- psu)
- echo 3psu
- ;;
- c)
- echo 7c
- ;;
- d)
- echo 8d
- ;;
- f)
- echo 9f
- ;;
- s)
- echo 10s
- ;;
- psus)
- echo 12psus
- ;;
- t)
- echo 13t
- ;;
- psut)
- echo 15psut
- ;;
- r)
- echo 16r
- ;;
- fl)
- echo 17fl
- ;;
- psfl)
- echo 19psfl
- ;;
- sn)
- echo 20sn
- ;;
- i)
- echo 22i
- ;;
- sl)
- echo 23sl
- ;;
- fr)
- echo 24fr
- ;;
- rsn)
- echo 25rsn
- ;;
- ho)
- echo 27ho
- ;;
- co)
- echo 28co
- ;;
- cl)
- echo 29cl
- ;;
- w)
- echo 30w
- ;;
- mcl)
- echo 31mcl
- ;;
- pc)
- echo 32pc
- ;;
- ic)
- echo 33ic
- ;;
- h)
- echo 34h
- ;;
- mc)
- echo 35mc
- ;;
- pcs)
- echo 36pcs
- ;;
- mcs)
- echo 37mcs
- ;;
- pct)
- echo 38pct
- ;;
- mct)
- echo 39mct
- ;;
- mcfl)
- echo 40mcfl
- ;;
- mcsn)
- echo 41mcsn
- ;;
- esac
- }
- #put your Accuweather address here
- address="http://www.accuweather.com/ru/ua/kiev/324505/weather-forecast/324505"
- loc_id=$(echo $address|sed 's/\/weather-forecast.*$//'|sed 's/^.*\///')
- last_number=$(echo $address|sed 's/^.*\///')
- curr_addr="$(echo $address|sed 's/weather-forecast.*$//')"current-weather/"$last_number"
- addr1="$(echo $address|sed 's/weather-forecast.*$//')"daily-weather-forecast/"$last_number"
- addr2="$addr1"?day=6
- kill -STOP $(pidof conky)
- killall wget
- wget --save-cookies $HOME/Accuweather_Conky_Int_Images/cookie -O $HOME/Accuweather_Conky_Int_Images/curr_cond_raw $curr_addr
- wget --load-cookies $HOME/Accuweather_Conky_Int_Images/cookie -O $HOME/Accuweather_Conky_Int_Images/first_days_raw $addr1
- wget --load-cookies $HOME/Accuweather_Conky_Int_Images/cookie -O $HOME/Accuweather_Conky_Int_Images/last_days_raw $addr2
- #Current Conditions - curr_cond file
- if [[ -s $HOME/Accuweather_Conky_Int_Images/curr_cond_raw ]]; then
- egrep -i '"detail-tab-panel |>Today<\/a>|>Tonight<\/a>|>Early AM<\/a>|>Overnight<\/a>|>Mon<\/a>|>Tue<\/a>|>Wed<\/a>|>Thu<\/a>|>Fri<\/a>|>Sat<\/a>|>Sun<\/a>|icon i-|"cond"|"temp"|var d = '\''|var s = '\''|Humidity: |Pressure: |Cloud Cover: |UV Index: |Dew Point: |Precipitation(1 hr): |Visibility: |"start">|"finish">' $HOME/Accuweather_Conky_Int_Images/curr_cond_raw > $HOME/Accuweather_Conky_Int_Images/curr_cond
- sed -i -e 's/^[ \t]*//g' -e 's/^.*icon i-//g' -e 's/^.*"cond">//g' -e 's/>Lo</\n/g' -e 's/RealFeel/\n/g' $HOME/Accuweather_Conky_Int_Images/curr_cond
- sed -i -e 's/^.*"#">//g' -e 's/^.*<strong class="temp"//g' -e 's/^>//g' -e 's/<span>°.*$//g' $HOME/Accuweather_Conky_Int_Images/curr_cond
- sed -i -e 's/<\/a>.*$//g' -e 's/\/span> //g' -e 's/var d = //g' -e 's/var s = //g' -e 's/"temp">/\n/g' $HOME/Accuweather_Conky_Int_Images/curr_cond
- sed -i -e 's/^.*"start">//g' -e 's/^.*"finish">//g' -e 's/<li>//g' -e 's/<strong>//g' -e 's/<<span.*$//g' $HOME/Accuweather_Conky_Int_Images/curr_cond
- sed -i -e 's/<\/span>//g' -e 's/<\/strong><\/li>//g' -e 's/ "><\/div>//g' -e 's/'\''//g' $HOME/Accuweather_Conky_Int_Images/curr_cond
- sed -i -e 's/"><\/div>//g' -e 's/^.*; //g' -e 's/&#.*$//g' -e 's/ i-alarm.*$//g' -e 's/;//g' $HOME/Accuweather_Conky_Int_Images/curr_cond
- sed -i -e 's/Humidity: //g' -e 's/Pressure: //g' -e 's/Cloud Cover: //g' -e 's/UV Index: //g' -e 's/Dew Point: //g' -e 's/Visibility: //g' $HOME/Accuweather_Conky_Int_Images/curr_cond
- sed -i -e 's/^.*detail-tab-panel //g' -e 's/">//g' -e 's/\r//g' -e 's/ *$//g' -e 's/mb.*$/mb/g' $HOME/Accuweather_Conky_Int_Images/curr_cond
- sed -i '1,12d' $HOME/Accuweather_Conky_Int_Images/curr_cond
- time=$(sed -n 1p $HOME/Accuweather_Conky_Int_Images/curr_cond)
- if [[ $time == Tonight || $time == Overnight || $time == "Early AM" ]]; then
- sed -i 3a- $HOME/Accuweather_Conky_Int_Images/curr_cond
- fi
- line35=$(sed -n 35p $HOME/Accuweather_Conky_Int_Images/curr_cond)
- sed -i '35d' $HOME/Accuweather_Conky_Int_Images/curr_cond
- sed -i 35a$line35 $HOME/Accuweather_Conky_Int_Images/curr_cond
- time=$(sed -n 26p $HOME/Accuweather_Conky_Int_Images/curr_cond)
- image=$(sed -n 27p $HOME/Accuweather_Conky_Int_Images/curr_cond)
- if [[ $time == day ]]; then
- sed -i 27s/$image/$(test_image_day $image)/ $HOME/Accuweather_Conky_Int_Images/curr_cond
- elif [[ $time == night ]]; then
- sed -i 27s/$image/$(test_image_night $image)/ $HOME/Accuweather_Conky_Int_Images/curr_cond
- fi
- cp $HOME/Accuweather_Conky_Int_Images/Forecast_Images/$(sed -n 27p $HOME/Accuweather_Conky_Int_Images/curr_cond).png $HOME/Accuweather_Conky_Int_Images/cc.png
- fi
- #First 5days - first_days file
- if [[ -s $HOME/Accuweather_Conky_Int_Images/first_days_raw ]]; then
- sed -i '/<div class="column-1 clearfix">/,/<div id=\"feature-history\">/!d' $HOME/Accuweather_Conky_Int_Images/first_days_raw
- egrep -i '>Today<|<p>[a-z]|>Mon<\/a>|>Tue<\/a>|>Wed<\/a>|>Thu<\/a>|>Fri<\/a>|>Sat<\/a>|>Sun<\/a>|icon i-|"cond"|"temp"|realfeel">RealFeel|realfeel">Precipitation' $HOME/Accuweather_Conky_Int_Images/first_days_raw > $HOME/Accuweather_Conky_Int_Images/first_days
- sed -i -e 's/^[ \t]*//g' -e 's/^.*icon i-//g' -e 's/^.*"cond">//g' -e 's/>Lo</\n/g' $HOME/Accuweather_Conky_Int_Images/first_days
- sed -i -e 's/ "><\/div>//g' -e 's/"><\/div>//g' -e 's/^.*"temp">//g' -e 's/<span>°.*$//g' $HOME/Accuweather_Conky_Int_Images/first_days
- sed -i -e 's/<p>//g' -e 's/<\/p>//g' -e 's/^.*"#">//g' -e 's/\/span> //g' -e 's/^.*>Precipitation //g' -e 's/^.*; //g' $HOME/Accuweather_Conky_Int_Images/first_days
- sed -i -e 's/&#.*$//g' -e 's/<.*$//g' -e 's/ i-alarm.*$//g' -e 's/\r//g' -e 's/ *$//g' $HOME/Accuweather_Conky_Int_Images/first_days
- sed -i -e 's/Today/TODAY/' -e 's/Mon$/MONDAY/' -e 's/Tue$/TUESDAY/' -e 's/Wed$/WEDNESDAY/' -e 's/Thu$/THURSDAY/' -e 's/Fri$/FRIDAY/' -e 's/Sat$/SATURDAY/' -e 's/Sun$/SUNDAY/' $HOME/Accuweather_Conky_Int_Images/first_days
- time=$(sed -n 1p $HOME/Accuweather_Conky_Int_Images/curr_cond)
- if [[ $time == Tonight || $time == Overnight || $time == "Early AM" ]]; then
- sed -i 2a- $HOME/Accuweather_Conky_Int_Images/first_days
- fi
- L1=$(sed -n 1p $HOME/Accuweather_Conky_Int_Images/first_days)
- if [[ $L1 == TODAY ]]; then
- sed -i 1d $HOME/Accuweather_Conky_Int_Images/first_days
- fi
- for (( i=6; i<=21; i+=5 ))
- do
- image_raw=$(sed -n "${i}"p $HOME/Accuweather_Conky_Int_Images/first_days)
- sed -i ${i}s/$image_raw/$(test_image_day $image_raw)/ $HOME/Accuweather_Conky_Int_Images/first_days
- cp $HOME/Accuweather_Conky_Int_Images/Forecast_Images/$(sed -n ${i}p $HOME/Accuweather_Conky_Int_Images/first_days).png $HOME/Accuweather_Conky_Int_Images/$i.png
- done
- image_raw=$(sed -n 25p $HOME/Accuweather_Conky_Int_Images/first_days)
- sed -i 25s/$image_raw/$(test_image_day $image_raw)/ $HOME/Accuweather_Conky_Int_Images/first_days
- cp $HOME/Accuweather_Conky_Int_Images/Forecast_Images/$(sed -n 25p $HOME/Accuweather_Conky_Int_Images/first_days).png $HOME/Accuweather_Conky_Int_Images/tod.png
- image_raw=$(sed -n 30p $HOME/Accuweather_Conky_Int_Images/first_days)
- sed -i 30s/$image_raw/$(test_image_day $image_raw)/ $HOME/Accuweather_Conky_Int_Images/first_days
- cp $HOME/Accuweather_Conky_Int_Images/Forecast_Images/$(sed -n 30p $HOME/Accuweather_Conky_Int_Images/first_days).png $HOME/Accuweather_Conky_Int_Images/ton.png
- fi
- #Last 5days - last_days file
- if [[ -s $HOME/Accuweather_Conky_Int_Images/last_days_raw ]]; then
- sed -i '/<div class="column-1 clearfix">/,/<div id=\"feature-history\">/!d' $HOME/Accuweather_Conky_Int_Images/last_days_raw
- egrep -i '>Mon<\/a>|>Tue<\/a>|>Wed<\/a>|>Thu<\/a>|>Fri<\/a>|>Sat<\/a>|>Sun<\/a>|icon i-|"cond"|"temp"|realfeel">RealFeel|realfeel">Precipitation' $HOME/Accuweather_Conky_Int_Images/last_days_raw > $HOME/Accuweather_Conky_Int_Images/last_days
- sed -i -e 's/^[ \t]*//g' -e 's/^.*icon i-//g' -e 's/^.*"cond">//g' -e 's/>Lo</\n/g' $HOME/Accuweather_Conky_Int_Images/last_days
- sed -i -e 's/ "><\/div>//g' -e 's/"><\/div>//g' -e 's/^.*"temp">//g' -e 's/<span>°.*$//g' $HOME/Accuweather_Conky_Int_Images/last_days
- sed -i -e 's/^.*"#">//g' -e 's/\/span> //g' -e 's/^.*>Precipitation //g' -e 's/^.*; //g' $HOME/Accuweather_Conky_Int_Images/last_days
- sed -i -e 's/&#.*$//g' -e 's/<.*$//g' -e 's/ i-alarm.*$//g' -e 's/\r//g' -e 's/ *$//g' $HOME/Accuweather_Conky_Int_Images/last_days
- sed -i -e 's/Mon$/MONDAY/' -e 's/Tue$/TUESDAY/' -e 's/Wed$/WEDNESDAY/' -e 's/Thu$/THURSDAY/' -e 's/Fri$/FRIDAY/' -e 's/Sat$/SATURDAY/' -e 's/Sun$/SUNDAY/' $HOME/Accuweather_Conky_Int_Images/last_days
- for (( i=2; i<=22; i+=5 ))
- do
- image_raw=$(sed -n "${i}"p $HOME/Accuweather_Conky_Int_Images/last_days)
- sed -i ${i}s/$image_raw/$(test_image_day $image_raw)/ $HOME/Accuweather_Conky_Int_Images/last_days
- cp $HOME/Accuweather_Conky_Int_Images/Forecast_Images/$(sed -n ${i}p $HOME/Accuweather_Conky_Int_Images/last_days).png $HOME/Accuweather_Conky_Int_Images/last_$i.png
- done
- fi
- #messages file
- sed -n 28p $HOME/Accuweather_Conky_Int_Images/curr_cond | cut -c -20 > $HOME/Accuweather_Conky_Int_Images/messages
- sed -n 29p $HOME/Accuweather_Conky_Int_Images/first_days | cut -c -20 >> $HOME/Accuweather_Conky_Int_Images/messages
- sed -n 34p $HOME/Accuweather_Conky_Int_Images/first_days | cut -c -20 >> $HOME/Accuweather_Conky_Int_Images/messages
- for (( i=7; i<=22; i+=5 ))
- do
- sed -n ${i}p $HOME/Accuweather_Conky_Int_Images/first_days | cut -c -20 >> $HOME/Accuweather_Conky_Int_Images/messages
- done
- for (( i=3; i<=23; i+=5 ))
- do
- sed -n ${i}p $HOME/Accuweather_Conky_Int_Images/last_days | cut -c -20 >> $HOME/Accuweather_Conky_Int_Images/messages
- done
- kill -CONT $(pidof conky)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement