Downloads songs from SoundCloud.com
;SoundCloud Search and Download by Ford_Lawnmower irc.abjects.net #mIRC
menu channel,status,menubar {
.SoundCloud: {
getwget
dialog $iif($dialog(SoundcloudSearch),-v,-md SoundcloudSearch) SoundcloudSearch
}
}
alias SoundCloudDownloadInfo { GetSoundCloudDownloadInfo echo -a $1- }
alias -l GetSoundCloudDownloadInfo {
var %sockname $+(GetSoundCloudDownloadInfo,$network,$2,$ticks), %dir $sdir($mircdir,Destination Directory needed.)
sockopen %sockname soundcloud.com 80
sockmark %sockname $1-2 $+($3) %dir
}
On *:sockopen:GetSoundCloudDownloadInfo*: {
if (!$sockerr) {
sockwrite -nt $sockname GET $gettok($sock($sockname).mark,3,32) HTTP/1.0
sockwrite -n $sockname Host: soundcloud.com
sockwrite -n $sockname $crlf
}
else { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
}
On *:sockread:GetSoundCloudDownloadInfo*: {
if ($sockerr) { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
else {
var %GetSoundCloudDownloadInfo | sockread %GetSoundCloudDownloadInfo
if ($regex(title,%GetSoundCloudDownloadInfo,/"title":"(.*?)"/i) && $regex(link,%GetSoundCloudDownloadInfo,/"streamUrl":"(.*?)"/i)) {
var %id $+(SoundCloudProgress,$ticks),%fn $+($mkfn($fixchars($regml(title,1))),.mp3)
run -np $qt($mircdirwget\wget.exe) -bo $qt($+($wshgetvar(temp),\,%id)) -O $qt($+($gettok($sock($sockname).mark,4-,32),%fn)) $regml(link,1)
sockclose $sockname
dialog $iif($dialog(%id),-v,-md) %id SoundcloudDownloadProgress
dcheck did -a %id 1 %fn
.timer 1 2 SoundcloudProgressCheck %id
}
}
}
alias -l SoundCloudSearch {
GetSoundCloudSearch echo -a $+(/search?page=,$iif($($+($,$0),2) isnum,$v1,1),$&
&q%5Bfulltext%5D=,$urlencode($gettok($1-,$+(1-,$calc($0 - $iif($($+($,$0),2) isnum,1,0))),32)))
}
alias -l GetSoundCloudSearch {
var %sockname $+(GetSoundCloudSearch,$network,$2,$ticks)
sockopen %sockname soundcloud.com 80
sockmark %sockname $1-2 $3
}
On *:sockopen:GetSoundCloudSearch*: {
if (!$sockerr) {
sockwrite -nt $sockname GET $gettok($sock($sockname).mark,3,32) HTTP/1.0
sockwrite -n $sockname Host: soundcloud.com
sockwrite -n $sockname $crlf
}
else { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
}
On *:sockread:GetSoundCloudSearch*: {
if ($sockerr) { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
else {
var %GetSoundCloudSearch | sockread %GetSoundCloudSearch
if (we couldn't find any tracks isin %GetSoundCloudSearch) {
echo -gat No results for your search!
sockclose $sockname
}
elseif ($regex(%GetSoundCloudSearch,/info-header"><h3><a href="(.*?)">(.*?)<\/a>/i)) {
if (empty-set isin %GetSoundCloudSearch) dcheck did -a SoundCloudSearch 4,24 n/a (no files)
dcheck did -a SoundcloudSearch 5 $regml(1)
dcheck did -a SoundCloudSearch 1 $fixchars($regml(2))
}
elseif ($regex(%GetSoundCloudSearch,/<h3><a href="(.*?)">(.*?)<\/a>/i)) {
dcheck did -a SoundcloudSearch 5 $gettok($regml(1),1,34)
dcheck did -a SoundCloudSearch 1 $fixchars($regml(2))
}
elseif ($regex(%GetSoundCloudSearch,/user-name">(.*?)<\/a>/i)) dcheck did -a SoundcloudSearch 2 $regml(1)
elseif ($regex(%GetSoundCloudSearch,/date'>(.*?)<\/abbr>/i)) dcheck did -a SoundcloudSearch 3 $regml(1)
elseif ($regex(%GetSoundCloudSearch,/duration"\stitle=".*?">(.*?)</i)) dcheck did -a SoundcloudSearch 24 $regml(1)
elseif ($regex(%GetSoundCloudSearch,/Plays">(.*?)<)) dcheck did -a SoundcloudSearch 4 $iif($regml(1),$regml(1),1)
elseif ($regex(%GetSoundCloudSearch,/"next">Next<\/a>/i)) dcheck did -e SoundcloudSearch 13
}
}
alias -l dcheck {
if ($dialog($3)) $1-
}
alias -l fixchars {
return $replace($regsubex($1-,/\\u([0-9a-f]{4})/gi,$chr($base(\t,16,10))),&,&,",",>,>,<,<)
}
alias -l urlencode {
return $replace($regsubex($iif($version < 7, $utfencode($1-),$1),/([^a-z0-9\s])/ig,% $+ $base($asc(\t),10,16,2)),$chr(32),+)
}
On *:dialog:SoundcloudSearch:Sclick:*: {
if ($did == 7 && $did(16)) {
var %search $v1
if (http://soundcloud.com* iswm %search) {
SoundCloudDownloadInfo $+(/,$gettok(%search,3-,47))
}
else {
did -r $dname 1-6,18-24
did -b $dname 13,26
did -a $dname 6 1
SoundcloudSearch %search
}
}
elseif ($did == 13 && $did(16)) {
did -r $dname 1-5,18-24
did -b $dname 13
did -e $dname 26
did -a $dname 6 $calc($did(6) + 1)
SoundcloudSearch $v1 $did(6)
}
elseif ($did == 26 && $did(16)) {
if ($did(6) > 1) {
did -r $dname 1-5,18-24
did -a $dname 6 $calc($did(6) - 1)
if ($did(6) == 1) did -b $dname 26
SoundcloudSearch $did(16) $did(6)
}
else did -b $dname 26
}
elseif ($did == 14 && $did(22)) {
url -an http://soundcloud.com $+ $v1
}
elseif ($did == 15 && $did(22)) {
SoundCloudDownloadInfo $v1
}
elseif ($did == 1 && $did(1).sel) {
did -r $dname 18-23
var %sel $v1
did -c $dname 2-5,24 %sel
var %count 1
while (%count <= 5) {
did -a $dname $calc(17 + %count) $did(%count)
inc %count
}
did -a $dname 23 $did(24)
}
}
dialog SoundcloudSearch {
title "SoundCloud Search"
size -1 -1 229 151
option dbu
combo 1, 118 20 106 88, vsbar
combo 2, 1 117 0 0
combo 3, 1 118 0 0
combo 4, 1 119 0 0
combo 5, 1 120 0 0
combo 24, 1 121 0 0
text "", 6, 1 121 0 0
text "Title:", 8, 2 31 25 8, right
text "User:", 9, 2 44 25 8, right
text "Date:", 10, 2 57 25 8, right
text "Plays:", 11, 2 70 25 8, right
text "Link:", 12, 2 83 25 8, right
text "Length:", 25, 2 96 25 8, right
button "Next Page", 13, 190 112 34 12
button "Search", 7, 190 4 33 12
button "Play", 14, 157 134 31 12
button "Download", 15, 193 134 31 12
button "Prev. Page", 26, 150 112 34 12
edit "", 16, 6 5 180 10, autohs rich
box "", 17, 113 16 113 112
edit "", 18, 28 31 77 8, autohs rich
edit "", 19, 28 44 77 8, autohs rich
edit "", 20, 28 57 77 8, autohs rich
edit "", 21, 28 70 77 8, autohs rich
edit "", 22, 28 83 77 8, autohs rich
edit "", 23, 28 96 77 8, autohs rich
}
alias -l SoundcloudProgressCheck {
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 SoundcloudProgressCheck %dname
}
else {
did -a %dname 2,3,5 Complete
did -a %dname 4 $3-4
.remove $qt(%file)
dialog -x %dname
}
}
}
dialog -l SoundcloudDownloadProgress {
title "SoundCloud 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
}
alias -l GetWget {
if (!$isdir(wget)) {
if ($input(You must download some files to continue. $crlf Dowload them now ?,yq,Sound Cloud Missing 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
}
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 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 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
}