mIRC Home    About    Download    Register    News    Help

Print Thread
Youtube video information #268629 29/03/21 12:07 PM
Joined: Jan 2021
Posts: 7
T
turbosmurfen Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Jan 2021
Posts: 7
So I have been trying with all different ways to read YouTube video information.
My conclusion is that I need to read from "www.googleapis.com" and retrieve information with API key.
I have seen another post on this forum about this, and he could fix the problem but this was from 2014.
I can use this api when i use my webbrowser, but not in mIRC.

Here is my example Script I'm trying to test with. But always return 3 or 404 from the site.
Example: /youtube https://www.youtube.com/watch?v=5wb5HWVh6Fs
And this would return the video title, likes and such.
Code
alias youtube {
  if (https://www.youtube.com isin $1-) {
    set %linked $remove($wildtok($1-,$ifmatch $+ *,1,32),https://)
    set %apikey = X
    sockopen -e ytube www.googleapis.com 80
  }
}
on *:sockopen:ytube:{ 
  if (!$sockerr) {
    sockwrite -n $sockname GET $+(/youtube/v3/videos?id=,$remove($gettok(%linked,2-,47),watch?v=),&key=,%apikey,&fields=items(id,snippet(channelId,title,categoryId),statistics)&part=snippet,statistics) HTTP/1.1
    sockwrite -n $sockname Host: www.googleapis.com
    sockwrite -n $sockname $crlf
  }
  else {
    echo -a $sockerr
    sockclose $sockname
    halt
  }
}

on *:sockread:ytube:{

  if ($sockerr) { echo -a $sockerr | sockclose $sockname | return }
  else {
    var %check | sockread %check
    while ($sockbr) {
      echo -a %check
      sockread %check
    }
  }
}

Last edited by turbosmurfen; 29/03/21 12:14 PM. Reason: webbrowser works
Re: Youtube video information [Re: turbosmurfen] #268630 29/03/21 05:41 PM
Joined: Jan 2004
Posts: 1,319
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,319
/sockopen -e should be used with port 443

Re: Youtube video information [Re: Loki12583] #268631 30/03/21 12:57 AM
Joined: Jan 2021
Posts: 7
T
turbosmurfen Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Jan 2021
Posts: 7
Originally Posted by Loki12583
/sockopen -e should be used with port 443

Thanks. I also found out that I have been using the apikey as set %apikey = key.
I guess I used another language than MSL. Changed to %apikey apikey, worked lol.