Code:
;http://www.youtube.com/watch?v=py5w1DbNsyk
#include <String.au3>
#include <Array.au3>
#include <File.au3>
#include <YouTube.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $Links = ""
ClipPut(" ")
Opt("GUIResizeMode",$GUI_DOCKALL)
#Region ### START Koda GUI section ### Form=z:\users\xcode\desktop\ytdownloader\gui.kxf
$Form1_1 = GUICreate("YTDownloader-Beta", 642, 361, 831, 125)
GUISetBkColor(0xFFFFFF)
$Edit1 = GUICtrlCreateEdit("", 8, 171, 626, 182)
GUICtrlSetData(-1, "Bitte fügen sie maximal ein Videlink pro Zeile ein.")
$Group1 = GUICtrlCreateGroup("", 136, 2, 498, 137)
$Label1 = GUICtrlCreateLabel("Titel:", 142, 18, 360, 17)
$Label2 = GUICtrlCreateLabel("Länge:", 142, 42, 360, 17)
$Label3 = GUICtrlCreateLabel("User:", 142, 66, 360, 17)
$Label4 = GUICtrlCreateLabel("Größer:", 142, 90, 360, 17)
$Progress1 = GUICtrlCreateProgress(214, 114, 414, 16, $PBS_SMOOTH)
GUICtrlSetColor(-1, 0xFF0000)
$Label5 = GUICtrlCreateLabel("-|-", 142, 114, 70, 17)
$Label6 = GUICtrlCreateLabel("0/0", 587, 15, 36, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("Download", 7, 141, 626, 25, $WS_GROUP)
$Pic1 = GUICtrlCreatePic("", 8, 13, 120, 120, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUICtrlSetImage($Pic1,@ScriptDir&"\Pic\No.jpg")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$TIMER = TimerInit()
DownloadLoop()
$TIMERDIFF = TimerDiff($TIMER)
$TIMER_Count = IniReadSection("Timer.ini","TIMER")
IniWrite("Timer.ini","TIMER",UBound($TIMER_Count),$TIMERDIFF)
EndSwitch
WEnd
Func DownloadLoop()
If GUICtrlRead($Edit1) = "" Then
MsgBox(0,"Error","Es wurden keine Videos eingegeben")
Else
WinMove("YTDownloader-Beta","",0,0,642,166)
$CRLF = StringSplit(GUICtrlRead($Edit1),@CRLF)
_ArrayDeleteEmpty($CRLF)
For $i=1 to UBound($CRLF)-1
$Addi = 0
$Divis = 1
$Titel = Title($CRLF[$i])
$VLink = GetVideoImg($CRLF[$i],$Titel)
GUICtrlSetImage($Pic1,$VLink)
$Grose = Size($CRLF[$i])
$Lange = Lenght($CRLF[$i])
$User = User($CRLF[$i])
If StringLen($Titel) > 40 Then
$Titel = StringLeft($Titel,40)
EndIf
GUICtrlSetData($Label6,$i&"/"&UBound($CRLF)-1)
GUICtrlSetData($Label1,"Titel: "&$Titel)
GUICtrlSetData($Label2,"Länge: "&$Lange)
GUICtrlSetData($Label3,"User: "&$User)
GUICtrlSetData($Label4,"Größe: "&$Grose)
$Ran = Random(1,1000000)
$HInet = InetGet(GetDownloadLink($CRLF[$i]),@ScriptDir&"\Videos\"&$Titel&$Ran&".mp4",0,1)
Do
$cSize = FileGetSize(@ScriptDir&"\Videos\"&$Titel&$Ran&".mp4")
$Akk = $cSize*100/$Grose
GUICtrlSetData($Progress1,$Akk)
GUICtrlSetData($Label5,Round($Akk,2)&"%")
Sleep(30)
Until $cSize = $Grose
FileDelete($VLink)
Next
EndIf
Schluss()
EndFunc
Func Schluss()
WinMove("YTDownloader-Beta","",642, 361, 647, 385)
GUICtrlSetData($Label1,"Titel:")
GUICtrlSetData($Label2,"Länge:")
GUICtrlSetData($Label3,"User:")
GUICtrlSetData($Label4,"Größe:")
GUICtrlSetData($Label5,"-|-:")
GUICtrlSetData($Label6,"0/0")
GUICtrlSetData($Edit1,"Bitte fügen sie maximal ein Videlink pro Zeile ein.")
MsgBox(0,"Fertig","Die Videos sind im Video Ordner zu finden.")
EndFunc