JRSmile Posted March 21, 2009 Posted March 21, 2009 (edited) I found an interresting leak in the last.fm api and as long as last.fm provides a fulllength copy of the track you want to download, you can get it by entering artist and title and it will arrive on your machine nearly instantly expandcollapse popup#include <inet.au3> #include <string.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $artist = "The Rural Alberta Advantage" $title = "The Ballad of The RAA" #Region ### START Koda GUI section ### Form= $IN_Form1 = GUICreate("Last.fm - Cheater", 370, 70, 415, 277) $IN_Artist = GUICtrlCreateInput($artist, 8, 8, 137, 21) $IN_Title = GUICtrlCreateInput($title, 152, 8, 137, 21) $IN_Search = GUICtrlCreateButton("Search", 296, 8, 65, 25, 0) Global $IN_Searching = GUICtrlCreateLabel("", 8, 40, 356, 42) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $IN_Search Download() EndSwitch WEnd Func Download() GUICtrlSetData($IN_Searching, "Searching ...") $artist = GUICtrlRead($IN_Artist) $title = GUICtrlRead($IN_Title) $link = __lastfm_get_track($artist, $title) if not @error Then InetGet($link, $artist & " - " & $title & ".mp3", 1, 1) While @InetGetActive GUICtrlSetData($IN_Searching, "Downloading:" & $artist & " - " & $title & @CRLF & @InetGetBytesRead & " bytes") if GUIGetMsg() = $GUI_EVENT_CLOSE then Exit Sleep(25) Wend GUICtrlSetData($IN_Searching, "DONE") Else GUICtrlSetData($IN_Searching, @extended) EndIf EndFunc Func __lastfm_get_track($artist, $track) $artist = __lastfm_URLEncode($artist) $track = __lastfm_URLEncode($track) $res = _INetGetSource('http://ws.audioscrobbler.com/2.0/?method=track.getinfo&api_key=b25b959554ed76058ac220b7b2e0a026&artist=' & $artist & '&track=' & $track) if @error Then Return SetError(1,"could not contact last.fm",False) if StringInStr($res, '<streamable fulltrack="1">1</streamable>') Then Local $ID = _StringBetween($res, '<id>', '</id>') $res = _INetGetSource('http://ws.audioscrobbler.com/2.0/?method=playlist.fetch&api_key=b25b959554ed76058ac220b7b2e0a026&playlistURL=lastfm://playlist/track/' & $ID[0] & '&streaming=1&fod=1') if @error Then Return SetError(1,"could not get playlist",False) Local $link = _StringBetween($res, '<location>', '</location>') Return $link[0] Else Return SetError(1,'No fulltrack was found', False) EndIf EndFunc ;==>__lastfm_get_track Func __lastfm_URLEncode($toEncode) Local $strHex = "", $iDec Local $aryChar = StringSplit($toEncode, "") For $i = 1 To $aryChar[0] If Not StringInStr("$-_.+!*'(),;/?:@=&abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", $aryChar[$i]) Then $strHex = $strHex & "%" & Hex(Asc($aryChar[$i]), 2) Else $strHex = $strHex & $aryChar[$i] EndIf Next Return $strHex EndFunc ;==>__lastfm_URLEncode Edited March 21, 2009 by JRSmile $a=StringSplit("547275737420796F757220546563686E6F6C75737421","") For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4) Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI" Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile; MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)
ChaosCookie Posted March 21, 2009 Posted March 21, 2009 dammit, you are a genius! I tried so long without any success... nice!
JRSmile Posted March 22, 2009 Author Posted March 22, 2009 Yupp noticed that extended thing... What a pitty only integer ... $a=StringSplit("547275737420796F757220546563686E6F6C75737421","") For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4) Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI" Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile; MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)
ChaosCookie Posted March 22, 2009 Posted March 22, 2009 Is it somehow possible to add Tracks to your playlists with Autoit?
JRSmile Posted March 22, 2009 Author Posted March 22, 2009 Is it somehow possible to add Tracks to your playlists with Autoit?sure $a=StringSplit("547275737420796F757220546563686E6F6C75737421","") For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4) Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI" Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile; MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now