Last active
April 7, 2016 13:59
-
-
Save ralphcrisostomo/a95d75f37023a7d8038d to your computer and use it in GitHub Desktop.
for lazy people that wanted to download tutorials from tutsplus.com automatically
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Created by : Ralph Crisostomo | |
# 14FEB2016 | |
# | |
# Instead of clicking and downloading one by one | |
# Paste the code below to your chrome console | |
# to generate bash command for you to copy and paste | |
# to your terminal. | |
# | |
# Paste the code below to your chrome console : | |
# You should be at the initial course page | |
# | |
# (function(){var n,e,t,o,r,l,s;for(r="",e=[],l=[],n="",s=t=0;30>=t;s=++t)n+="-";o=function(){var t,i,c,u;return 0!==e.length?(t=e[0],c=$("<iframe>",{src:t.url}).appendTo("body"),s=0,i=setInterval(function(){var n,r;return(null!=(n=c.contents().find("source"))?n.attr("src"):void 0)&&(clearInterval(i),t.title=t.title.replace(":"," -"),console.log(t.title),l.push({name:t.title,url:null!=(r=c.contents().find("source"))?r.attr("src"):void 0}),setTimeout(function(){return c.remove(),e.shift()},100),setTimeout(function(){return o()},200)),s++},300)):(u=n+"\n",u+="Paste code below: \n",u+=n+"\n",u+="# \n",u+="# "+r+"\n",u+="# \n",u+='sudo mkdir "'+r+'"\n',u+='cd "'+r+'"\n',l.forEach(function(n){return u+='sudo curl -C - -o "'+n.name+'.mp4" '+n.url+"\n"}),u+="cd ../ \n",u+='echo "'+n+'"\n',u+='echo "'+r+'"\n',u+='echo "'+n+'"\n',u+='ls -al "'+r+'"\n',u+='echo "'+n+'"\n',console.log(u))},$(".lesson-index__lesson .lesson-index__lesson-link").each(function(){var n,t,o;return r=$("title").text(),o=$(this).attr("href"),n=$(this).find(".lesson-index__lesson-number").text(),t=$(this).find(".lesson-index__lesson-title").text(),e.push({url:o,title:n+" "+t})}),o()}).call(this); | |
title = "" | |
frames = [] | |
videos = [] | |
border = "" | |
for x in [0..30] | |
border += "-" | |
loadFrame = -> | |
if frames.length isnt 0 | |
frame = frames[0] | |
iframe = $('<iframe>', { src : frame.url }).appendTo('body') | |
x = 0 | |
i = setInterval ( -> | |
if iframe.contents().find('source')?.attr('src') | |
clearInterval i | |
frame.title = frame.title.replace(':',' -') | |
console.log frame.title | |
videos.push | |
name : frame.title | |
url : iframe.contents().find('source')?.attr('src') | |
setTimeout -> | |
iframe.remove() | |
frames.shift() | |
, 100 | |
setTimeout -> | |
loadFrame() | |
, 200 | |
x++ | |
), 300 | |
else | |
message = "#{border}\n" | |
message += "Paste code below: \n" | |
message += "#{border}\n" | |
message += "# \n" | |
message += "# #{title}\n" | |
message += "# \n" | |
message += "sudo mkdir \"#{title}\"\n" | |
message += "cd \"#{title}\"\n" | |
videos.forEach (item) -> | |
message += "sudo curl -C - -o \"#{item.name}.mp4\" #{item.url}\n" | |
message += "cd ../ \n" | |
message += "echo \"#{border}\"\n" | |
message += "echo \"#{title}\"\n" | |
message += "echo \"#{border}\"\n" | |
message += "ls -al \"#{title}\"\n" | |
message += "echo \"#{border}\"\n" | |
console.log message | |
$('.lesson-index__lesson .lesson-index__lesson-link').each -> | |
title = $('title').text() | |
_url = $(@).attr('href') | |
_number = $(@).find('.lesson-index__lesson-number').text() | |
_title = $(@).find('.lesson-index__lesson-title').text() | |
frames.push | |
url : _url | |
title : "#{_number} #{_title}" | |
loadFrame() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment