YT to MP3/MP4 and captcha

09/26/2018 15:34 Szmycu#1
Inspired by this tutorial I wanted to make MP4 downloader too
How code looks in the beggining

PHP Code:
#include <_httprequest.au3>
#include <string.au3>
$url InputBox('YoububeToMp3','Type url video...')
if @
error Then Exit
YoububeToMp3($url)
Func YoububeToMp3($url,$dir=@ScriptDir,$type='mp3')
$id _StringBetween($url,'watch?v=','')[0]
$oIE _httprequest(2,'https://www.download-mp3-youtube.com/api/?api_key=MzQ3NzQzNDYz&format='&$type&'&video_id='&$id)
$link _StringBetween($oIE,'src="','"')[0]
$oIE _httprequest(2,$link)
$name _StringBetween($oIE,'<div class="buttonTitle">','</div>')[0]
$oIE =_StringBetween($oIE,'id="downloadButton" href="','"')[0]
$linkdowload 'https://www.convertmp3.io'&$oIE
ProgressOn
('''Downloading '&$name&'.'&$type'0%')
Local $BinaryData _HttpRequest(3$linkdowload''''''''''ProgressFunc)
If @
error Then
MsgBox
(16,'Error',"Couldn't download file!!")
   Exit
EndIf
ProgressOff()
_HttpRequest_Test($BinaryData$dir '\'&$name&'.'&$type,Default,False)
EndFunc
Func ProgressFunc($NowSize, $TotalSize)
$iPercent = Round(100 * $NowSize / $TotalSize, 2)
ProgressSet ($iPercent, $iPercent & '
%', 'Downloading...' & Round($NowSize / (1024 ^ 2), 2) & 'Mb')
EndFunc 
So I founded that site with MP4 API too. There is written how to make API link similar like above in script
Code:
https://lolyoutube.com
How could look example link for this API
Code:
https://lolyoutube.com/download/mp3/HLVjWH8deew/1537966320
so how code looks for lolyyoutube downloader
PHP Code:
 make request for the link
    $oIE 
_httprequest(2,'https://lolyoutube.com/download/' $format '/' $id '/' $timestamp)
    ; 
but there is no src attrib 
    $link 
_StringBetween($oIE,'src="','"')[0] ; iframe button with src attribute
    
so cant make http request to the link
    $oIE 
_httprequest(2,$link
as we can see button has no src attrib and I cant get link for this, its generated in Javascript and how to click that button?

Next is Recaptcha button too similar too this button

I tracked whats going on on and got something like that.

[Only registered and activated users can see links. Click Here To Register...]

how to click that captcha with autoit?

[Only registered and activated users can see links. Click Here To Register...]

see something here is like
Code:
 ; Click on ReCaptcha checkbox
        $idivs = _IETagNameGetCollection($iframe, 'div')
        For $idiv In $idivs
            If $idiv.classname = 'recaptcha-checkbox-checkmark' And $idiv.attributes.item('role').value="presentation" Then
                $idiv.click()
            EndIf
        Next
and it click captcha i saw but it has to open IE
09/28/2018 16:31 chronicles666#2
Why make your life harder trying to use such shoddy websites, when youtube-dl already exists and you can use that instead? [Only registered and activated users can see links. Click Here To Register...]
No captchas, no manual HTML parsing, etc. It's implemented in Python, and you can use it as a python library straight away, but if you (don't know/don't want to get to know) Python, then you can just call the youtube-dl script from AutoIt with Run, RunWait, and the likes.
It's going to be much easier to parse the output of this command and retrieve data of interest, eg. stream-specifiers.
You can download mp4 files straight away from YouTube, but as for mp3, YouTube doesn't use that format internally, so you either download audio encoded with Opus/AAC/Vorbis and use that, or if you really need mp3, you can transcode with ffmpeg like this:
Code:
ffmpeg -i input.m4a -c:a libmp3lame -q:a 2 output.mp3
For details, refer to the documentation of ffmpeg, which you can find here: [Only registered and activated users can see links. Click Here To Register...]
10/08/2018 22:33 Szmycu#3
gratefuly thanks