Bou Posted January 12, 2017 Share Posted January 12, 2017 Hello guys I got this script that u just enter the youtube channel u want and it will write the videos names in a notepad. However, it only writes like 10 --15 videos from a given page.... is there a way to make it read the whole page then extract the names from it ? #include<string.au3> $channel = InputBox("Channel","Enter a Youtube channel") $source = BinaryToString(InetRead($channel,1)) $fir = _StringBetween($source,'spf-link yt-ui-ellipsis yt-ui-ellipsis-2" dir="ltr" title="', '" aria-describedb') Run('notepad.exe') WinWait('Untitled - Notepad') for $a in $fir ControlSend('Untitled - Notepad' ,"" ,"",$a & @CRLF ) Next Thanks Link to comment Share on other sites More sharing options...
Bou Posted January 12, 2017 Author Share Posted January 12, 2017 i have been trying it on this channel " https://www.youtube.com/user/LinusTechTips/videos " Link to comment Share on other sites More sharing options...
genius257 Posted January 13, 2017 Share Posted January 13, 2017 Have you looked at the YouTube API? https://developers.google.com/youtube/v3/guides/implementation/videos#videos-retrieve-uploads I would suggest using "winhttp.winhttprequest.5.1" for the requests and "ScriptControl" for parsing the JSON. Bou 1 My highlighted topics: AutoIt Package Manager, AutoItObject Pure AutoIt, AutoIt extension for Visual Studio Code Github: AutoIt HTTP Server, AutoIt HTML Parser Link to comment Share on other sites More sharing options...
Bou Posted January 13, 2017 Author Share Posted January 13, 2017 Thanks. but i want to do the work with Autoit, as i have more uses for the script rather than just getting a specific playlist videos names. So, any ideas whats the script missing?! Link to comment Share on other sites More sharing options...
genius257 Posted January 14, 2017 Share Posted January 14, 2017 1 hour ago, Bou said: Thanks. but i want to do the work with Autoit, as i have more uses for the script rather than just getting a specific playlist videos names. So, any ideas whats the script missing?! My suggestions are for AutoIt. the two suggestions is used with ObjCreate. Bou 1 My highlighted topics: AutoIt Package Manager, AutoItObject Pure AutoIt, AutoIt extension for Visual Studio Code Github: AutoIt HTTP Server, AutoIt HTML Parser Link to comment Share on other sites More sharing options...
Bou Posted January 14, 2017 Author Share Posted January 14, 2017 could you please tell me how my code will be ? Link to comment Share on other sites More sharing options...
genius257 Posted January 14, 2017 Share Posted January 14, 2017 12 minutes ago, Bou said: could you please tell me how my code will be ? Here's some code to get you started. You still need to get an API key. Follow the instructions here: https://developers.google.com/youtube/v3/getting-started $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oSC = ObjCreate("ScriptControl") $oSC.language = "JScript" $oSC.Eval("Array.prototype.Item=function(i){return this[i];};") $YT_API_Key = "" $oHTTP.Open("GET", "https://www.googleapis.com/youtube/v3/channels?part=contentDetails&forUsername=LinusTechTips&key="&$YT_API_Key, False) $oHTTP.Send() $oJSON = $oSC.Eval("(" & $oHTTP.responseText & ")") If $oHTTP.status <> 200 Then MsgBox(0, "Error ("&$oHTTP.status&")", "Domain: "&Execute("$oJSON.error.errors.Item(0).domain")&@CRLF&"Reason: "&Execute("$oJSON.error.errors.Item(0).reason")&@CRLF&"Message: "&Execute("$oJSON.error.errors.Item(0).message")) Else $YT_PL_ID = Execute("$oJSON.items.Item(0).contentDetails.relatedPlaylists.uploads") If $YT_PL_ID == "" Then Exit MsgBox(0, "", "Could not get playlist ID") $oHTTP.Open("GET", "https://www.googleapis.com/youtube/v3/playlistItems?part=snippet%2CcontentDetails%2Cstatus&playlistId=UUXuqSBlHAE6Xw-yeJA0Tunw&key="&$YT_API_Key, False) $oHTTP.Send() $oJSON = $oSC.Eval("(" & $oHTTP.responseText & ")") If $oHTTP.status <> 200 Then MsgBox(0, "Error ("&$oHTTP.status&")", "Domain: "&Execute("$oJSON.error.errors.Item(0).domain")&@CRLF&"Reason: "&Execute("$oJSON.error.errors.Item(0).reason")&@CRLF&"Message: "&Execute("$oJSON.error.errors.Item(0).message")) Else MsgBox(0, "", "page 1 of "&(Execute("$oJSON.pageInfo.totalResults")/Execute("$oJSON.pageInfo.resultsPerPage"))) $iLength = Execute("$oJSON.items.length") $iLength = ($iLength=="")?0:$iLength For $i=0 To $iLength $oItem = Execute("$oJSON.items.Item(0)") MsgBox(0, $i&" of "&$iLength, "Title: "&Execute("$oItem.snippet.title")) Next EndIf EndIf Bou 1 My highlighted topics: AutoIt Package Manager, AutoItObject Pure AutoIt, AutoIt extension for Visual Studio Code Github: AutoIt HTTP Server, AutoIt HTML Parser Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now