Dieses Skript ist noch in einer sehr frühen Phase...
Es bindet sich an Skreemr an und erlaubt so das Abspielen und speichern von Musik.
Rechtliches
- SkreemR ist legal
- Wer hierdurch urheberrechtlich geschützte Musik runterläd, ist selber schuld
- Passt also auf, was ihr downloaded
Features/Funktionsweise
Eingabe von Liedtitel oder anderem Suchbegriff, auf Suchen klicken
-->Programm läd Quelltext von skreemr Suchergebnisseite runter und analysiert es
Auswahl des richtigen Songs, Stdmäßig der erste gefundene
Lied downloaden per Button, oder abspielen per Button oder {MEDIA_PLAY_PAUSE}-Taste
Stopbar (leider noch kein Pause) durch Stopbutton oder wieder die Taste
Beim Schließen minimiert es sich in den Tray, einfaches Klicken auf den Tray stellt es wieder her.
So, hier ist es:
Code
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_Comment=SkreemR Player & Downloader
#AutoIt3Wrapper_Res_Description=Lets you hear ANY music file
#AutoIt3Wrapper_Res_Fileversion=0.2.5.4
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=p
#AutoIt3Wrapper_Res_LegalCopyright=(c) 2009 GLi Labors international
#AutoIt3Wrapper_Res_Language=1031
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Author: L3viathan2142 <[email='vkoleviathan@googlemail.com'][/email]>
; License: CC No-Commerce
; Never delete this comment
; Never ever
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include <Constants.au3>
#include <ProgressConstants.au3>
#include <SendMessage.au3>
#include <ComboConstants.au3>
#include <Array.au3>
#include <INet.au3>
#include <GUIConstantsEx.au3>
#include <GuiComboBox.au3>
#include <String.au3>
Opt("TrayAutoPause",0)
Opt("TrayMenuMode",1)
Opt("TrayOnEventMode",1)
TraySetOnEvent($TRAY_EVENT_PRIMARYDOWN,"_showagain")
TraySetClick(12)
TrayCreateItem("Close")
TrayItemSetOnEvent(-1,"_exit")
Global $play=False
Global $files[1], $titles[1]
$Form1 = GUICreate("Skreemr Player", 626, 111, 193, 125)
$hSearchinput = GUICtrlCreateInput("", 8, 2, 425, 21)
$hSearchbutton = GUICtrlCreateButton("Search", 448, 0, 161, 25, 0)
$hCombo = GUICtrlCreateCombo("Datei auswählen...", 8, 32, 609, 25,$CBS_DROPDOWNLIST)
$hDownloadButton = GUICtrlCreateButton("Download...", 8, 80, 153, 25, 0)
$hplayButton = GUICtrlCreateButton("Play", 168, 80, 161, 25, 0)
$volume=GUICtrlCreateSlider(495, 80, 100, 25)
$volabel=GUICtrlCreateLabel("%",595, 80, 30, 25)
$hstopButton = GUICtrlCreateButton("Stop", 330, 80, 161, 25, 0)
GUICtrlSetState($hStopButton,$GUI_DISABLE)
GUICtrlSetState($hDownloadButton,$GUI_DISABLE)
GUICtrlSetState($hPlayButton,$GUI_DISABLE)
$Progress1 = GUICtrlCreateProgress(8, 56, 609, 17)
Global $hProgress = GUICtrlGetHandle($Progress1)
GUICtrlSetState($hSearchbutton,$GUI_FOCUS)
GUICtrlSetState($hSearchinput,$GUI_FOCUS)
GUICtrlSetData($volume,_SoundGetWaveVolume())
GUICtrlSetData($volabel,_SoundGetWaveVolume() & "%")
GUISetState()
AdlibEnable("_actualize",5000)
While True
Switch GUIGetMsg()
case $GUI_EVENT_CLOSE
_close()
case $hSearchbutton
_search()
case $hDownloadButton
_load()
case $hPlayButton
_play()
case $hStopButton
_stop()
case $volume
SoundSetWaveVolume(GUICtrlRead($volume))
GUICtrlSetData($volabel,GUICtrlRead($volume) & "%")
EndSwitch
WEnd
#Region functions
Func _search()
$files[0]=0
$titles[0]=0
_GUICtrlComboBox_ResetContent($hCombo)
GUICtrlSetData($hCombo,"Datei auswählen...")
GUICtrlSetState($hSearchbutton,$GUI_DISABLE)
GUICtrlSetStyle($Progress1,$PBS_MARQUEE)
_SendMessage($hProgress, $PBM_SETMARQUEE, True, 10)
$sInput=GUICtrlRead($hSearchinput)
$sUrl="http://skreemr.com/results.jsp?q=" & StringReplace($sInput," ","+") & "&search=SkreemR+Search"
$sPlainhtml=_INetGetSource($sUrl)
$sfileHtml=$sPlainhtml
$stitleHtml=$sPlainhtml
$aHelper=StringReplace($sfileHtml,'<SPAN CLASS="title">File: </SPAN>',"bla")
$iHowmany=@extended
For $i=1 To $iHowmany
$position=StringInStr($sfileHtml,'<SPAN CLASS="title">File: </SPAN>')
$cutted=StringTrimLeft($sfileHtml,$position)
$sHelpTemp2=_StringBetween($cutted,'<a href="','"')
_ArrayAdd($files,$sHelpTemp2[0])
;~ GUICtrlSetData($hCombo,$sHelpTemp2[0])
$files[0]=$files[0]+1
$sfileHtml=StringTrimLeft($cutted,StringInStr($cutted,'"',0,2))
Next
$aHelper=StringReplace($stitleHtml,'onmouseover="doSearch(',"bla")
$iHowmany=@extended
For $i=1 To $iHowmany
$position=StringInStr($stitleHtml,'onmouseover="doSearch(')
$cutted=StringTrimLeft($stitleHtml,$position)
$sHelpTemp2=_StringBetween($cutted,'>','</span>')
_ArrayAdd($titles,StringTrimLeft($sHelpTemp2[0],4))
GUICtrlSetData($hCombo,StringTrimLeft($sHelpTemp2[0],4),$titles[1])
$titles[0]=$titles[0]+1
$stitleHtml=StringTrimLeft($cutted,StringInStr($cutted,'>',0,2))
GUICtrlSetState($hDownloadButton,$GUI_ENABLE)
GUICtrlSetState($hPlayButton,$GUI_ENABLE)
Next
GUICtrlSetState($hSearchbutton,$GUI_ENABLE)
_SendMessage($hProgress, $PBM_SETMARQUEE, False, 10)
GUICtrlSetStyle($Progress1,0)
GUICtrlSetState($hDownloadButton,$GUI_SHOW)
HotKeySet("{MEDIA_PLAY_PAUSE}","_play")
EndFunc
Func _load()
$sTitletoLoad=GUICtrlRead($hCombo)
If $sTitletoLoad = "" Or $sTitletoLoad = "Datei auswählen..." Then return False
$sFileToLoad=$files[_ArraySearch($titles,$sTitletoLoad)]
;~ _SendMessage($hProgress, $PBM_SETMARQUEE, True, 10)
$iSize=InetGetSize($sFileToLoad)
$filetosave=FileSaveDialog("Save Musik as...",@MyDocumentsDir,"MPEG Layer-3 (*.mp3)|All files(*.*)",16,$sTitletoLoad & ".mp3")
If @error Then return False
InetGet($sFileToLoad,$filetosave,1,1)
If @error Then return False
While @InetGetActive
GUICtrlSetData($Progress1,(@InetGetBytesRead/$iSize)*100)
WEnd
GUICtrlSetData($Progress1,0)
;~ _SendMessage($hProgress, $PBM_SETMARQUEE, False, 10)
EndFunc
Func _play()
$sTitletoLoad=GUICtrlRead($hCombo)
If $sTitletoLoad = "" Or $sTitletoLoad = "Datei auswählen..." Then return False
If @error Then return False
If not (IsArray($titles) AND IsArray($files)) then return false
$sFileToLoad=$files[_ArraySearch($titles,$sTitletoLoad)]
If @error Then return False
GUICtrlSetStyle($Progress1,$PBS_MARQUEE)
_SendMessage($hProgress, $PBM_SETMARQUEE, True, 10)
SoundPlay($sFileToLoad)
$play = True
GUICtrlSetState($hStopButton,$GUI_ENABLE)
GUICtrlSetState($hplayButton,$GUI_DISABLE)
HotKeySet("{MEDIA_PLAY_PAUSE}","_stop")
EndFunc
Func _stop()
SoundPlay("")
$play=False
GUICtrlSetStyle($Progress1,0)
_SendMessage($hProgress, $PBM_SETMARQUEE, False, 10)
GUICtrlSetState($hStopButton,$GUI_DISABLE)
GUICtrlSetState($hPlayButton,$GUI_ENABLE)
HotKeySet("{MEDIA_PLAY_PAUSE}","_play")
EndFunc
func _showagain()
GUISetState(@SW_SHOW)
EndFunc
func _exit()
Exit
EndFunc
func _close()
If $play Then
GUISetState(@SW_HIDE)
Else
Exit
EndIf
EndFunc
Func _SoundGetWaveVolume()
Local $WaveVol = -1, $p, $ret
Const $MMSYSERR_NOERROR = 0
$p = DllStructCreate ("dword")
If @error Then
SetError(2)
Return -2
EndIf
$ret = DllCall("winmm.dll", "long", "waveOutGetVolume", "long", -1, "long", DllStructGetPtr ($p))
If ($ret[0] == $MMSYSERR_NOERROR) Then
$WaveVol = Round(Dec(StringRight(Hex(DllStructGetData ($p, 1), 8), 4)) / 0xFFFF * 100)
Else
SetError(1)
EndIf
;~ DllStructDelete ($p)
Return $WaveVol
EndFunc ;==>_SoundGetWaveVolume
func _actualize()
GUICtrlSetData($volume,_SoundGetWaveVolume())
GUICtrlSetData($volabel,_SoundGetWaveVolume() & "%")
EndFunc
#EndRegion functions
Erwünsche konstruktive Kritik,
ich weiß, dass das Auslesen des Codes nicht ideal so ist...
/edit: Noch neuere Version 0.2.5.4, mit Fehlerbehebung...(thx @ Tobi_Girst)