Hey Leute
Wollte mal schnell meinen Youtube-Downloader+Converter vorstellen
Hab mich soweit informiert: in den AGB steht das man es nur bei legalem Upload darf. (Die AGB´s muss man aber nur akzeptueren wenn man einen Account hat)
Das wichtigste ist mir nur, ob er auch in Windows-7 läuft.
Bitte um Rückmeldung^^
Source:
Spoiler anzeigen
#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_Comment=This Program allows you to download videos from Youtube and konvert them into mp3
#AutoIt3Wrapper_Res_Description=Youtube downloader and mp3 konverter
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=Tim_Dellmann/xVxT1MxVx
#AutoIt3Wrapper_Res_Language=1031
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <String.au3>
#include <Inet.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
Global $gesamtByte, $nowByte
Global $sSavePath, $Downloadlink, $hDownload, $sTempSave
#region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Youtube Downloader by Tim Dellmann", 394, 422, 285, 174)
$lURL = GUICtrlCreateListView("Title|Size|Quality|Lenght|URL", 8, 8, 378, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 100)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 4, 230)
$bSetUrl = GUICtrlCreateButton("URL aus Zwischenspeicher einfügen", 8, 168, 299, 25, $WS_GROUP)
$Label1 = GUICtrlCreateLabel("Speicherpfad:", 8, 200, 70, 17)
$iSavePath = GUICtrlCreateInput("", 88, 200, 257, 21)
$bDelete = GUICtrlCreateButton("Entfernen", 312, 168, 75, 25, $WS_GROUP)
$bBrowseDir = GUICtrlCreateButton("...", 352, 200, 35, 25, $WS_GROUP)
$Label2 = GUICtrlCreateLabel("Speichername:", 8, 224, 75, 17)
$iSaveName = GUICtrlCreateInput(" - Title - ", 88, 224, 257, 21, BitOR($ES_AUTOHSCROLL, $ES_READONLY))
$Group1 = GUICtrlCreateGroup("", 0, 264, 393, 9)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$bDownload = GUICtrlCreateButton("Downloade markiertes Video", 8, 280, 379, 25, $WS_GROUP)
$lProgress = GUICtrlCreateLabel("0 Mb / 0 Mb", 8, 312, 375, 17, $SS_CENTER)
$Progress1 = GUICtrlCreateProgress(8, 336, 374, 17)
$bStop = GUICtrlCreateButton("Download abbrechen", 8, 360, 379, 25, $WS_GROUP)
$Group2 = GUICtrlCreateGroup("", 0, 384, 393, 9)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Checkbox1 = GUICtrlCreateCheckbox("Nächsten Download in Liste automatisch starten", 8, 400, 377, 17)
$RadioMPEG = GUICtrlCreateRadio("Als MPEG speichern (video)", 8, 248, 153, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$RadioMp3 = GUICtrlCreateRadio("Als Mp3 speichern (sound)", 168, 248, 145, 17)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $bDelete
_delete()
Case $bDownload
_StartDownload()
Case $bSetUrl
_SetURL()
Case $bBrowseDir
GUICtrlSetData($iSavePath, FileSelectFolder("Wähle den Speicherort!", @DesktopDir))
Case $bStop
InetClose($hDownload)
AdlibUnRegister("_SetProgress")
GUICtrlSetData($Progress1, 0)
GUICtrlSetState($bDownload, $GUI_Enable)
GUICtrlSetState($lURL, $GUI_Enable)
GUICtrlSetData($lProgress, "0 Mb / 0 Mb")
GUICtrlSetState($iSaveName, " - Titel - ")
EndSwitch
WEnd
Func _IsYoutubeURL($sURL)
Local $iResult = 0
If StringLeft($sURL, 31) = "http://www.youtube.com/watch?v=" Then $iResult = 1
Return $iResult
EndFunc ;==>_IsYoutubeURL
Func _SetURL()
$tURL = ClipGet()
If Not _IsYoutubeURL($tURL) Then Return (MsgBox(64, "Error", "Angebebene URL ist keine Youtube.com URL." & @CRLF & "Format: [media]http://www.youtube.com/watch?v=8giug69to8[/media]"))
;MsgBox(64, "URL", $tURL)
$tCode = _INetGetSource($tURL)
$tLenght = _GetLenght($tCode)
;MsgBox(64, "lenght", $tLenght & " sec")
$tQuality = _GetQuality($tCode)
;MsgBox(64, "quality", $tQuality & "p")
$tDownloadlink = _GetVideoDownloadLink($tCode)
$tSize = InetGetSize($tDownloadlink)
;MsgBox(64, "size", Round($tSize / 1024 / 1024, 1) & " Mb")
$tTitle = _GetTitle($tCode)
;MsgBox(64, "title", $tTitle)
GUICtrlCreateListViewItem($tTitle & "|" & Round($tSize / 1024 / 1024, 1) & " Mb" & "|" & $tQuality & "f/s" & "|" & $tLenght & "sec" & "|" & $tURL, $lURL)
EndFunc ;==>_SetURL
Func _SetProgress()
$nowByte = @inetGetbytesread
;MsgBox(64, "gesamtbyte", Round($nowByte / 1024 / 1024, 0) & " Mb")
$percent = $nowByte / $gesamtByte * 100
;MsgBox(64, "", Round($gesamtByte / 1024 / 1024, 1))
GUICtrlSetData($Progress1, $percent)
GUICtrlSetData($lProgress, Round($nowByte / 1024 / 1024, 1) & " Mb / " & Round($gesamtByte / 1024 / 1024, 1) & " Mb")
If @inetgetactive = 0 Then
AdlibUnRegister("_SetProgress")
GUICtrlSetData($Progress1, 0)
GUICtrlSetState($bDownload, $GUI_Enable)
GUICtrlSetState($lURL, $GUI_Enable)
_delete()
GUICtrlSetData($lProgress, "0 Mb / 0 Mb")
GUICtrlSetData($iSaveName, " - Titel - ")
GUICtrlSetData($lProgress, " - Video wird Convertiert - ")
_SaveAsSelected()
FileDelete($sTempSave & ".flv")
GUICtrlSetData($lProgress, "0 Mb / 0 Mb")
If GUICtrlRead($Checkbox1) = 1 Then
_GUICtrlListView_ClickItem($lURL, 0)
If _GUICtrlListView_GetItemCount($lURL) > 0 Then
_StartDownload()
Return
EndIf
EndIf
$x = _GetSelectedURL()
If $x = -1 Then
MsgBox(64, "Fertig", "Alle Downloads wurden beendet!")
WinFlash("Youtube Downloader by Tim Dellmann")
EndIf
EndIf
EndFunc ;==>_SetProgress
Func _StartDownload()
If Not FileExists(GUICtrlRead($iSavePath)) Then Return (MsgBox(64, "Error", "Keinen Speicherpfad ausgewählt/Pfad existiert nicht!"))
If GUICtrlRead($iSaveName) = "" Then Return (MsgBox(64, "Error", "Keinen Namen ausgewählt!"))
$URL = _GetSelectedURL()
If $URL = -1 Then Return MsgBox(64, "Error", "Keine URL ausgewählt!")
;MsgBox(64, "", $URL)
$tCode = _INetGetSource($URL)
$tTitle = _GetTitle($tCode)
GUICtrlSetData($iSaveName, StringReplace($tTitle, " ", "_"))
$sSavePath = GUICtrlRead($iSavePath) & "/" & GUICtrlRead($iSaveName)
$sTempSave = @TempDir & "/" & GUICtrlRead($iSaveName)
$Downloadlink = _GetVideoDownloadLink($tCode)
$gesamtByte = InetGetSize($Downloadlink)
$hDownload = InetGet($Downloadlink, $sTempSave & ".flv", 0, 1)
GUICtrlSetState($bDownload, $GUI_Disable)
GUICtrlSetState($lURL, $GUI_Disable)
AdlibRegister("_SetProgress")
EndFunc ;==>_StartDownload
Func _GetTitle($sCode)
$Title = _StringBetween($sCode, 'title" content="', '">')
Return $Title[0]
EndFunc ;==>_GetTitle
Func _GetLenght($sCode)
$Length = _StringBetween($sCode, '"length_seconds": ', ',')
Return $Length[0]
EndFunc ;==>_GetLenght
Func _GetQuality($sCode)
$Quality = _StringBetween($sCode, '&fmt_list=', '%')
Return $Quality[0]
EndFunc ;==>_GetQuality
Func _GetVideoDownloadLink($sCode)
$ID = _StringBetween($sCode, 'http://www.youtube.com/watch?v=', '" />')
$VideoID = StringRegExp($sCode, "&t=(.*?)&", 3)
$DLLink = "http://youtube.com/get_video?video_id=" & $ID[0] & "&fmt=" & _GetQuality($sCode) & "&t=" & $VideoID[0]
Return $DLLink
EndFunc ;==>_GetVideoDownloadLink
Func _GetSelectedURL()
$URL = GUICtrlRead(GUICtrlRead($lURL))
If $URL = "" Then Return -1
$aURL = StringSplit($URL, "|")
Return $aURL[$aURL[0] - 1]
EndFunc ;==>_GetSelectedURL
Func _delete()
GUICtrlDelete(GUICtrlRead($lURL))
EndFunc ;==>_delete
Func _Convert($Inputfile, $Outputfile)
RunWait("ffmpeg -i " & $Inputfile & " " & $Outputfile)
EndFunc ;==>_Convert
Func _SaveAsSelected()
Local $sSaveType
If BitOR(GUICtrlRead($RadioMp3), $GUI_CHECKED) = $GUI_CHECKED Then $sSaveType = ".mp3"
If BitOR(GUICtrlRead($RadioMPEG), $GUI_CHECKED) = $GUI_CHECKED Then $sSaveType = ".mpeg"
_Convert($sTempSave & ".flv", $sSavePath & $sSaveType)
EndFunc ;==>_SaveAsSelected
Um die Videos zu konvertieren braucht ihr die FFmpeg.exe, diese muss im selben Ordner liegen wie das Script!
FFmpeg: http://ffmpeg.arrozcru.org/builds/bin/ffmpeg-latest.tar.bz2
bitte wirklich rückmeldung zu Win-7 geben