document.write("<div class=\"pastie\">\n");
document.write("  <link href=\"http://pastie.org/stylesheets/embed.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n");
document.write("  <link href=\"http://pastie.org/stylesheets/clean.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n");
document.write("  \n");
document.write("\n");
document.write("  \n");
document.write("  \n");
document.write("\n");
document.write("\n");
document.write("\n");
document.write("\n");
document.write("\n");
document.write("\n");
document.write("\n");
document.write("	\n");
document.write("	<div class=\"allcode\">\n");
document.write("		<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n");
document.write("		<tr>\n");
document.write("			<td>\n");
document.write("				\n");
document.write("				<pre class=\"textmate-source-numbers\">1\n");
document.write("2\n");
document.write("3\n");
document.write("4\n");
document.write("5\n");
document.write("6\n");
document.write("7\n");
document.write("8\n");
document.write("9\n");
document.write("10\n");
document.write("11\n");
document.write("12\n");
document.write("13\n");
document.write("14\n");
document.write("15\n");
document.write("16\n");
document.write("17\n");
document.write("18\n");
document.write("19\n");
document.write("20\n");
document.write("21\n");
document.write("22\n");
document.write("23\n");
document.write("24\n");
document.write("25\n");
document.write("26\n");
document.write("27\n");
document.write("28\n");
document.write("29\n");
document.write("30\n");
document.write("31\n");
document.write("32\n");
document.write("33\n");
document.write("34\n");
document.write("35\n");
document.write("36\n");
document.write("37\n");
document.write("38\n");
document.write("39\n");
document.write("40\n");
document.write("41\n");
document.write("42\n");
document.write("43\n");
document.write("44\n");
document.write("45\n");
document.write("46\n");
document.write("47\n");
document.write("48\n");
document.write("49\n");
document.write("50\n");
document.write("51\n");
document.write("52\n");
document.write("<\/pre>\n");
document.write("			<\/td>\n");
document.write("		<td>\n");
document.write("		<pre class=\"textmate-source\"><pre class=\"sunburst\"><span class=\'comment comment_line comment_line_number-sign comment_line_number-sign_ruby\'>#!/bin/bash<\/span>\n");
document.write("<span class=\'comment comment_line comment_line_number-sign comment_line_number-sign_ruby\'># constants &amp; tunings here...<\/span>\n");
document.write("tmp<span class=\'keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby\'>=<\/span><span class=\'string string_regexp string_regexp_classic string_regexp_classic_ruby\'>/<\/span><span class=\'string string_regexp string_regexp_classic string_regexp_classic_ruby\'>tmp<\/span><span class=\'string string_regexp string_regexp_classic string_regexp_classic_ruby\'>/<\/span>tmp<span class=\'variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_pre-defined variable_other_readwrite_global_pre-defined_ruby\'>$$<\/span>\n");
document.write("rchost<span class=\'keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby\'>=<\/span><span class=\'string string_quoted string_quoted_double string_quoted_double_ruby\'>&quot;http://railscasts.com&quot;<\/span> <span class=\'comment comment_line comment_line_number-sign comment_line_number-sign_ruby\'># railscast host<\/span>\n");
document.write("dl_dir<span class=\'keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby\'>=<\/span>$(dirname <span class=\'variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_pre-defined variable_other_readwrite_global_pre-defined_ruby\'>$0<\/span>)<span class=\'keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby\'>/<\/span>movies <span class=\'comment comment_line comment_line_number-sign comment_line_number-sign_ruby\'># directory where movies saved<\/span>\n");
document.write("dl_bandwidth<span class=\'keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby\'>=<\/span><span class=\'constant constant_numeric constant_numeric_ruby\'>60<\/span>          <span class=\'comment comment_line comment_line_number-sign comment_line_number-sign_ruby\'># download limit/s in kilobytes<\/span>\n");
document.write("dl_interval<span class=\'keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby\'>=<\/span><span class=\'constant constant_numeric constant_numeric_ruby\'>2<\/span>            <span class=\'comment comment_line comment_line_number-sign comment_line_number-sign_ruby\'># delay interval between downloads<\/span>\n");
document.write("\n");
document.write("<span class=\'comment comment_line comment_line_number-sign comment_line_number-sign_ruby\'># strip html line to tag uri<\/span>\n");
document.write("function strip(){<span class=\'meta meta_syntax meta_syntax_ruby meta_syntax_ruby_start-block\'><\/span>\n");
document.write("  cat <span class=\'keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby\'>-<\/span> <span class=\'keyword keyword_operator keyword_operator_other keyword_operator_other_ruby\'>|<\/span> sed <span class=\'keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby\'>-<\/span>r <span class=\'string string_quoted string_quoted_single string_quoted_single_ruby\'>\'s#(^.*&quot;\\/)(tags.*)(&quot;.*)#\'<\/span><span class=\'variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_ruby\'>$rchost<\/span><span class=\'string string_quoted string_quoted_single string_quoted_single_ruby\'>\'/\\2#g\'<\/span>\n");
document.write("}\n");
document.write("\n");
document.write("<span class=\'comment comment_line comment_line_number-sign comment_line_number-sign_ruby\'># pull tag categories<\/span>\n");
document.write("curl <span class=\'variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_ruby\'>$rchost<\/span> <span class=\'keyword keyword_operator keyword_operator_other keyword_operator_other_ruby\'>|<\/span> grep <span class=\'keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby\'>-<\/span><span class=\'variable variable_other variable_other_constant variable_other_constant_ruby\'>E<\/span> <span class=\'string string_quoted string_quoted_double string_quoted_double_ruby\'>&quot;<span class=\'constant constant_character constant_character_escape constant_character_escape_ruby\'>\\/<\/span>tag&quot;<\/span> <span class=\'keyword keyword_operator keyword_operator_other keyword_operator_other_ruby\'>|<\/span>\\\n");
document.write("grep <span class=\'string string_quoted string_quoted_double string_quoted_double_ruby\'>&quot;&lt;li&gt;&quot;<\/span>  <span class=\'keyword keyword_operator keyword_operator_other keyword_operator_other_ruby\'>|<\/span> strip           <span class=\'keyword keyword_operator keyword_operator_comparison keyword_operator_comparison_ruby\'>&gt;<\/span> <span class=\'variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_ruby\'>$tmp<\/span><span class=\'keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby\'>-<\/span>pages\n");
document.write("\n");
document.write("<span class=\'comment comment_line comment_line_number-sign comment_line_number-sign_ruby\'># create directory for downloading movies<\/span>\n");
document.write("mkdir <span class=\'keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby\'>-<\/span>p <span class=\'variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_ruby\'>$dl_dir<\/span>\n");
document.write("\n");
document.write("<span class=\'keyword keyword_control keyword_control_ruby\'>while<\/span> [ <span class=\'keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby\'>-<\/span>s <span class=\'variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_ruby\'>$tmp<\/span><span class=\'keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby\'>-<\/span>pages ]\n");
document.write("<span class=\'keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby\'>do<\/span>\n");
document.write("<span class=\'comment comment_line comment_line_number-sign comment_line_number-sign_ruby\'>  # pull uri\'s to: download || turn to next page<\/span>\n");
document.write("  dl_uri<span class=\'keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby\'>=<\/span>$(head <span class=\'keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby\'>-<\/span><span class=\'constant constant_numeric constant_numeric_ruby\'>1<\/span> <span class=\'variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_ruby\'>$tmp<\/span><span class=\'keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby\'>-<\/span>pages)\n");
document.write("  curl <span class=\'variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_ruby\'>$dl_uri<\/span>                    <span class=\'keyword keyword_operator keyword_operator_other keyword_operator_other_ruby\'>|<\/span>\\\n");
document.write("  grep <span class=\'keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby\'>-<\/span><span class=\'variable variable_other variable_other_constant variable_other_constant_ruby\'>E<\/span> <span class=\'string string_quoted string_quoted_double string_quoted_double_ruby\'>&quot;Download|Next Page&quot;<\/span>    <span class=\'keyword keyword_operator keyword_operator_other keyword_operator_other_ruby\'>|<\/span>\\\n");
document.write("  tee <span class=\'variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_ruby\'>$tmp<\/span><span class=\'keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby\'>-<\/span>html                   <span class=\'keyword keyword_operator keyword_operator_other keyword_operator_other_ruby\'>|<\/span>\\\n");
document.write("  grep <span class=\'string string_quoted string_quoted_double string_quoted_double_ruby\'>&quot;Download&quot;<\/span>                 <span class=\'keyword keyword_operator keyword_operator_other keyword_operator_other_ruby\'>|<\/span>\\\n");
document.write("  sed <span class=\'keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby\'>-<\/span>r <span class=\'string string_quoted string_quoted_single string_quoted_single_ruby\'>\'s#(^.*&quot;)(.*)(&quot;.*)#\\2#g\'<\/span> <span class=\'keyword keyword_operator keyword_operator_comparison keyword_operator_comparison_ruby\'>&gt;<\/span> <span class=\'variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_ruby\'>$tmp<\/span><span class=\'keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby\'>-<\/span>movies\n");
document.write("\n");
document.write("<span class=\'comment comment_line comment_line_number-sign comment_line_number-sign_ruby\'>  # download operation is here...<\/span>\n");
document.write("  cat <span class=\'variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_ruby\'>$tmp<\/span><span class=\'keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby\'>-<\/span>movies   <span class=\'keyword keyword_operator keyword_operator_other keyword_operator_other_ruby\'>|<\/span>\\\n");
document.write("  <span class=\'keyword keyword_control keyword_control_ruby\'>while<\/span> read movie_uri\n");
document.write("  <span class=\'keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby\'>do<\/span>\n");
document.write("<span class=\'comment comment_line comment_line_number-sign comment_line_number-sign_ruby\'>    # let\'s use continue mode. operation would <\/span>\n");
document.write("<span class=\'comment comment_line comment_line_number-sign comment_line_number-sign_ruby\'>    # be cheaper if movie is downloaded before.<\/span>\n");
document.write("    wget <span class=\'keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby\'>-<\/span>c <span class=\'keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby\'>-<\/span><span class=\'keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby\'>-<\/span>limit<span class=\'keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby\'>-<\/span>rate<span class=\'keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby\'>=<\/span>${dl_bandwidth}k \\\n");
document.write("         <span class=\'keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby\'>-<\/span><span class=\'variable variable_other variable_other_constant variable_other_constant_ruby\'>O<\/span> <span class=\'variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_ruby\'>$dl_dir<\/span><span class=\'keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby\'>/<\/span>$(basename <span class=\'variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_ruby\'>$movie_uri<\/span>) <span class=\'variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_ruby\'>$movie_uri<\/span> \n");
document.write("    sleep <span class=\'variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_ruby\'>$dl_interval<\/span>\n");
document.write("  done\n");
document.write("\n");
document.write("<span class=\'comment comment_line comment_line_number-sign comment_line_number-sign_ruby\'>  # remove downloaded uri <\/span>\n");
document.write("  sed <span class=\'string string_quoted string_quoted_single string_quoted_single_ruby\'>\'1d\'<\/span> <span class=\'variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_ruby\'>$tmp<\/span><span class=\'keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby\'>-<\/span>pages <span class=\'keyword keyword_operator keyword_operator_comparison keyword_operator_comparison_ruby\'>&gt;<\/span> <span class=\'variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_ruby\'>$tmp<\/span><span class=\'keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby\'>-<\/span>tmp\n");
document.write("  mv <span class=\'variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_ruby\'>$tmp<\/span><span class=\'keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby\'>-<\/span>tmp <span class=\'variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_ruby\'>$tmp<\/span><span class=\'keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby\'>-<\/span>pages\n");
document.write("\n");
document.write("<span class=\'comment comment_line comment_line_number-sign comment_line_number-sign_ruby\'>  # add onto $tmp-pages if &quot;Next Page&quot; was shown.<\/span>\n");
document.write("  grep <span class=\'string string_quoted string_quoted_double string_quoted_double_ruby\'>&quot;Next Page&quot;<\/span> <span class=\'variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_ruby\'>$tmp<\/span><span class=\'keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby\'>-<\/span>html <span class=\'keyword keyword_operator keyword_operator_other keyword_operator_other_ruby\'>|<\/span> strip <span class=\'keyword keyword_operator keyword_operator_other keyword_operator_other_ruby\'>&gt;&gt;<\/span> <span class=\'variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_ruby\'>$tmp<\/span><span class=\'keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby\'>-<\/span>pages\n");
document.write("done\n");
document.write("<span class=\'comment comment_line comment_line_number-sign comment_line_number-sign_ruby\'># Happy ride on Rails ;)<\/span>\n");
document.write("\n");
document.write("rm <span class=\'variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_ruby\'>$tmp<\/span><span class=\'keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby\'>-<\/span><span class=\'keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby\'>*<\/span>\n");
document.write("exit <span class=\'constant constant_numeric constant_numeric_ruby\'>0<\/span>\n");
document.write("<\/pre><\/pre>\n");
document.write("		<\/td>\n");
document.write("		<\/tr>\n");
document.write("		<\/table>\n");
document.write("	\n");
document.write("	<\/div>\n");
document.write("\n");
document.write("\n");
document.write("  \n");
document.write("  \n");
document.write("  <div class=\"credit\">\n");
document.write("    <div class=\"buttons\">\n");
document.write("      <a href=\"http://pastie.org/pastes/663647.txt\">\n");
document.write("      <img src=\"http://pastie.org/images/view.png\" height=\"20\" width=\"67\" /><\/a>\n");
document.write("    <\/div>\n");
document.write("  \n");
document.write("    <a href=\"http://pastie.org/663647\">Pastie #663647<\/a> linked directly from <a href=\"http://pastie.org/\">Pastie<\/a>.\n");
document.write("  <\/div><\/div>");
