Advertisement
jiffypop23

WeeklyBeats Download Script

Apr 10th, 2012
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.68 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. ############################################
  4. # change this variable to the current week #
  5. WEEK="27"
  6. ############################################
  7.  
  8. # create working directory
  9. mkdir weeklybeats_download_script
  10. cd weeklybeats_download_script
  11.  
  12. # retrieve RSS file
  13. wget http://weeklybeats.com/music/rss
  14.  
  15. # set limits
  16. PWEEK=$(($WEEK - 1))
  17. X=$(sed -n '/weeklybeats-2012_'$PWEEK'_/{=;q;}' rss)
  18. T=true
  19. C="<item>"
  20. while [ $T == true ]; do
  21.         X=$(($X - 1))
  22.         Y=$(sed $X'q;d' rss)
  23.         if [ $Y == $C ]; then
  24.                 T=false
  25.         fi
  26. done
  27. LIMIT1=$X
  28. LIMIT2=$(sed -n '$=' rss)
  29.  
  30. # cut out necessary info
  31. sed $LIMIT1','$LIMIT2'd' rss > rss1
  32. sed 's/_'$WEEK'_/&/w temp_mp3_links' <rss1
  33. sed 's/<title><!\[CDATA\[Week '$WEEK' - /&/w temp_titles' <rss1
  34. sed 's/\/itunes:summary/&/w temp_licenses' <rss1
  35.  
  36. # clean mp3 links file
  37. sed 's/            <enclosure url=/wget /w mp3_links1' <temp_mp3_links
  38. sed 's/ type=\"audio\/mpeg\" \/>/ /w mp3_links2' <mp3_links1
  39.  
  40. # clean copyright file
  41. sed 's/\]\]><\/itunes:summary>/ /w licenses1' <temp_licenses
  42.  
  43. # clean song titles file
  44. sed 's/            <title><!\[CDATA\[Week '$WEEK' - /- /w titles1' <temp_titles
  45. sed 's/\]\]><\/title>/ /w titles2' <titles1
  46.  
  47. # organize copyright file
  48. paste titles2 licenses1 > copyright
  49. cp copyright ..
  50.  
  51. # download mp3s
  52. chmod +x mp3_links2
  53. ./mp3_links2
  54.  
  55. # delete temp files
  56. rm rss rss1 temp_* mp3_links* licenses1 titles*
  57.  
  58. # package into zip file
  59. zip weeklybeats_week$WEEK.zip *
  60. mv weeklybeats_week$WEEK.zip ..
  61.  
  62. # delete temp files
  63. rm rss rss1 temp_* mp3_links* licenses1 titles*
  64.  
  65. # package into zip file
  66. zip weeklybeats_week$WEEK.zip *
  67. mv weeklybeats_week$WEEK.zip ..
  68.  
  69. # delete other stuff
  70. cd ..
  71. rm -rf weeklybeats_download_script
  72.  
  73. ############################################
  74. # The following are the lines that I use to create the torrent file
  75. # and upload it to dropbox to share in the torrent thread. These are
  76. # mainly just here for my personal use. If all you want is to make a
  77. # zip of the current week then just leave these commented.
  78. ############################################
  79.  
  80. # create torrent
  81. #mktorrent -a "udp://tracker.openbittorrent.com:80" weeklybeats_week$WEEK.zip
  82.  
  83. # move files to folders
  84. #cp weeklybeats_week$WEEK.zip.torrent ~/Dropbox/Public/
  85. #mv weeklybeats_week$WEEK.zip ~/torrent/
  86. #mv weeklybeats_week$WEEK.zip.torrent ~/torrent/watch/
  87.  
  88. ############################################
  89. # advance WEEK variable by one for next week
  90. NWEEK=$(($WEEK + 1))
  91. # note- change this to the script's directory
  92. cd /home/dcs/stuff/
  93. sed "5s/"$WEEK"/"$NWEEK"/" weeklybeats.sh > weeklybeats.sh.new
  94. mv weeklybeats.sh.new weeklybeats.sh
  95. chmod +x weeklybeats.sh
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement