Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ############################################
- # change this variable to the current week #
- WEEK="27"
- ############################################
- # create working directory
- mkdir weeklybeats_download_script
- cd weeklybeats_download_script
- # retrieve RSS file
- wget http://weeklybeats.com/music/rss
- # set limits
- PWEEK=$(($WEEK - 1))
- X=$(sed -n '/weeklybeats-2012_'$PWEEK'_/{=;q;}' rss)
- T=true
- C="<item>"
- while [ $T == true ]; do
- X=$(($X - 1))
- Y=$(sed $X'q;d' rss)
- if [ $Y == $C ]; then
- T=false
- fi
- done
- LIMIT1=$X
- LIMIT2=$(sed -n '$=' rss)
- # cut out necessary info
- sed $LIMIT1','$LIMIT2'd' rss > rss1
- sed 's/_'$WEEK'_/&/w temp_mp3_links' <rss1
- sed 's/<title><!\[CDATA\[Week '$WEEK' - /&/w temp_titles' <rss1
- sed 's/\/itunes:summary/&/w temp_licenses' <rss1
- # clean mp3 links file
- sed 's/ <enclosure url=/wget /w mp3_links1' <temp_mp3_links
- sed 's/ type=\"audio\/mpeg\" \/>/ /w mp3_links2' <mp3_links1
- # clean copyright file
- sed 's/\]\]><\/itunes:summary>/ /w licenses1' <temp_licenses
- # clean song titles file
- sed 's/ <title><!\[CDATA\[Week '$WEEK' - /- /w titles1' <temp_titles
- sed 's/\]\]><\/title>/ /w titles2' <titles1
- # organize copyright file
- paste titles2 licenses1 > copyright
- cp copyright ..
- # download mp3s
- chmod +x mp3_links2
- ./mp3_links2
- # delete temp files
- rm rss rss1 temp_* mp3_links* licenses1 titles*
- # package into zip file
- zip weeklybeats_week$WEEK.zip *
- mv weeklybeats_week$WEEK.zip ..
- # delete temp files
- rm rss rss1 temp_* mp3_links* licenses1 titles*
- # package into zip file
- zip weeklybeats_week$WEEK.zip *
- mv weeklybeats_week$WEEK.zip ..
- # delete other stuff
- cd ..
- rm -rf weeklybeats_download_script
- ############################################
- # The following are the lines that I use to create the torrent file
- # and upload it to dropbox to share in the torrent thread. These are
- # mainly just here for my personal use. If all you want is to make a
- # zip of the current week then just leave these commented.
- ############################################
- # create torrent
- #mktorrent -a "udp://tracker.openbittorrent.com:80" weeklybeats_week$WEEK.zip
- # move files to folders
- #cp weeklybeats_week$WEEK.zip.torrent ~/Dropbox/Public/
- #mv weeklybeats_week$WEEK.zip ~/torrent/
- #mv weeklybeats_week$WEEK.zip.torrent ~/torrent/watch/
- ############################################
- # advance WEEK variable by one for next week
- NWEEK=$(($WEEK + 1))
- # note- change this to the script's directory
- cd /home/dcs/stuff/
- sed "5s/"$WEEK"/"$NWEEK"/" weeklybeats.sh > weeklybeats.sh.new
- mv weeklybeats.sh.new weeklybeats.sh
- chmod +x weeklybeats.sh
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement