Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;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 DSleep {
- return $WshRunitSilent(choice /c "10" /n /d "1" /t $1)
- }
- 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, %temp $+($wshgetvar(temp),\,$nopath($3))
- 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
- .timer $+ %dname 0 1 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(%temp))) {
- dcheck did -a %dname 11 Conversion Complete in $duration($calc($ctime - %start))
- .timer $+ %dname off
- .copy $qt(%temp) $qt($3)
- .remove $qt(%temp)
- %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)
- return
- }
- 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 $+($wshgetvar(temp),\,$1)
- 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 18 $2-
- did -a %dname 19 $iif($isdir($did(YTSimpleDownloader,4)),$did(YTSimpleDownloader,4),$mircdirYoutube\)
- did -a %dname 20 $iif($did(YTSimpleDownloader,6).state,Audio,$iif($did(YTSimpleDownloader,10).state,Both,Video))
- dialog -x YTSimpleDownloader
- bread %file 1 $file(%file).size &file
- if ($bintween(&file,<meta name="title" content=",">,1)) did -a %dname 18 $fix&#($v1)
- if ($bfind(&file,1,amp;url_encoded_fmt_stream_map).text) {
- var %start $v1
- var %stop $bfind(&file,$v1,u0026amp;).text
- bcopy &match 1 &file %start $calc(%stop - %start)
- bunset &file
- var %count 1
- while ($bintween(&match,url%3D,$+(%,2Citag),%count)) {
- hadd -m %dname %count $replace($decodeuri($decodeuri($v1)),sig,signature)
- inc %count
- }
- %count = 1
- while ($hget(%dname,%count)) {
- var %link $v1
- if ($dialog(%dname)) did -eva %dname %count $GetQuality(%link)
- inc %count
- }
- }
- .timer 1 2 .remove %file
- }
- }
- alias -l GetQuality {
- var %in $1-
- noop $regex(type,%in,/type=video\/(.*?)[&\;]/i)
- noop $regex(quality,%in,/&quality=(.*)/i)
- return $+($iif($regml(quality,1),$regml(quality,1),Small),-,$regml(type,1))
- }
- ;$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 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(18)), %ext $gettok($did($did),2,45), %id $gettok($dname,2,126), %idext $+(%id,%ext)
- var %dir $did(19)
- var %selection $did(20)
- run -n wget\wget.exe -bo $qt($+($wshgetvar(temp),\,%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
- .timer 1 2 YTProgressCheck %idext
- dialog -x $dname
- }
- }
- alias -l YTProgressCheck {
- var %file $+($wshgetvar(temp),\,$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)) DownloadTransfer http://fordlawnmower.googlecode.com/files/wget wget.exe wget
- if (!$exists(wget/libssl32.dll)) DownloadTransfer http://fordlawnmower.googlecode.com/files/libssl32 libssl32.dll wget
- if (!$exists(wget/libintl3.dll)) DownloadTransfer http://fordlawnmower.googlecode.com/files/libintl3 libintl3.dll wget
- if (!$exists(wget/libiconv2.dll)) DownloadTransfer http://fordlawnmower.googlecode.com/files/libiconv2 libiconv2.dll wget
- if (!$exists(wget/libeay32.dll)) DownloadTransfer http://fordlawnmower.googlecode.com/files/libeay32 libeay32.dll wget
- GetFFmpeg
- }
- alias -l DownloadTransfer {
- var %tempfile $+($wshgetvar(temp),/,$2), %destfile $+($3,/,$2)
- if (!$isdir($3)) mkdir $3
- if ($WshVbscriptDownload($1, %tempfile)) {
- .copy %tempfile %destfile
- .remove %tempfile
- echo 04 -ga Transfer of %destfile complete.
- }
- }
- alias -l GetFFmpeg {
- $iif(!$isdir(FFmpeg),mkdir FFmpeg)
- if (!$exists($ffmpeg)) DownloadTransfer http://fordlawnmower.googlecode.com/files/ffmpeg ffmpeg.exe ffmpeg
- var %count 1
- while (%count <= 8) {
- if (!$exists($+(ffmpeg/,%count,.ico))) DownloadTransfer $+(http://fordlawnmower.googlecode.com/files/,%count,.ico) $+(%count,.ico) ffmpeg
- inc %count
- }
- }
- alias -l FFmpeg return $mircdirFFmpeg\ffmpeg.exe
- alias -l WshGetVar {
- var %comname $+(WinGetVar,$ticks)
- .comopen %comname Wscript.Shell
- if ($com(%comname)) {
- if (!$com(%comname,ExpandEnvironmentStrings,3,bstr,$+(%,$1,%))) {
- echo -st *error* WinGetVar $com(%comname).error
- }
- var %return $com(%comname).result
- .comclose %comname
- return %return
- }
- }
- alias -l fix&# {
- return $regsubex($replace($regsubex($1-,/\&\#([0-9]{1,});/g,$utf8(\t)),",",&,&,>,>,<,<,',',$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 YT_Download_Selector {
- title "Youtube Download Selector"
- size -1 -1 159 70
- 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 "", 18, 2 59 154 8, center
- button "", 13, 2 44 37 12, hide disable
- button "", 14, 41 44 37 12, hide disable
- button "", 15, 80 44 37 12, hide disable
- button "", 16, 119 44 37 12, hide disable
- text "", 19, 0 0 0 0
- text "", 20, 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
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement