#!/bin/bash

cd /home/tunes/downloads

# Just some stats gathering
echo "Track-count yesterday:"
wc /home/tunes/recentfiles.txt
find /home/tunes/ -name \*.mp3 -mtime -42 -print > /home/tunes/recentfiles.txt
echo "Track-count after old tracks removed:"
wc /home/tunes/recentfiles.txt

# Delete any downloaded files older than 42 days as they won't get chosen anyway
find /home/tunes/downloads/ -name \*.mp3 -mtime +42 -exec rm {} \;

wget -q -r -l1 -H -N -t1 -nd -A.mp3 -w5 -erobots=off -P newflux http://newflux.blogspot.com/
# Said The Gramophone has wget avoidance scripts in place now
#wget -q -r -l1 -H -N -t1 -nd -A.mp3 -w5 -erobots=off -P said_the_gramaphone http://www.tangmonkey.com/blogs/music/
wget -q -r -l1 -H -N -t1 -nd -A.mp3 -w5 -erobots=off -P music_for_robots http://music.for-robots.com/
wget -q -r -l1 -H -N -t1 -nd -A.mp3 -w5 -erobots=off -P talkiewalkie http://www.livejournal.com/community/talkiewalkie/
wget -q -r -l1 -H -N -t1 -nd -A.mp3 -w5 -erobots=off -P soul_sides http://www.o-dub.com/crates/weblog/blogger.html
wget -q -r -l1 -H -N -t1 -nd -A.mp3 -w5 -erobots=off -P cocaine_blunts http://multsanta.madvision.co.uk/blunts/newsblog/news2.html
wget -q -r -l1 -H -N -t1 -nd -A.mp3 -w5 -erobots=off -P number_1_songs_in_heaven http://www.londonlee.com/blog.html
wget -q -r -l1 -H -N -t1 -nd -A.mp3 -w5 -erobots=off -P sleeve_notes http://www.sleeve-notes.com/blog.html
wget -q -r -l1 -H -N -t1 -nd -A.mp3 -w5 -erobots=off -P pitchfork http://www.pitchforkmedia.com/mp3/
ls teachingtheindiekidstodanceagain | wc
wget -q -r -l1 -H -N -t1 -nd -A.mp3 -w5 -erobots=off -P teachingtheindiekidstodanceagain http://teachingtheindiekidstodanceagain.blogspot.com/

# Now we've got the new music, let's build the list of recent files
find /home/tunes/ -name \*.mp3 -mtime -42 -print > /home/tunes/recentfiles.txt

echo "Track-count now:"
wc /home/tunes/recentfiles.txt