github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

battur / dirty_little_hacks

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 1
    • 1
  • Source
  • Commits
  • Network (1)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Dirty little hacks, performance boost scripts — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

License => License 
battur (author)
Sat Feb 06 20:41:23 -0800 2010
commit  02b58974c2b03eaeffb2c3fb376b86c472c7dc70
tree    bb96edb5324f9a51a94e5edd6378937f1f9041df
parent  f688c0d319e76601d1637ad4fc8b9ad6ebca6aa5
dirty_little_hacks / railscast_video_downloader.sh railscast_video_downloader.sh
100755 68 lines (51 sloc) 2.122 kb
edit raw blame history
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
#*****************************************************************************#
# Description: RailsCast Video Downloader. Useful for offline learners. #
# Author: Battur Sanchin: { mail: batturjapan@gmail.com, #
# blog: http://battur.blogspot.com } #
# Date: 2009.10.20 #
# License: Free Software. #
# #
#*****************************************************************************#
 
# constants & tunings here...
tmp=/tmp/tmp$$
rchost="http://railscasts.com" # railscast host
dl_dir=$(dirname $0)/movies # directory where movies saved
dl_bandwidth=60 # download limit/s in kilobytes
dl_interval=2 # delay interval between downloads
 
# strip html line to tag uri
function strip(){
  cat - | sed -r 's#(^.*"\/)(tags.*)(".*)#'$rchost'/\2#g'
}
 
 
# we need get newest podcast each time we start this shell
curl $rchost > $tmp-pages
 
# pull tag categories
curl $rchost | grep -E "\/tag" | grep "<li>" | strip >> $tmp-pages
 
# create directory for downloading movies
mkdir -p $dl_dir
 
 
while [ -s $tmp-pages ]
do
 
  # pull uri's to: download || turn to next page
  dl_uri=$(head -1 $tmp-pages)
  curl $dl_uri |\
  grep -E "Download|Next Page" |\
  tee $tmp-html |\
  grep "Download" |\
  sed -r 's#(^.*")(.*)(".*)#\2#g' > $tmp-movies
 
 
  # download operation is here...
  cat $tmp-movies |\
  while read movie_uri
  do
    # let's use continue mode. operation would be cheaper if movie is downloaded before.
    wget -c --limit-rate=${dl_bandwidth}k -O $dl_dir/$(basename $movie_uri) $movie_uri
    sleep $dl_interval
  done
 
 
  # remove downloaded uri
  sed '1d' $tmp-pages > $tmp-tmp
  mv $tmp-tmp $tmp-pages
 
  # add onto $tmp-pages if "Next Page" was shown.
  grep "Next Page" $tmp-html | strip >> $tmp-pages
 
done
# Happy ride on Rails ;)
 
rm $tmp-*
exit 0
 
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server