secret
Last active

GrooveShark Playlist Player

  • Download Gist
gspls.hta
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396
<html>
<head>
<title>GrooveShark Playlist Player</title>
<HTA:APPLICATION
APPLICATIONNAME="GrooveShark Playlist Player"
ID="GSpls"
VERSION="0.1"
BORDER="none"
INNERBORDER="no"
SELECTION="no"
CONTEXTMENU="yes"
SINGLEINSTANCE="yes"
NAVIGABLE="yes"
ICON="http://grooveshark.com/webincludes/images/favicon64.ico" />
<script language="VBScript">
<!--
width = 340
height = 600
ResizeTo width, height
MoveTo (screen.AvailWidth-width)/2, (screen.AvailHeight-height)/2
 
x = 0 : y = 0 : m = 0
Function setpos()
move_me.style.color = "#000000"
move_me.style.backgroundColor = "#6AAEF5"
main.style.backgroundColor = "#6AAEF5"
close_button.style.backgroundColor = "#5B92D2"
main.style.borderColor = "#5B92D2"
window.event.srcElement.hideFocus = 1
x = window.event.screenX
y = window.event.screenY
m = 1
End Function
 
Function domove()
If m = 1 Then
moveX = 0 : moveY = 0
moveX = window.event.screenX - x
moveY = window.event.screenY - y
window.moveto(window.screenLeft + moveX), (window.screenTop + moveY)
setPos()
End if
End Function
 
Function stopmove()
move_me.style.color = "#444444"
move_me.style.backgroundColor = "#EBEBEB"
main.style.backgroundColor = "#EBEBEB"
close_button.style.backgroundColor = "#BABABA"
main.style.borderColor = "#C9C9C9"
m = 0
End Function
//-->
</script>
<style type="text/css">
body,form,input,object,div {
margin: 0;
border: 0;
padding: 0;
font-family: "Segoe UI","Trebuchet MS",Arial;
}
body {
padding: 28px 6px 6px 6px;
border: 1px solid #C9C9C9;
overflow: hidden;
}
form {
background-color: #FFFFFF;
padding: 0 0 10px 0;
}
#input_box {
color: silver;
font-size: 9pt;
width: 300px;
height: 26px;
padding: 0px 28px 0px 4px;
border: solid 1px #C9C9C9;
line-height: 24px;
}
#move_me,#close_button,#go_button {
position: absolute;
top: 0;
}
#move_me {
background-color: #EBEBEB;
color: #444444;
font-size: 11pt;
right: 50px;
width: 250px;
height: 28px;
cursor: move;
}
#close_button {
background-color: #BABABA;
color: white;
font-family: Verdana,Tahoma;
font-size: 10pt;
right: 6px;
width: 45px;
height: 20px;
text-align: center;
}
#go_button {
display: none;
background-color: white;
color: silver;
font-family: Verdana,Tahoma;
font-size: 10.5pt;
top: 43px;
right: 20px;
width: 24px;
height: 24px;
text-align: center;
}
table {
background-color: #FFFFFF;
border-collapse: collapse;
border: 1px solid #D7D7D7;
}
td {
text-align: center;
padding-top: 12px;
padding-bottom: 12px;
}
td#groove {
background: url('http://dl.dropbox.com/u/30782742/img/EFC380E1.png') no-repeat center;
padding: 0px auto;
height: 435px;
}
#dd, #ax {
width: 300px;
height: 41px;
background-color: #E9E9E9;
font-size: 9pt;
color: #707070;
text-align: center;
line-height: 36px;
cursor: pointer;
}
#dd {
position: absolute;
top: 538px;
left: 19px;
border: 1px solid #D7D7D7;
}
#dt {
height:65px;
}
</style>
</head>
 
<script language="VBScript">
<!--
Dim msg, gs
 
api_key = "b07b690c6c2a7f32402dc2d34c5a2a65"
 
arg = Split(gspls.commandLine, Chr(34))
If Ubound(arg) > 3 Then msg = arg(3)
url = "http://tinysong.com/b/" : par = "?key=" & api_key
msgs = "Enter playlist path. Playlist too big; Query aborted. Invalid path. Empty file. Playlist not valid." &_
"No result. Not supported filetype. Registering aborted. Operation successful; Changes available on restart."
msg = Split(msgs, ".")(0)
 
Sub window_onload()
move_me.style.backgroundColor = document.bgcolor
groove.innerHtml = gs
search.input_box.value = msg
tab.focus
End Sub
 
Sub ax_Click()
fopen()
End Sub
 
Sub ax_OLEDragDrop(Data, Effect, Button, Shift, x, y)
If Data.GetFormat(15) Then
If InStr("txt,m3u,xml,spf", Right(Data.Files.Item(1), 3)) Then
ax.Backcolor = &H53A615&
search.input_box.value = Data.Files.item(1) : go()
Else
msg = "Not supported filetype"
window_onload()
End If
End If
End Sub
 
Sub ax_OLEDragOver(Data, Effect, Button, Shift, x, y, State)
If State = 0 Then
If InStr("txt,m3u,xml,spf", Right(Data.Files.item(1), 3)) Then ax.Backcolor = &H4217B5&
End If
If State = 1 Then ax.Backcolor = &H53A615&
End Sub
 
Sub RegisterDragDrop(h)
sKey = "HKEY_CLASSES_ROOT\HTAFile\ShellEx\DropHandler\" : sValue = "{60254CA5-953B-11CF-8C96-00AA00B8708C}"
dKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\ActiveX Compatibility\{B09DE715-87C1-11D1-8BE3-0000F8754DA1}\Compatibility Flags"
With CreateObject("WScript.Shell")
On Error Resume Next
d = .regread(dKey)
If Err.Number Then
msg = "Registering aborted"
Else
.regread(sKey)
If Err.Number Then .regwrite sKey, sValue, "REG_SZ"
If h <> d Then .regwrite dKey, CStr(h), "REG_DWORD"
If h = .regread(dKey) Then msg = "Operation successful; Changes available on restart"
End If
On Error Goto 0
window_onload()
End With
End Sub
 
Function Request(url)
Set HTTP = CreateObject("MSXML2.XMLHTTP")
On Error Resume Next
HTTP.open "GET", url, False
HTTP.send ""
If Not Err.number Then resp = HTTP.responseText
On Error GoTo 0
Request = resp
End Function
 
Function Parse(path)
If Not CBool(InStr(path, ".")) Or Left(path, 1) = "?" Then
Parse = path
ElseIf InStr("txt,m3u,xml,spf", Right(path, 3)) Then
If Left(path, 7) = "http://" Then
pls = Request(path)
Else
With CreateObject("Scripting.FileSystemObject")
If .FileExists(path) Then
pls = .OpenTextFile(path).ReadAll
Else
Parse = "Invalid path"
End If
End With
End If
If Len(pls) > 10000 Then
Parse = "Playlist too big; Query aborted"
ElseIf Len(pls) Then
If Right(path, 4) = ".txt" Then
Parse = Replace(pls, vbCrLf, ";")
ElseIf Right(path, 4) = ".m3u" Then
For Each line in Filter(Split(pls, vbCrLf), "#EXTINF")
tracks = tracks & Split(line, ",")(1) & ";"
Next
Parse = tracks
ElseIf Right(path, 4) = ".xml" Or Right(path, 5) = ".xspf" Then
With CreateObject("MSXML2.DOMDocument.6.0")
.loadXML(pls)
.async = False
.setProperty "SelectionNamespaces", "xmlns:x='http://xspf.org/ns/0/'"
For Each node in .selectSingleNode("x:playlist").childnodes
If node.nodeName = "trackList" Then
For Each track In node.childNodes
For Each tag In track.childNodes
If InStr("title.creator", tag.nodeName) Then tracks = tracks & " " & tag.text
Next
tracks = tracks & ";"
Next
End If
Next
Parse = tracks
End With
End If
Else
Parse = "Empty file"
End If
Else
Parse = "Invalid path"
End If
End Function
 
Function ParseResponse(sid)
If InStr(sid, "rate limit exceeded") Or InStr(sid, "api key missing") Then
If MsgBox("Rate limit exceeded." & vbCrLf & vbCrLf & "Press OK to get new api key from 'http://tinysong.com/api' and set it on line 156" & vbCrLf, 49, "Error") = vbOK Then CreateObject("WScript.Shell").Run("http://tinysong.com/api")
window.close
ElseIf InStr(sid, """error""") Then
MsgBox "Error occured." & vbCrLf & vbCrLf & "Message is: " & sid & vbCrLf, 48, "Error"
window.close
ElseIf sid <> "NSF;" Then
ParseResponse = 1
End If
End Function
 
Sub Go()
msg = search.input_box.value
search.go_button.style.color = "silver"
search.go_button.style.display = "none"
If Len(msg) And msg <> "Enter playlist path" Then
shade() : gs = ""
tracks = Parse(msg)
If Len(tracks) Then
On Error Resume Next
If tracks = msg Then
sid = Request(Replace(url, "/b/", "/s/") & Replace(Trim(Replace(tracks,"?", "")), " ", "+") & par & "&limit=32")
If ParseResponse(sid) Then
For Each track in Split(sid, "http://")
If Split(track, "; ")(1) Then ids = ids & Split(track, "; ")(1) & ","
Next
End If
If Not CBool(Len(ids)) Then msg = "No result"
ElseIf Not CBool(InStr(tracks, ";")) Then
msg = tracks
Else
For Each track in Split(tracks, ";")
sid = Request(url & Replace(Trim(Replace(track, vbTab, " ")), " ", "+") & par)
If ParseResponse(sid) Then
If Split(sid, "; ")(1) Then ids = ids & Split(sid, "; ")(1) & ","
End If
Next
If Not CBool(Len(ids)) Then msg = "No result"
End If
On Error GoTo 0
If Len(ids) Then
scheme = "&bbg=1177CB&pbg=1177CB&pfg=FFFFFF&pbgh=6AAEF5&pfgh=FFFFFF&bt=6AAEF5&bth=FFFFFF&bfg=1177CB&lfg=EBEBEB&lbg=1177CB&lfgh=FFFFFF&lbgh=6AAEF5&sb=6AAEF5&sbh=FFFFFF&p=0"
gs = "<object width='300' height='400'>" & vbCrLf &_
" <param name='movie' value='http://grooveshark.com/widget.swf' />" & vbCrLf &_
" <param name='flashvars' value='hostname=cowbell.grooveshark.com&songIDs=" & Left(ids, Len(ids)-1) & scheme & "' />" & vbCrLf &_
" <embed src='http://grooveshark.com/widget.swf' " & vbCrLf &_
" type='application/x-shockwave-flash' width='300' height='400'" & vbCrLf &_
" flashvars='hostname=cowbell.grooveshark.com&songIDs=" & Left(ids, Len(ids)-1) & scheme & "'" & vbCrLf & "</object>"
End If
Else
msg = "Playlist not valid"
End If
window_onload()
End If
End Sub
 
Sub Clean()
For Each m in Filter(Split(msgs, "."), search.input_box.value)
search.input_box.value = ""
Next
search.input_box.style.color = "black"
search.input_box.style.fontSize = "11pt"
End Sub
 
Sub Shade()
If search.input_box.value = "" Then search.input_box.value = "Enter playlist path"
If Not document.activeElement.id = "go_button" Then search.go_button.style.display = "none"
search.input_box.style.color = "silver"
search.input_box.style.fontSize = "9pt"
End Sub
 
Sub fopen()
On Error Resume Next
Set sh = CreateObject("WScript.Shell")
If sh.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE") = "x86" Then
For Each obj In Split("UserAccounts.CommonDialog MSComDlg.CommonDialog MSComDlg.CommonDialog.1")
Set dlg = CreateObject(obj)
If IsObject(dlg) Then
If InStr(obj, "MSComDlg") Then dlg.MaxFileSize = 256
dlg.Filter = "EXTM3U Playlist|*.m3u|XSPF Playlist|*.xspf|TXT List|*.txt|All Files|*.*"
dlg.ShowOpen : msg = dlg.FileName
been_there = True
Exit For
End If
Next
End If
If Not been_there Then
msg = sh.Exec("mshta.exe ""about:<input name='Open' type='file' id='f'><script>f.click();new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).Write(f.value);close();resizeTo(0,0);</script>""").StdOut.ReadLine
End If
On Error Goto 0
If Len(msg) Then window_onload() : search.input_box.focus
End Sub
 
Sub Document_onKeyDown()
If Window.Event.KeyCode = 9 Then search.go_button.style.display = "none"
If Window.Event.KeyCode = 13 Then go()
If Window.Event.KeyCode = 27 Then window.close
If Window.Event.KeyCode = 82 And window.event.ctrlKey Then RegisterDragDrop(0)
If Window.Event.KeyCode = 85 And window.event.ctrlKey Then RegisterDragDrop(&H400)
End Sub
//-->
</script>
 
<body bgcolor="#EBEBEB" id="main">
<input type="button" id="move_me" onmousedown="setpos" onmousemove="domove" onmouseup="stopmove" value="GrooveShark Playlist Player">
<input type="button" id="close_button" value="x" onclick="window.close" onmouseover="me.style.backgroundcolor='#C85051'" onmouseout="me.style.backgroundcolor='#BABABA'">
<table id="tab" width="100%">
<tr><td>
<form id="search">
<input type="text" id="input_box" onfocus="clean():search.go_button.style.display='block'" onblur="shade()">
<input type="button" id="go_button" value="&#182;" title="Submit" onclick="go()" onmouseover="me.style.color='black'" onmouseout="me.style.color='silver'">
</form>
</td></tr>
<tr><td id="groove"></td></tr>
<tr><td id="dt">
<object id="ax" classid="clsid:B09DE715-87C1-11D1-8BE3-0000F8754DA1"><param name="OleDropMode" value="1"><param name="BackColor" value="5482005"></object>
<div id="dd" title="Click to browse for playlist" onclick="fopen()" onmouseover="me.style.borderColor='#3598FE':me.style.color='#000000'" onmouseout="me.style.borderColor='#D7D7D7':me.style.color='#707070'">Open</div>
</td></tr>
</table>
</body>
</html>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.