Videos von YouTube mit AutoIt?

  • Ja ;)

    Hier das fertige Skript:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    #include <inet.au3>
    #include <Date.au3>

    GUICreate("You Tube Video-Downloader", 273, 105, 193, 115, -1)
    $DwnInput = GUICtrlCreateInput("Hier YouTube Link Rein !", 8, 24, 257, 21)
    GUICtrlCreateLabel("www.youtube.com Download Link:", 8, 8, 268, 15)
    $start = GUICtrlCreateButton("&Start", 8, 48, 128, 25, 0)
    $Progress = GUICtrlCreateProgress(8, 80, 257, 16)
    $abb = GUICtrlCreateButton("A&bbruch", 137, 48, 128, 25, 0)
    GUISetState(@SW_SHOW)

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $start
    GUICtrlSetState($start,$GUI_DISABLE)
    $dwnlink = GUICtrlRead($DwnInput)
    $sCode=_INetGetSource ($dwnlink)
    $s_t=StringRegExp($sCode, "&t=(.*?)&", 3)
    $s_v=stringmid($dwnlink,stringinstr($dwnlink,"v=")+2)
    $save = FileSaveDialog("Speichere FLV","","Flash Video(*.flv)",-1,$s_v)
    If StringRight($save,4) <> ".swf" Then $save&=".flv"
    _Download("http://youtube.com/get_video?video_id=" & $s_v & "&t=" & $s_t[0],$save,$Progress)
    GUIDelete()
    MsgBox(0,"","Fertig!")
    Exit
    EndSwitch
    WEnd

    Func _Download($site,$punkt,$prog=0)
    $orisize = InetGetSize($site)
    InetGet($site,$punkt,1,1)
    If $prog = 0 Then ProgressOn("Download","")
    Do
    $msg = GUIGetMsg()
    If $msg = $abb Then
    If MsgBox(4,"","Abbruch?") = 6 Then Exit
    EndIf
    $size1 = FileGetSize($punkt)
    $MBsize1 = FileGetSize($punkt)
    $inetget = @InetGetBytesRead
    $Prozent = (100 * $inetget ) / $orisize
    $decimalplace = Round ($Prozent)
    $decimalplaceMBsize1 = Round (@InetGetBytesRead / 1024)
    If $prog = 0 Then
    ProgressSet ($Prozent, $decimalplace & "% " & "(" & $decimalplaceMBsize1 & ") Kb sind bereits gedownloadet.")
    Else
    GUICtrlSetData($prog,$Prozent)
    EndIf
    Until @InetGetActive = 0
    If $prog = 0 Then ProgressOff ()
    Local $sFFmpeg="", $hFFmpeg
    $hFFmpeg=Run(@ScriptDir & '\ffmpeg.exe -i "' & $punkt & '" -y "' & StringTrimRight($punkt,3) & 'avi"',@ScriptDir,@SW_HIDE,0x4)
    While 1
    $sFFmpeg &= StderrRead($hFFmpeg)
    If @error Or StringInStr($sFFmpeg,"Duration") Then ExitLoop
    WEnd
    $sFFmpeg = StringLeft(StringTrimLeft($sFFmpeg, StringInStr($sFFmpeg, "Duration:") + 9), 8)
    $iTicks = _TimeToTicks(StringLeft($sFFmpeg, 2), StringMid($sFFmpeg, 4, 2), StringMid($sFFmpeg, 7, 2))
    While 1
    $sFFmpeg = StderrRead($hFFmpeg)
    If @error Then ExitLoop
    If StringInStr($sFFmpeg,"time=") Then
    $sFFmpeg=StringTrimLeft($sFFmpeg, StringInStr($sFFmpeg, "time=") + 4)
    GUICtrlSetData($prog,(StringLeft($sFFmpeg, StringInStr($sFFmpeg, ".")-1) *100000)/$iTicks)
    EndIf
    WEnd
    Return $punkt
    EndFunc

    [/autoit]

    Musst nur noch Avi durch MP3 ersetzen =D
    Mfg
    Benne

  • @PokerFace wenn man einen falschen link eingibt dann kommt ein fehler...
    kann man das noch irgendwie verhinder - also so eine art abfrage wenn der link falsch ist dann msgbox(...."Url existiert nicht..)
    ???

  • und wie würde das dann im script aussehn?
    hier noch mal der fehler der kommt:
    _Download("http://youtube.com/get_video?video_id=" & $s_v & "&t=" & $s_t^ ERROR
    Error: Subscript used with non-Array variable.
    > Es soll nur dieser Fehler behoben werden, wenn man eine nicht existierende url eingibt...

    Einmal editiert, zuletzt von team2way (5. April 2009 um 22:50)

  • Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    #include <inet.au3>
    #include <Date.au3>

    [/autoit] [autoit][/autoit] [autoit]

    ;~ FileInstall ("C:\ffmpeg.exe", "C:\Video\ffmpeg.exe")

    [/autoit] [autoit][/autoit] [autoit]

    ;~ $Pfad = "C:\Video\ffmpeg.exe"

    GUICreate("You Tube Video-Downloader", 273, 105, 193, 115, -1)
    $DwnInput = GUICtrlCreateInput("Hier YouTube Link Rein !", 8, 24, 257, 21)
    GUICtrlCreateLabel("www.youtube.com Download Link:", 8, 8, 268, 15)
    $start = GUICtrlCreateButton("&Start", 8, 48, 128, 25, 0)
    $Progress = GUICtrlCreateProgress(8, 80, 257, 16)
    $abb = GUICtrlCreateButton("A&bbruch", 137, 48, 128, 25, 0)
    GUISetState(@SW_SHOW)

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $start
    GUICtrlSetState($start,$GUI_DISABLE)
    $dwnlink = GUICtrlRead($DwnInput)
    If Ping ($dwnlink) = 1 Then
    $sCode=_INetGetSource ($dwnlink)
    $s_t=StringRegExp($sCode, "&t=(.*?)&", 3)
    $s_v=stringmid($dwnlink,stringinstr($dwnlink,"v=")+2)
    $save = FileSaveDialog("Speichere FLV","","Flash Video (*.flv)",-1,$s_v)
    If StringRight($save,4) <> ".swf" Then $save&=".flv"
    _Download("http://youtube.com/get_video?video_id=" & $s_v & "&t=" & $s_t[0],$save,$Progress)
    GUIDelete()
    MsgBox(0,"","Fertig!")
    Exit
    ElseIf Ping ($dwnlink) = 0 Then
    MsgBox (0, "Error", "Der Link existiert nicht!!")
    Exit
    EndIf
    EndSwitch
    WEnd

    Func _Download($site,$punkt,$prog=0)
    $orisize = InetGetSize($site)
    InetGet($site,$punkt,1,1)
    If $prog = 0 Then ProgressOn("Download","")
    Do
    $msg = GUIGetMsg()
    If $msg = $abb Then
    If MsgBox(4,"","Abbruch?") = 6 Then Exit
    EndIf
    $size1 = FileGetSize($punkt)
    $MBsize1 = FileGetSize($punkt)
    $inetget = @InetGetBytesRead
    $Prozent = (100 * $inetget ) / $orisize
    $decimalplace = Round ($Prozent)
    $decimalplaceMBsize1 = Round (@InetGetBytesRead / 1024)
    If $prog = 0 Then
    ProgressSet ($Prozent, $decimalplace & "% " & "(" & $decimalplaceMBsize1 & ") Kb sind bereits gedownloadet.")
    Else
    GUICtrlSetData($prog,$Prozent)
    EndIf
    Until @InetGetActive = 0
    If $prog = 0 Then ProgressOff ()
    Local $sFFmpeg="", $hFFmpeg
    $hFFmpeg=Run(@ScriptDir '\ffmpeg.exe -i "' & $punkt & '" -y "' & StringTrimRight($punkt,3) & 'avi"',@ScriptDir,@SW_HIDE,0x4)
    While 1
    $sFFmpeg &= StderrRead($hFFmpeg)
    If @error Or StringInStr($sFFmpeg,"Duration") Then ExitLoop
    WEnd
    $sFFmpeg = StringLeft(StringTrimLeft($sFFmpeg, StringInStr($sFFmpeg, "Duration:") + 9), 8)
    $iTicks = _TimeToTicks(StringLeft($sFFmpeg, 2), StringMid($sFFmpeg, 4, 2), StringMid($sFFmpeg, 7, 2))
    While 1
    $sFFmpeg = StderrRead($hFFmpeg)
    If @error Then ExitLoop
    If StringInStr($sFFmpeg,"time=") Then
    $sFFmpeg=StringTrimLeft($sFFmpeg, StringInStr($sFFmpeg, "time=") + 4)
    GUICtrlSetData($prog,(StringLeft($sFFmpeg, StringInStr($sFFmpeg, ".")-1) *100000)/$iTicks)
    EndIf
    WEnd
    Return $punkt
    EndFunc

    [/autoit]

    Bitte sehr ;)

  • nice
    hab grad die youtube funktion zu nem proggi von mir hinzugefügt und dich unter autoren erwähnt ^^
    also danke noch mal :thumbup:

    Einmal editiert, zuletzt von team2way (6. April 2009 um 20:11)

  • also das habe ich gestartet, meine FTP Adresse eingetragen.
    Und wie geht es dann weiter? =D
    Enter drücen geht net =P

  • @PokerFace unten im traymenü kannst du auf download klicken und hab den hotkey Alt+a eingebaut
    kann ber auch noch das inputfeld onevent setzen^^

    Zitat

    lso das habe ich gestartet, meine FTP Adresse eingetragen.


    (ich glaub nich das du da was mit ordnern runterladen kannst
    normal gehn nur einzelne dateien)

    geht das auch komplette ordner runterladen mit inetget?
    das währ natürlich nice noch so als funktion^^

  • Danke ;)
    Außerdem würde ich dir raten, das du dafür nen eigenen Thread unter dem Forum Skripte machst =)
    Dann bekommt es jeder mit. =)

  • @PokerFace zu deinem script : hab noch n fehler festgestellt es kommt immer die meldung link existiert nicht...^^
    das scheint irwas mit dem pingen nicht zu stimmen!!

    mfg team2way

  • Das versuche ich gerade zu fixen :D
    Das Problem ist, dass man den Link nicht anpingen kann.
    Ich habe das mal mit der Konsole von Windows probiert, man kann den Download Link nicht an pingen.
    Was mich wundert.
    Ich suche noch nach einer Lösung^^
    Aber sonst steht alles =P

  • Hallo,

    nur schade, dass die Downloads bei Youtube eine schlechtere Bildqualität haben als wenn man die Online anschaut.
    Wenn man z.B. einen Link zu einen HD Video eingibt ist das fertige Video wirklich miese Qualität... Schade, aber da kann das Tools nix dafür.

    Ansonsten wirklich ganz nett. :)

    müsste man mal schauen, ob diese tools das auch so machen:
    http://www.heise.de/software/downl…r_youtube/52949

    oder
    http://www.heise.de/software/downl…ownloader/53674

    schöne Grüße

    Franz

    ---
    In "Independence Day" konnten die Windows-Erdcomputer problemlos mit denen der Außerirdischen kommunizieren. Was sagt uns das über unseren lieben Bill Gates? :D
    ---

  • Das scheint leider zu stimmen.
    Liegt aber an der Größe in der man das Abspielt.
    Wenn das die größe des YoUTube Fensters ist, dann ist es genau so .!
    Und wenn man den Converter (ffmpeg) benutzt, dann ist wirklich ne Miese Quali =P

  • Zitat

    hier noch mal der fehler der kommt:
    _Download("http://youtube.com/get_video?video_id=" & $s_v & "&t=" & $s_t^ ERROR
    Error: Subscript used with non-Array variable.


    warum kommt eigentlich dieser array fehler, wenn man eine falsche url eingibt?
    vllt kann man auch einfach den beheben und bräuchte so nicht das pingen

    mfg team2way

  • ja klar geht das einfacher mit der func isarray...
    der fehler ist ja das er sagt das ist kein array aber wenn du vorher mit isarray testes....