tglogo.png

Downloading File

Filename: Simple Youtube Downloader
;Youtube Simple Downloader by Ford_Lawnmower irc.abjects.net #mIRC
menu channel,status,menubar {
  Youtube Simple Downloader: dialog $iif(!$dialog(YTSimpleDownloader),-m YTSimpleDownloader,-v) YTSimpleDownloader
}
alias -l WshRunitSilent {
  var %comname $+(WshRunSilent,$ticks)
  .comopen %comname WScript.Shell
  if ($com(%comname)) {
    if (!$com(%comname,run,3,bstr,$1-,uint,0,string,true)) {
      echo -st *error* WshRunSilent $com(%comname).error
      var %return 0
    }
    else var %return 1
    .comclose %comname
    return %return
  }
}
;VideoToAudio ffmpeg.exeDirectory;infile;outfile;cleanup command here
alias -l VideoToAudio {
  tokenize 59 $1-
  var %start $ctime, %dname $replace($+(YTVideoToAudio,$mkfn($3)),$chr(32),_), %cleanup $4
  var %quality $input(Please select an audio quality,omr,Quality Settings Needed,160,64,128,160,192,224,256,320)
  if (%quality) {
    dialog $iif($dialog(%dname),-v,-md) %dname YTVideoToAudio
    dcheck did -a %dname 8 $nopath($2) 
    dcheck did -a %dname 9 $nopath($3)
    dcheck did -a %dname 11 Conversion in progress......
    ShowProgress %dname
    if ($exists($qt($3))) .remove $qt($3) 
    if ($WshRunitSilent($1 -i $qt($2) -vn -ar 44100 -ac 2 -ab $+(%quality,k) -f mp3 $qt($3))) {
      dcheck did -a %dname 11 Conversion Complete in $duration($calc($ctime - %start))
      .timer $+ %dname off
      %cleanup
    }
    else dcheck did -a %dname Conversion Failed!
  }
}
alias -l ShowProgress {
  var %count $iif($calc($gettok($nopath($did($1,1)),1,46) + 1) > 8,1,$calc($gettok($nopath($did($1,1)),1,46) + 1))
  dcheck did -g $1 1-7 $+(FFmpeg\,%count,.ico)
  .timer $+ $1 -m 1 250 ShowProgress $1
}
alias -l GetCount {
  echo -a getcount $iif($calc($gettok($nopath($did($1,1)),1,46) + 1) > 8,1,$calc($gettok($nopath($did($1,1)),1,46) + 1))
  return $iif($calc($gettok($nopath($did($1,1)),1,46) + 1) > 8,1,$calc($gettok($nopath($did($1,1)),1,46) + 1))
}
alias -l dcheck {
  if ($dialog($3)) $1-
}
dialog -l YTVideoToAudio {
  title "Video to Audio Conversion"
  size -1 -1 132 56
  option dbu
  icon 1, 2 24 17 19
  icon 2, 20 24 17 19
  icon 3, 38 24 17 19
  icon 4, 56 24 17 19
  icon 5, 74 24 17 19
  icon 6, 92 24 17 19
  icon 7, 110 24 17 19
  text "", 8, 0 1 132 8, center
  text "", 9, -2 16 134 8, center
  text "TO", 10, 51 8 25 8, center
  text "", 11, 0 46 132 8, center
  text "", 12, 0 0 0 0
}
dialog -l YTSimpleDownloader {
  title "Youtube Downloader"
  size -1 -1 202 51
  option dbu
  text "Link:", 1, 0 4 25 8, right
  text "Save to:", 2, 0 15 25 8, right
  edit "", 3, 26 3 175 10
  edit "", 4, 26 14 151 10
  button "Browse", 5, 179 14 22 10
  radio "Audio Only", 6, 8 38 42 10
  radio "Video Only", 7, 54 38 38 10
  button "Download", 8, 163 37 37 12
  text "", 9, 0 27 201 8
  radio "Both", 10, 97 38 31 10
}
on *:dialog:YTSimpleDownloader:Sclick:5,8: {
  getwget
  if ($did == 5) did -ra $dname 4 $sdir($mircdir,Select a Directory)
  else {
    tokenize 32 $did(3) $did(4) $iif($did(6).state,Audio,$iif($did(8).state,Both,Video)) $did(4)
    if ($regex($1,/.*youtube\.com\/watch\?v=[\S]{11}/Si)) { 
      YTGetDownloadLinks $left($gettok($1,2,61),11) $left($gettok($1,2,61),11)
    }
  }
}
;Link select and download starts here.
alias -l YTGetDownloadLinks {
  var %file $+(temp\,$1)
  if (!$isdir(temp)) mkdir temp
  if ($WshVbscriptDownload($+(http://www.youtube.com/watch?v=,$1),%file)) {
    var %dname $+(YT_GetDownloadLinks,~,$1)
    dialog $iif($dialog(%dname),-v,-m) %dname YT_Download_Selector
    did -a %dname 13 $2- 
    did -a %dname 14 $iif($isdir($did(YTSimpleDownloader,4)),$did(YTSimpleDownloader,4),$mircdirYoutube\)
    did -a %dname 15 $iif($did(YTSimpleDownloader,6).state,Audio,$iif($did(YTSimpleDownloader,10).state,Both,Video))
    dialog -x YTSimpleDownloader
    bread %file 1 $file(%file).size &file
    if ($bfind(&file,1,url_encoded_fmt_stream_map).text) {
      if ($bintween(&file,<meta name="title" content=",">,1)) did -a %dname 13 $fix&#($v1)
      var %count 1
      while ($bintween(&file,url%3D,$+(%,26itag),%count)) {
        hadd -m %dname %count $gettok($decodeuri($decodeuri($v1)),1,59)
        inc %count
      }
      %count = 1
      while ($hget(%dname,%count)) {
        var %link $v1
        if ($dialog(%dname)) did -eva %dname %count $GetQuality(%link)
        inc %count
      }
    }
    .remove %file 
  }
}
alias -l GetQuality {
  var %in $1-
  noop $regex(%in,/quality=(.*?)&/i)
  return $+($iif($regml(1),$regml(1),Small),-,$gettok($gettok(%in,-1,47),-1,45))
}
;$bintween by Ford_Lawnmower Syntax = $bintween(&binvar,starttext,endtext,matchnum)
alias -l bintween {
  var %count = 1, %mark = 0, %mark2 = 0
  while (%count <= $4) {
    if ($bfind($1, %mark2, $2).text) {
      %mark = $calc($bfind($1, %mark2, $2).text + $len($2))
      if ($bfind($1, %mark, $3).text) {
        %mark2 = $bfind($1, %mark, $3).text
      }
      else { return 0 } 
    }
    else { return 0 }
    inc %count
  }
  return $bvar($1, $iif(%mark > 0,%mark,1), $calc(%mark2 - %mark)).text
}
alias -l DecodeUri return $regsubex($1-,/\%([0-9a-f]{2})/gi,$chr($base(\t,16,10)))
alias -l WshVbscriptDownload {
  var %comname $+(WshVbscriptDownload,$ticks,$r(1,1000))
  .comopen %comname MSScriptControl.ScriptControl
  if ($com(%comname)) {
    var %Success $com(%comname,language,4,string,vbscript)
    inc %Success $Execute(%comname,Set MicrosoftXmlhttp = CreateObject("Microsoft.Xmlhttp"))
    inc %Success $Execute(%comname,$+(MicrosoftXmlhttp.Open "GET",$chr(44),$qt($1),$chr(44),False))
    inc %Success $Execute(%comname,MicrosoftXmlhttp.Send)
    if ($evaluate(%comname,MicrosoftXmlhttp.Status)) {
      inc %Success $Execute(%comname,set AdodbStream = CreateObject("Adodb.Stream"))
      inc %Success $Execute(%comname,AdodbStream.type = 1)
      inc %Success $Execute(%comname,AdodbStream.open)
      inc %Success $Execute(%comname,AdodbStream.write MicrosoftXmlhttp.responseBody)
      ;$iif(!$isid,echo 04 -sat Downloading $1 $bytes($evaluate(%comname,AdodbStream.Size)).suf)
      inc %Success $Execute(%comname,AdodbStream.savetofile $+($qt($2),$chr(44),2))
      inc %Success $Execute(%comname,AdodbStream.close)
      if (%Success != 10) echo -st *error* WshVbscriptDownload Download Failed!
      else {
        $iif(!$isid,echo 09 -sat Download $1 Complete)
        var %return 1
      }
    }
    .comclose %comname
    return %return
  }
}
alias -l WshVbscriptSleep {
  var %comname $+(WshVbscriptSleep,$ticks,$r(1,1000))
  .comopen %comname MSScriptControl.ScriptControl
  if ($com(%comname)) {
    var %Success $com(%comname,language,4,string,vbscript)
    inc %Success $Execute(%comname,Dim Sleepstart $chr(44) Sleepend)
    inc %Success $Execute(%comname,Sleepstart = Time())
    inc %Success $Execute(%comname,Sleepend = DateAdd("s" $chr(44) $1 $chr(44) Sleepstart))
    inc %Success $Execute(%comname,While Sleepend >= Time() $crlf Wend)
    if (%Success == 5) var %return 1
  }
  .comclose %comname
  return %return
}
alias -l Execute return $com($1,executestatement,3,bstr,$2-)
alias -l Evaluate {
  noop $com($1,eval,3,bstr,$2-)
  return $com($1).result
}
On *:start: {
  if (!$exists(wget\wget.exe)) getwget
}
On *:dialog:YT_GetDownloadLinks~*:close:*: if ($hget($dname)) hfree $dname
On *:dialog:YT_GetDownloadLinks~*:Sclick:1-12: {
  $iif(!$isdir(Youtube),mkdir Youtube)
  $iif(!$isdir(wget),mkdir wget)
  if ((!$exists(wget\wget.exe)) || (!$exists($ffmpeg)))  {
    echo -gat I am missing some of the files needed to download your video.
    echo -gat Please try your download after I gather the missing files.
    getwget
  }
  else {
    var %fn $mkfn($did(13)), %ext $gettok($did($did),2,45), %id $gettok($dname,2,126), %idext $+(%id,%ext)
    var %dir $did(14)
    var %selection $did(15)
    run -n wget\wget.exe -bo $qt($+($mircdir,wget\,%id,%ext)) -O $qt($+(%dir,%fn,.,%ext)) $hget($dname,$did)
    dialog $iif($dialog(%idext),-v,-md) %idext YTDownloadProgress
    did -a %idext 1 %fn
    did -a %idext 10 %selection
    did -a %idext 11 %dir
    did -a %idext 12 %ext
    YTProgressCheck %idext
    dialog -x $dname
  }
}
alias -l YTProgressCheck {
  var %file $+(wget\,$1), %dname $1, %data $remove($read(%file,$calc($lines(%file) - 1)),..)
  if ($dialog(%dname)) {
    tokenize 32 %data
    if (!$5) {
      did -a %dname 2 $bytes($calc($remove($1,k) * 1000)).suf
      did -a %dname 3 $2
      did -a %dname 4 $3
      did -a %dname 5 $4
      .timer $+ %dname 1 1 YTProgressCheck %dname
    }
    else {
      did -a %dname 2,3,5 Complete
      did -a %dname 4 $3-4
      .remove $qt(%file)
      if ($did(%dname,10) != Video) {
        var %sel $did(%dname,10), %dir $did(%dname,11), %ext $did(%dname,12), %fn $did(%dname,1)
        var %command $iif($did(%dname,10) == Audio,.remove $qt($+(%dir,%fn,.,%ext)))
        var %fn2 $iif($exists($qt($+(%dir,$did(%dname,1),.mp3))), $input($did(%dname,1) already exists.$&
        $crlf Please enter a new file name.,eoq,FileName Conflict,$did(%dname,1),),$did(%dname,1))
        if (%fn) VideoToAudio $+($qt($ffmpeg),;,$qt($+(%dir,%fn,.,%ext)),;,$qt($+(%dir,%fn2,.,mp3)),;,%command)
      }
      dialog -x %dname
    }
  }
}
alias -l GetWget {
  if (!$isdir(wget)) {
    if ($input(You must download some files to continue. $crlf Dowload them now ?,yq,Youtube Simple DownloaderMissing Files,,)) {
      mkdir wget
    }
    else halt
  }
  if (!$exists(wget/wget.exe)) WshVbscriptDownload http://fordlawnmower.googlecode.com/files/wget wget/wget.exe
  if (!$exists(wget/libssl32.dll)) WshVbscriptDownload http://fordlawnmower.googlecode.com/files/libssl32 wget/libssl32.dll
  if (!$exists(wget/libintl3.dll)) WshVbscriptDownload http://fordlawnmower.googlecode.com/files/libintl3 wget/libintl3.dll
  if (!$exists(wget/libiconv2.dll)) WshVbscriptDownload http://fordlawnmower.googlecode.com/files/libiconv2 wget/libiconv2.dll
  if (!$exists(wget/libeay32.dll)) WshVbscriptDownload http://fordlawnmower.googlecode.com/files/libeay32 wget/libeay32.dll
  GetFFmpeg
}
alias -l GetFFmpeg {
  $iif(!$isdir(FFmpeg),mkdir FFmpeg)
  if (!$exists($ffmpeg)) WshVbscriptDownload http://fordlawnmower.googlecode.com/files/ffmpeg ffmpeg/ffmpeg.exe
  var %count 1
  while (%count <= 8) {
    if (!$exists($+(ffmpeg/,%count,.ico))) WshVbscriptDownload $+(http://fordlawnmower.googlecode.com/files/,%count,.ico) $+(ffmpeg/,%count,.ico)
    inc %count
  }
}
alias -l FFmpeg return $mircdirFFmpeg\ffmpeg.exe
alias -l fix&# { 
  return $regsubex($replace($regsubex($1-,/\&\#([0-9]{1,});/g,$utf8(\t)),&quot;,",&amp;,&,&gt;,>,&lt;,<,&#39;,',$chr(9),$chr(32)),$&
    /([$\|%\[\]\}\{][^\s]*)/g,$+($chr(2),$chr(2),\t))
}
alias -l UTF8 {
  if ($version >= 7) return $chr($1)
  elseif ($1 < 255) { return $chr($1) }
  elseif ($1 >= 256) && ($1 < 2048) { return $+($chr($calc(192 + $div($1,64))),$chr($calc(128 + $mod($1,64)))) }
  elseif ($1 >= 2048) && ($1 < 65536) { return $+($chr($calc(224 + $div($1,4096))),$chr($calc(128 + $mod($div($1,64),64))),$chr($calc(128 + $mod($1,64)))) }
  elseif ($1 >= 65536) && ($1 < 2097152) {
    return $+($chr($calc(240 + $div($1,262144))),$chr($calc(128 + $mod($div($1,4096),64))),$chr($calc(128 + $mod($div($1,64),64))),$&
      $chr($calc(128 + $mod($1,64))))
  }
}
alias -l div { return $int($calc($1 / $2)) }
alias -l mod {
  var %int $int($calc($1 / $2))
  return $calc($1 - (%int * $2))
}
alias -l H2U { return $utf8($base($1,16,10)) }
dialog -l YT_Download_Selector {
  title "Youtube Download Selector"
  size -1 -1 159 57
  option dbu
  button "", 1, 2 4 37 12, hide disable
  button "", 2, 41 4 37 12, hide disable
  button "", 3, 80 4 37 12, hide disable
  button "", 4, 119 4 37 12, hide disable
  button "", 5, 2 17 37 12, hide disable
  button "", 6, 41 17 37 12, hide disable
  button "", 7, 80 17 37 12, hide disable
  button "", 8, 119 17 37 12, hide disable
  button "", 9, 2 30 37 12, hide disable
  button "", 10, 41 30 37 12, hide disable
  button "", 11, 80 30 37 12, hide disable
  button "", 12, 119 30 37 12, hide disable
  text "", 13, 3 46 154 8, center
  text "", 14, 0 0 0 0
  text "", 15, 0 0 0 0
}
dialog -l YTDownloadProgress {
  title "Youtube Downloads"
  size -1 -1 98 54
  option dbu
  text "", 1, 1 2 96 8, center
  text "", 2, 37 15 58 8
  text "", 3, 37 24 59 8
  text "", 4, 37 33 59 8
  text "", 5, 37 42 59 8
  text "Size:", 6, 2 15 32 8, right
  text "Complete:", 7, 2 24 32 8, right
  text "Speed:", 8, 2 33 32 8, right
  text "Remaining:", 9, 2 42 32 8, right
  text "", 10, 1 10 0 6, center
  text "", 11, 1 10 0 6, center
  text "", 12, 1 10 0 6, center
}


Related Files

by Soul_Eater
by Junaid

Please note that on our website we use cookies necessary for the functioning of our website, cookies that optimize the performance. To learn more about our cookies, how we use them and their benefits, please read our Cookie Policy.
I Understand