Jump to content

Recommended Posts

Posted

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 

Posted

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.

Posted

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?!

Posted
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.

Posted
12 minutes ago, Bou said:

could you please tell me how my code will be ? :sweating::sweating:

 

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

 

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.
×
×
  • Create New...