Jump to content

need help to do a youtube search using autoit

Recommended Posts

goodmorning; autoit team
please their are any youtube search way working?
because i was using the get source and split it to get the result but know it does not working any way.
is the youtube disabled that? and is their any other simple way to do that?
i tested all examples found in this post but also it don't work

and here is the example that i use to and it don't work any more

local $hSearchOpenHNDL, $hSearchConnect, $sSearchGet
local $a_UrlsArray[1][5]
local $b_ButtonsDisabled = false, $b_SearchBTNFocus = false, $b_SearchListFocus, $h_SearchFocusHND
local $Return = "0"
local $s_OpenStringY = "/feed/trending"
local $ChannelUrl = "", $channelName = ""
if Not ($a_YoutubeSearchArray[0][0] = 0) then
GUICtrlSetData($searchInp, $s_youtubeSearchLastSearch)
$s_OpenStringY = "/results?search_query=" & StringReplace(GUICtrlRead($searchInp), " ", "+")
$a_UrlsArray = $a_YoutubeSearchArray
for $i = 1 to $a_UrlsArray[0][0]
_GUICtrlListBox_AddString($SearchList, $a_UrlsArray[$i][0] & $a_UrlsArray[$i][2] & $a_UrlsArray[$i][3])
_GUICtrlListBox_SetCurSel($SearchList, $I_youtubeSearchLastIndex-1)
GUICtrlSetState($SearchList, $GUI_focus)
if Ping("youtube.com", 1000) > 1 then
$hSearchOpenHNDL = _WinHttpOpen('')
if not (@Error) then
$hSearchConnect = _WinHttpConnect($hSearchOpenHNDL, "youtube.com")
if Not (@Error) then
$sSearchGet = _WinHttpSimpleRequest($hSearchConnect, "get", $s_OpenStringY)
if not (@Error) then
local $a_strings = _StringBetween($sSearchGet, '<a href="/watch', "<ul")
local $title = ""
local $url = ""
local $length = ""
local $result = ""
GUICtrlSetData($SearchList, "")
ReDim $a_UrlsArray[1][5]
for $i = 0 to UBound($a_strings)-1
$url = _StringBetween($a_strings[$i], "?", '"')
if @error then ContinueLoop
$url = "https://www.youtube.com/watch?" & $url[0]
$title = _StringBetween($a_strings[$i], 'dir="', '</a>')
if @error then ContinueLoop
$title = $title[0]
$title = StringRegExpReplace($title, '(.*\"\>)', "")
if StringRegExp($a_strings[$i], '[0-9]{1,2}\:[0-9]{1,2}\:[0-9]{1,2}', 0) = 1 then
$length = StringRegExp($a_strings[$i], '[0-9]{1,2}\:[0-9]{1,2}\:[0-9]{1,2}', 2)
elseIf StringRegExp($a_strings[$i], '[0-9]{1,2}\:[0-9]{1,2}', 0) = 1 then
$length = StringRegExp($a_strings[$i], '[0-9]{1,2}\:[0-9]{1,2}', 2)
$length = ""
if IsArray($length) then
$length = ": (" & $length[0] & ")"
$length = ""
$ChannelUrl = stringRegexpReplace($a_strings[$i], '(^.*?<a.*?\"(\/user|\/channel))+', "$2")
$channelName = stringRegexpReplace($ChannelUrl, '(.*?\".*?>)(.*</a>)+', "$2")
$ChannelUrl = stringRegexpReplace($ChannelUrl, '(\".*)+', "")
$channelName = stringRegexpReplace($channelName, '(</a>.*)+', "")
$result &= $title & @crlf & $url & @crlf
ReDim $a_UrlsArray[UBound($a_UrlsArray)+1][5]
$a_UrlsArray[UBound($a_UrlsArray)-1][0] = $title
$a_UrlsArray[UBound($a_UrlsArray)-1][1] = $url
$a_UrlsArray[UBound($a_UrlsArray)-1][2] = $length
if not ($channelName = "") then $a_UrlsArray[UBound($a_UrlsArray)-1][3] = ", (" & $channelName & ")"
if not ($channelUrl = "") then $a_UrlsArray[UBound($a_UrlsArray)-1][4] = "https://www.youtube.com" & $channelUrl
$a_UrlsArray[0][0] = UBound($a_UrlsArray)-1
_GUICtrlListBox_AddString($SearchList, $a_UrlsArray[UBound($a_UrlsArray)-1][0] & $length & $a_UrlsArray[UBound($a_UrlsArray)-1][3])


i hope any one can help me

thanks in advance

Link to post
Share on other sites

hello again
i have read it
i tried this but it give me a error msg
can any one help please to solve it?


#include "WinHttp.au3"

; Open needed handles
Global $hOpen = _WinHttpOpen()
Global $hConnect = _WinHttpConnect($hOpen, "www.googleapis.com")
Global $s_Request = _WinHttpSimpleSSLRequest($hConnect, "Get", "/youtube/v3/search/?part=snippet&q=test&maxResults=50&type=video&ApiKey=xxxxxx")
if not (@error) then
FileWrite("result.txt", $s_Request)


Link to post
Share on other sites

thanks for your fast replys

here is the error message that i got

 "error": {
  "errors": [
    "domain": "usageLimits",
    "reason": "dailyLimitExceededUnreg",
    "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
    "extendedHelp": "https://code.google.com/apis/console"
  "code": 403,
  "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."

i tried to use key=
also i confirmed that the youtube api is enabled
i tried this with more than account and more than PC
the same result
i hope that i can find a way to do that simply

Link to post
Share on other sites

If you mean to get the links from the search results:

#Region ;Include + Opt
#include <IE.au3>
#include <ProgressConstants.au3>
Global $oIE, $Load = 0, $Failed = 0, $Visible = 0 ;Change to show or hide the IE window.
Global $oLinks, $iNumLinks, $sTxt, $PrevLink = ''
Func QuerySite($Name)
    $GMarquee = GUICreate("Working", 240, 70, -1, @DesktopHeight / 4)
    $Progress_1 = GUICtrlCreateProgress(10, 10, 220, 20, 0x0008)
    $LabelP = GUICtrlCreateLabel('Working...', 10, 40, 100)
    _ProgressMarquee_Start($Progress_1) ;Start
    $oIE = _IECreate("https://www.youtube.com/results?search_query=" & $Name, 0, $Visible, 0, 0)
    If $oIE <> @error Then
            $oLinks = _IELinkGetCollection($oIE)
            For $oLink In $oLinks
                If StringInStr($oLink.href, 'youtube.com/watch?v=') <> 0 Then
                    If $oLink.href <> $PrevLink Then
                    ConsoleWrite($oLink.href & @CRLF)
                    $PrevLink = $oLink.href
                If StringInStr($oLink.href, 'reporthistory') <> 0 Then
                    ConsoleWrite('Found "about" link'&@CRLF)
                    $Load = 1
        Until $Load = 1
        _ProgressMarquee_Stop($Progress_1) ;Stop
        MsgBox(64 + 262144, 'Failed', 'Error:' & @error & ' in: _IECreate')
    _ProgressMarquee_Stop($Progress_1) ;Stop
EndFunc   ;==>QuerySite
Func _ProgressMarquee_Start($iControlID)
    Return GUICtrlSendMsg($iControlID, $PBM_SETMARQUEE, True, 50)
EndFunc   ;==>_ProgressMarquee_Start
Func _ProgressMarquee_Stop($iControlID, $fReset = False)
    Local $fReturn = GUICtrlSendMsg($iControlID, $PBM_SETMARQUEE, False, 50)
    If $fReturn And $fReset Then
        GUICtrlSetStyle($iControlID, $PBS_MARQUEE)
    Return $fReturn
EndFunc   ;==>_ProgressMarquee_Stop


Edited by careca

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples


Link to post
Share on other sites

thanks for your reply

am sorry for the dellay

i need to get also the the time, the channel name, the channel url.
by this way i can't get this informations
also i can not know why my test does not work, when i tried it using the browser all things work without any problem.
but when i do that using autoit it did not work.
the problem it was working for me before.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By CYCho
      This file includes the source code for zPlayer, which is a stand-alone, simple, intuitive and easy-to-use, yet fully functional media player.  I made this to suit my purpose and you can tweak it to your taste. The source code is only about 1600 lines and only standard #include files were used. Also included in the source code file are some image files which are used for drawing the graphical media controls in the main window.
      As of its release date, the compiled exe file of this player, as attached hereto, is not flagged by Windows Defender with latest Security Intelligence Update.
      Hash values for compiled file of the latest version are as follows:
      SHA256: ED6FA666192AD8420161BB3E082F7440886A5DFA9D258AFB54D486AEA2D9703B
      SHA1: 9F41B7B1E01DA66A0A1C59398769D5AEB26A62D6

      This player has the following features:
      - Play back all formats of media files which can be played back by the Windows Media Player in your computer
      - Depending on the file types specified by the user in zPlayer.ini file this player can be either audio only, video only or both.
      - Video window is independent of other windows and, when maximized, increases the immersion of the user
      - Graphical media controls similar to embedded Windows Media Player
      - Forward, backward, pause, repeat, shuffle function
      - Increase/decrease/mute sound volume
      - Change folders and create playlist for all media files in that folder and its subfolders, and support for manually-made playlists
      - Save play-back environment when terminating and resume that environment when restarting
      - 'Continue playback' option for a file you left off in the middle of playback
      - With one click, you can see internet search results for the file selected in playlist
      - With a double-click, you can play back an item in the playlist
      - Search strings in the playlist
      - Option to see long file names including folder names
      - View file properties for any file in the playlist and copy their values
      - Resize the playlist and video windows, and restore them to their default positions
      - Very small footprint: very low CPU and memory usage, with only about 1MB when compiled
      - You can even hide all the windows and manipulate the player with hotkeys only
      Note: zPlayer is the name I used when I introduced the early version of this player in my blog back in early 2009 and, therefore, has nothing to do with the mobile media player of the same name which started marketing in 2015.
    • By ghetek
      Hi everybody!
      Apache Solr is an awesome search server that allows you to search through petabytes of data in milliseconds. It is used by many large organizations. It's kind of like MySQL with search in mind. 
      If you would like to get started, download Apache Solr and run the example command, "bin/solr start -e techproducts"
      Now the example in the UDF should work. I am looking for any advice at all before I post this into the examples area.
      here is a walkthrough of what is happening in the example
      Func Example() Local $sHost = '', $sPort = 8983, $sContainer = 'techproducts', $sWow64 = "" If @AutoItX64 Then $sWow64 = "\Wow6432Node" Local $dir_autoit = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") Local $st_URL = 'http://' & $sHost & ':' & $sPort & '/solr/' & $sContainer ;First lets see if its running, start if it is not If _solr_Webping($st_URL) = -1 Then _solr_cmdstart($SOLR_HOME, $sContainer) ;Enable stream overlay so that we can send commands via URL _solr_enablestreamoverlay($st_URL) ;delete the example data _solr_Webdelall($st_URL, True) ;Lets define some values for a document Local $aPairs[5][2] = [ _ [4, Default], _ ['literal.id', 5], _ ['literal.value_s', 'anything'], _ ['literal.resourcename', 'API Errors Constants'], _ ['literal.indextime_dt',_solr_tnow()]] ;now package up the document with the values _Solr_uploadPkg($dir_autoit & '\Include\APIErrorsConstants.au3', $st_URL, $aPairs, Null, 'commit=true&overrideLiterals=true') ;whoops, lets make a change to a single field _solr_Webupdate($st_URL, '[{"id":"' & 5 & '","value_s" : {"set":"something"}}]') ;and commit that change _solr_Webcommit($st_URL) ;we can also upload files from the SimplePostTool _solr_jarpost($SOLR_HOME & '\example\exampledocs\post.jar', $sContainer, $dir_autoit & '\Include\GuiListView.au3', 'literal.id=6&literal.cat=Help Files&commit=true') ;now we can query for something Local $qry_response = _solr_Webselect($st_URL, 'q=$ERROR_VOLSNAP_PREPARE_HIBERNATE') Local $json_response = Json_Encode($qry_response) json_dump($json_response) ConsoleWrite(json_get($qry_response, '.response.docs[0].content[0]') & @CRLF) EndFunc ;==>Example  
      Thank you for your time!
      solr.au3 Json.au3 BinaryCall.au3
    • By CYCho
      zPlayer is the name I used when I introduced the early version of this player in my blog back in early 2009 and, therefore, has nothing to do with the mobile media player of the same name which started marketing in 2015.
      After I retired from active duty in 2002 I spent much time listening to music. First I started with CD's and LP's, then quickly moved on to mp3 files. I converted many of my CD's to mp3 and I collected many more from various sources which were freely available at the time. As the number of my mp3 files grew, I put them in folders according to their genres and my favorite classifications. I mainly used Windows Media Player to listen to them and I slowly began to dislike wmp because it had massive user interface while I just wanted to listen to music in the background while I was doing other work in the foreground, hopping between folders from time to time. It was the time I was beginning to learn AutoIt and I thought I should make my own player with AutoIt. Coming from a sales career with no experience in programming, it was not an easy task. Somehow, after about 2 years of learning and trying, I had my own audio player which worked with only hotkeys without any graphical interface. I gave it to some of my friends who were not as computer-savvy as I. They liked it but definitely wanted something to clcik with mouse. So I came up with very rude gui which took a form similar to what it is now.
      The attached source files include one au3 file, one icon file and 14 jpg files. The jpg files are used for drawing a graphical player and are fileinstalled in @DocumentsCommonDir folder. This player uses WMPlayer.OCX as its engine and supports all audio file formats supported by wmp and additional codecs installed. I would like to thank @Bilgus for kind answers to my questions and would appreciate it if anyone could review the code and give me any suggestion. This player works for me, but I don't know whether the code is presentable as an example. I am posting this here with a hope to learn much from AutoIt community.
      PS: Video function was added in August 2020. 
      Please see Downloads section of this forum for the latest version of this player.

    • By nacerbaaziz
      hello autoit team
      please i need your help
      i found that the youtube provide a way to get any video informations with this link
      but it incoded i can not read it
      can any one tell me how to decode that please?
    • By FengHuangWuShen
      So I was playing with INet and downloading files and made a simple video downloader, or it can even be used for any file really.
      Just follow the reference section in INet_Settings.ini , and then run the script.
      Main Script <snip>
      INet_Settings.ini  URL - The target URL of the video you're trying to grab Data - This is the starting string, and ending string reference to look for the download URL itself. Settings - Only setting here currently, is the delay in which to wait for the file to download ### Reference for Start and End points for various websites <snip>
      Credits to : https://www.autoitscript.com/forum/profile/31965-progandy/  for the URL Encode and Decode.
  • Create New...