Jump to content
nacerbaaziz

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
https://www.autoitscript.com/forum/topic/123945-youtube-search/

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])
next
_GUICtrlListBox_SetCurSel($SearchList, $I_youtubeSearchLastIndex-1)
GUICtrlSetState($SearchList, $GUI_focus)
else
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)
else
$length = ""
endIf
if IsArray($length) then
$length = ": (" & $length[0] & ")"
else
$length = ""
endIf
$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])
next
endIf
endIf
endIf
endIf
endIf

 

i hope any one can help me

thanks in advance

Share this post


Link to post
Share on other sites

hello again
please
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
FileDelete("result.txt")
FileWrite("result.txt", $s_Request)
ShellExecute("result.txt")
endIf
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)

 

Share this post


Link to post
Share on other sites

hello
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

Share this post


Link to post
Share on other sites
Posted (edited)

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 = ''
;=============================================================================
QuerySite('chillstep')
;=============================================================================
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)
    GUISetState(@SW_SHOW)
    _ProgressMarquee_Start($Progress_1) ;Start
    ;=============================================================================
    $oIE = _IECreate("https://www.youtube.com/results?search_query=" & $Name, 0, $Visible, 0, 0)
    If $oIE <> @error Then
        Sleep(2000)
        Do
            $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
                    EndIf
                EndIf
                If StringInStr($oLink.href, 'reporthistory') <> 0 Then
                    ConsoleWrite('Found "about" link'&@CRLF)
                    $Load = 1
                    ExitLoop
                EndIf
            Next
            Sleep(100)
        Until $Load = 1
    Else
        _ProgressMarquee_Stop($Progress_1) ;Stop
        GUIDelete($GMarquee)
        MsgBox(64 + 262144, 'Failed', 'Error:' & @error & ' in: _IECreate')
        _IEQuit($oIE)
    EndIf
    _ProgressMarquee_Stop($Progress_1) ;Stop
    GUIDelete($GMarquee)
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)
    EndIf
    Return $fReturn
EndFunc   ;==>_ProgressMarquee_Stop
;=============================================================================

 

Edited by careca

Spoiler

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

Au3Record.exe

Share this post


Link to post
Share on other sites

@careca
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.
 

Share this post


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 all the source codes and a compiled .exe version of 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 1200 lines and only standard include files were used.
      zPlayer was my first AutoIt project through which I was hoping to learn coding. A media player capable of playing back audio and video files was my initial goal, but video was beyond my capcity for my lack of coding experience. So zPlayer was born as an audio-only player and remained so up to Version 2.0.1.5.
      Just recently I decided to add video function to zPlayer now that I had gained some experience. I thought it would be possible, but I didn't expect it to be this simple. I made minimal changes to the existing code and added only about 80 lines and, voila, I have an integrated audio and video player, starting from Version 3.0.0.1.
      This player has the following features:
      - Play back all formats of media files which can be palyed back by the Windows Media Player in your computer
      - Video window is independent of other windows and, when it is maximized, increases the immersiveness of the user
      - Graphical player similar to embedded Windows Media Player
      - Forward, backward, pause, repeat, shuffle funtion
      - 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
      - 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
      - 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 palyer 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 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.
    • By UEZ
      AutoIt Windows Screenshooter
      Key Features:
      takes easily a screenshot from any visible window capture any region of the desktop incl. freehand capturing capture GUI controls and GUI menus separately capture a marked area every x seconds for a duration of y seconds create a GIF animation from saved frames (Vista or higher os required) capture to AVI file (without audio!) takes a screenshot from web sites (available only on Win7+ os and when Aero is enabled) put images to clipboard to paste to other applications easily color picker save image in different formats and also to PDF! add timestamp to saved images simple image editing options: greyscale, b&w, invert, rotate +-90° send image to printer and default email client preview of captured screens incl. zoom option multi monitor support display pixel color under mouse ruler basic image editor (paint, highlight, ellipse, rectangle, text and some graphic FX) watermark captured image no 3rd party tools or DLLs used - pure AutoIt! fully portable - no installation is needed multi language feature (Eng, Ger, Tur, Fra and Rus only) drag'n'drop an image to the app for editing To do:
      capture content of scrollable window/control capture cascaded menus Due to DllCall("User32.dll", "int", "PrintWindow", "hwnd", $hWnd, "handle", $hMemDC, "int", 0) limitation some windows cannot be captured properly (GDI+, ProgDVB, etc.) but can take screenshots of hidden windows. One workaround is to use full screen capturing (F11/F12) or "Grab Screen" function! Or try double click with rmb on listview items (beta).
      Download source code (10489 downloads previously): AutoIt Windows Screenshooter v1.84 Build 2019-08-18.7z (version 3.3.12.0+ needed!)
      You are not allowed to sell this code or just parts of it in a commercial project or modify it and distribute it with a different name!
      Download compiled Exe only: 4shared / Media Fire  / Softpedia (1.58mb)
      Distributing copies of the program in compiled format (exe) must be free of any fee!
      -----> click here to Donate!  
      (Current donators: 1. Cuong N.) 
       
       
      It is designed for Win7+ operating systems with AERO enabled! E.g. on WinXP machines some functions are not working properly and might crash the application!
      AV scanners may have a negative impact the execution of compiled exe and might report any malware. I guarantee that there is no malicious code in the source code / exe!!! 
      Main GUI:

       
       
      About Intro:

       
       
      Basic Image Editor:

       
       
      Watermark:

       
       
      Click link for an enhanced version of Watermark Image.
      Credits:
      main code by UEZ additional code (alphabetical order) by Authenticity, AutoItObject Team, Eemuli, Eukalyptus, funkey, _Kurt, martin, monoceres, ProgAndy, taietel, trancexx, Ward, wolf9228 and Yashied! mesale0077 for turkish translation wakillon for french translation AZJIO for russian translation Keys:
      Main GUI:
      User your mouse to scroll preview window or
      Numpad 8: Scroll preview window up
      Numpad 2: Scroll preview window down
      Numpad 4: Scroll preview window left
      Numpad 6: Scroll preview window right
      Numpad +: zoom in preview window or mouse wheel down
      Numpad -: zoom out preview window or mouse wheel up
      F1: capture again on last position
      F5: refresh Windows Name list
      PRINTSCREEN: take screenshot from whole screen
      ALT+PRINTSCR: take a screenshot from active window
      F10: Undo made changes with Image Editing function
      F11: take screenshot from whole screen incl mouse cursor
      F12: take screenshot from whole screen
      Ctrl+Alt+F9 start "Grab Screen" mode
      Ctrl+Alt+F12: take a screenshot from active window using alternative screenshot functionality (beta)!
      Ctrl+r: call ruler
      Ctrl+s: save current displayed image
      Ctrl+x: exit program
      ctrl+w: call web grab input field (available only when Aero is enabled)
      Ctrl+i: call image editor
      Ctrl+m: call watermark editor
      Ctrl+z: undo
      Only available on Vista+ os: double click with rmb on list items to use alternative screenshot functionality (beta)!
      When 'Grab Screen' is clicked you can hold down the ctrl key to switch to 'grab controls' mode. Control under mouse will be framed red.
      ctrl + shift will take the screenshot of appropriate control. To capture GUI menus you can press rmb which simulates the lmb. When a menu is opened press shift additionally to capture it.
      Press and hold only the shift key to capture any region on the desktop using freehand capturing - release it so capture marked regions!
      Or just mark resize able area which you want to grab. Press CTRL key to grab marked area or right mouse button to capture the marked area every x seconds for a duration of y seconds.
      When saving the image just enter the extension you wish to use (*.jpg;*.png;*.bmp;*.gif;*.tif;*.pdf). Big thanks to taietel for his PDF UDF!
      Image Editor:
      s: save
      😄 copy
      n: send
      h: highlighter
      p: pen
      r: rectangle
      e: ellipse
      a: arrow
      o: color
      t: text
      g: text config
      Ctrl+z: undo
      Watermark editor:
      Ctrl+z: undo
       
      To start the app minimized just call it "Windows Screenshooter.exe /min"
      Maybe it is useful for someone...
      Any kind of comment is welcome.
      Br,
      UEZ
      Change log:
       


×
×
  • Create New...