Jump to content

Recommended Posts

Posted

Check my YouTube Multi-Downloader (link in my signature) and try with your video link, use the correct settings and you will be able to get the Original quality link.

Br, FireFox.

Posted (edited)

Check my YouTube Multi-Downloader (link in my signature) and try with your video link, use the correct settings and you will be able to get the Original quality link.

Br, FireFox.

 

I would like to write a program for download only 4K video, not use your for download vid ;)

So can you explain me only this part of video download process? (generate 4k link)

Edited by redfenix
Posted

The source code is available, take a look at it.

Between me and you, if there is already a program for it, why re-inventing the wheel?

Posted

To write it according to my taste :)

...

Sorry but i can't understood the correct method, in your sources there are too many variables and i can't follow all your mental path (?)

 

(sorry for my english :()

Posted (edited)

I understand this is complex for you. I havn't looked at the code for months and it has to be updated since it's not working anymore with all links.

I'm sorry but according to what I said I won't be able to help you until I have updated this last.

Br, FireFox.

Edited by FireFox
  • Solution
Posted (edited)

If you are still there, here you go :

;Author: FireFox @2013
#include <String.au3>
#include "WinHTTP.au3"
 
Local $sDownload_VideoID = "kIjjHeD-0dY"
 
Local Const $sHTTPUserAgent = "User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko/20100101 Firefox/11.0"
 
Local $hWinHttpOpen = _WinHttpOpen($sHTTPUserAgent)
Local $hWinHttpConnect = _WinHttpConnect($hWinHttpOpen, "www.youtube.com")
 
Local $hWinHttpRequest = _WinHttpOpenRequest($hWinHttpConnect, "GET", _
        "/watch?v=" & $sDownload_VideoID, _
        "HTTP/1.1")
 
_WinHttpSendRequest($hWinHttpRequest)
 
_WinHttpReceiveResponse($hWinHttpRequest)
 
Local $sDownload_Chunk = "", $sDownload_ResponseData = ""
While 1
    $sDownload_Chunk = _WinHttpReadData($hWinHttpRequest, 1)
    If @error Then ExitLoop
    $sDownload_ResponseData &= $sDownload_Chunk
WEnd
 
_WinHttpCloseHandle($hWinHttpRequest)
 
Local $aDownload_URLMap = _StringBetween($sDownload_ResponseData, '"url_encoded_fmt_stream_map": "', '", "')
 
If StringInStr($aDownload_URLMap[0], '"}};') > 0 Then
    $aDownload_URLMap[0] = StringLeft($aDownload_URLMap[0], StringInStr($aDownload_URLMap[0], '"}};'))
EndIf
 
$aDownload_URLMap = StringSplit($aDownload_URLMap[0], ",")
 
Local $sDownload_Link = _Download_fmtstream_GetOriginalLink($aDownload_URLMap)
If $sDownload_Link = "" Then
    ConsoleWrite("!>Original link NOT available" & @CrLf)
    Exit 1
EndIf
ConsoleWrite($sDownload_Link & @CrLf)
 
;~ ConsoleWrite("Downloading..." & @CrLf)
;~ Local $hDownload_1 = InetGet($sDownload_Link, $sDownload_VideoID & ".mp4")
;~ InetClose($hDownload_1)
 
Func _Download_fmtstream_GetOriginalLink($aFmtstream)
    Local Const $sFmtOriginal = "38"
    Local $aParamOrder[20] = ["url", "gcr", "upn", "source", "key", "mv", "cp", "ip", "expire", "ratebypass", "mt", "itag", "sparams", "ms", "ipbits", "sver", "fexp", "id", "sig"]
    Local $aParam = 0, $sFmtDecoded = ""
 
    For $i = 1 To $aFmtstream[0]
        $aFmtstream[$i] = _UnicodeURLDecode($aFmtstream[$i])
 
        $aParam = StringRegExp($aFmtstream[$i], "([^?&=]+)=([^?&]*)", 3)
 
        For $j = 0 To UBound($aParamOrder) - 1
            For $k = 0 To UBound($aParam) - 1 Step 2
                If $aParam[$k] <> $aParamOrder[$j] Then ContinueLoop
 
                If $j = 0 Then
                    $sFmtDecoded = $aParam[$k + 1] & "?"
                Else
                    If $aParam[$k] = "itag" And $aParam[$k + 1] <> $sFmtOriginal Then
                        $sFmtDecoded = ""
                        ExitLoop 2
                    ElseIf $aParam[$k] = "sig" Then
                        $aParam[$k] = "signature"
                    EndIf
 
                    $sFmtDecoded &= $aParam[$k] & "=" & $aParam[$k + 1] & "&"
                EndIf
 
                ExitLoop
            Next
        Next
 
        Return StringTrimRight($sFmtDecoded, 1)
    Next
EndFunc
 
; #FUNCTION# ====================================================================================================================
; Name...........: _UnicodeURLDecode
; Author ........: Dhilip89
; ===============================================================================================================================
Func _UnicodeURLDecode($toDecode)
    Local $strChar = "", $iOne = 0, $iTwo = 0
    Local $aryHex = StringSplit($toDecode, "")
 
    For $i = 1 To $aryHex[0]
        If $aryHex[$i] = "%" Then
            $i = $i + 1
            $iOne = $aryHex[$i]
            $i = $i + 1
            $iTwo = $aryHex[$i]
            $strChar = $strChar & Chr(Dec($iOne & $iTwo))
        Else
            $strChar = $strChar & $aryHex[$i]
        EndIf
    Next
 
    $strChar = StringReplace($strChar, "+", " ")
    $strChar = StringReplace($strChar, "%3A", ":")
    $strChar = StringReplace($strChar, "\/", "/")
    $strChar = StringReplace($strChar, "\u0026", "&")
 
    Return BinaryToString(StringToBinary($strChar), 4)
EndFunc
Br, FireFox. Edited by FireFox
Posted

i wonder if he means mpeg4 quality ? youtube always offers a bunch of qualities like flv or mp3 and other formats.

[color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font]

Posted

If you are still there, here you go :

;Author: FireFox @2013
#include <String.au3>
#include "WinHTTP.au3"
 
Local $sDownload_VideoID = "kIjjHeD-0dY"
 
Local Const $sFmtOriginal = "38"
 
Local Const $sHTTPUserAgent = "User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko/20100101 Firefox/11.0"
 
Local $hWinHttpOpen = _WinHttpOpen($sHTTPUserAgent)
Local $hWinHttpConnect = _WinHttpConnect($hWinHttpOpen, "www.youtube.com")
 
Local $hWinHttpRequest = _WinHttpOpenRequest($hWinHttpConnect, "GET", _
        "/watch?v=" & $sDownload_VideoID, _
        "HTTP/1.1")
 
_WinHttpSendRequest($hWinHttpRequest)
 
_WinHttpReceiveResponse($hWinHttpRequest)
 
Local $sDownload_Chunk = "", $sDownload_ResponseData = ""
While 1
    $sDownload_Chunk = _WinHttpReadData($hWinHttpRequest, 1)
    If @error Then ExitLoop
    $sDownload_ResponseData &= $sDownload_Chunk
WEnd
 
_WinHttpCloseHandle($hWinHttpRequest)
 
Local $aDownload_URLMap = _StringBetween($sDownload_ResponseData, '"url_encoded_fmt_stream_map": "', '", "')
 
If StringInStr($aDownload_URLMap[0], '"}};') > 0 Then
    $aDownload_URLMap[0] = StringLeft($aDownload_URLMap[0], StringInStr($aDownload_URLMap[0], '"}};'))
EndIf
 
$aDownload_URLMap = StringSplit($aDownload_URLMap[0], ",")
 
Local $sDownload_Link = _Download_fmtstream_GetOriginalLink($aDownload_URLMap)
If $sDownload_Link = "" Then
    ConsoleWrite("!>Original link NOT available" & @CrLf)
    Exit 1
EndIf
ConsoleWrite($sDownload_Link & @CrLf)
 
;~ ConsoleWrite("Downloading..." & @CrLf)
;~ Local $hDownload_1 = InetGet($sDownload_Link, $sDownload_VideoID & ".mp4")
;~ InetClose($hDownload_1)
 
Func _Download_fmtstream_GetOriginalLink($aFmtstream)
    Local $aParamOrder[20] = ["url", "gcr", "upn", "source", "key", "mv", "cp", "ip", "expire", "ratebypass", "mt", "itag", "sparams", "ms", "ipbits", "sver", "fexp", "id", "sig"]
    Local $aParam = 0, $sFmtDecoded = ""
 
    For $i = 1 To $aFmtstream[0]
        $aFmtstream[$i] = _UnicodeURLDecode($aFmtstream[$i])
 
        $aParam = StringRegExp($aFmtstream[$i], "([^?&=]+)=([^?&]*)", 3)
 
        For $j = 0 To UBound($aParamOrder) - 1
            For $k = 0 To UBound($aParam) - 1 Step 2
                If $aParam[$k] <> $aParamOrder[$j] Then ContinueLoop
 
                If $j = 0 Then
                    $sFmtDecoded = $aParam[$k + 1] & "?"
                Else
                    If $aParam[$k] = "itag" And $aParam[$k + 1] <> $sFmtOriginal Then
                        $sFmtDecoded = ""
                        ExitLoop 2
                    ElseIf $aParam[$k] = "sig" Then
                        $aParam[$k] = "signature"
                    EndIf
 
                    $sFmtDecoded &= $aParam[$k] & "=" & $aParam[$k + 1] & "&"
                EndIf
 
                ExitLoop
            Next
        Next
 
        Return StringTrimRight($sFmtDecoded, 1)
    Next
EndFunc
 
; #FUNCTION# ====================================================================================================================
; Name...........: _UnicodeURLDecode
; Author ........: Dhilip89
; ===============================================================================================================================
Func _UnicodeURLDecode($toDecode)
    Local $strChar = "", $iOne = 0, $iTwo = 0
    Local $aryHex = StringSplit($toDecode, "")
 
    For $i = 1 To $aryHex[0]
        If $aryHex[$i] = "%" Then
            $i = $i + 1
            $iOne = $aryHex[$i]
            $i = $i + 1
            $iTwo = $aryHex[$i]
            $strChar = $strChar & Chr(Dec($iOne & $iTwo))
        Else
            $strChar = $strChar & $aryHex[$i]
        EndIf
    Next
 
    $strChar = StringReplace($strChar, "+", " ")
    $strChar = StringReplace($strChar, "%3A", ":")
    $strChar = StringReplace($strChar, "\/", "/")
    $strChar = StringReplace($strChar, "\u0026", "&")
 
    Return BinaryToString(StringToBinary($strChar), 4)
EndFunc
Br, FireFox.

 

 

*.* Epic thanks!!

  • 3 years later...
Posted (edited)

Copy the link form YouTube or Facebook and paste it to <snip> or <snip> program, it will be automatically downloaded to your computer.  It doesn't matter what resolution you want, it can do it all. 

Edited by JLogan3o13
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...