Youtube Link Parser v0.2

By OrFeAsGr on Jun 10, 2016

SCRIPT ID: YOUTUBE-PARSER
Credits: Wikked ( irc.g0dz.net +6697 (SSL ONLY) ) | westor ( http://westor.ucoz.com )

This is the "classic" Youtube Link Parser IRC Script! It's ready! Just load it in a clean remote and it's ready to work!
Check my website! http://humanity.ucoz.com

v0.2 FIxed a bug where the video ID wasn't recieved right if there were more parameters like: ?t e.t.c
Thx to Candent for finding this obvious bug which somehow my silly mind ignored! :D

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;Youtube Link Parser! Credits to Wikked ( irc.g0dz.net +6697 (SSL ONLY) );;;;
;;;;;By OrFeAsGr: http://humanity.ucoz.com ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; http://hawkee.com/snippet/17106/ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;; v0.2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
on *:text:*:#: {
  if (!%YOUTUBE-PARSERversion) || (!%YOUTUBE-PARSERversion != v0.2) { set %YOUTUBE-PARSERversion v0.2 }
  tokenize 32 $strip($1-,burci)
  if (youtube.com isin $1-) { var %yt_t $gettok($gettok($1-,2,61),1,63) | set %yt_c # | _youtube %yt_t }
  if (youtu.be isin $1-) { var %yt_t $gettok($gettok($1-,3,47),1,63) | set %yt_c # | _youtube %yt_t }
}

on *:action:*:#: {
  tokenize 32 $strip($1-,burci)
  if (youtube.com isin $1-) { var %yt_t $gettok($1-,2,61) | set %yt_c # | _youtube %yt_t }
  if (youtu.be isin $1-) { var %yt_t $gettok($1-,3,47) | set %yt_c # | _youtube %yt_t }
}

alias _YouTube {
  sockclose $+(Ytb,.,$1)
  sockopen -e $+(Ytb,.,$1) www.googleapis.com 443
}
on *:sockopen:*: {
  if (Ytb* iswm $sockname) {
    if ($sockerr) { sockclose $sockname | halt }
    sockwrite -nt $sockname GET /youtube/v3/videos?id= $+ $remove($sockname,Ytb.) $+ &key=AIzaSyCzHxG53pxE0hWrWBIMMGm75PRHBQ8ZP8c&part=snippet,contentDetails,statistics,topicDetails HTTP/1.1
    sockwrite -nt $sockname Host: www.googleapis.com
    sockwrite -nt $sockname $crlf
  }
}
on *:sockread:*: {
  if (Ytb* iswm $sockname) {
    if ($sockerr) { return }
    var %read
    sockread -f %read
    while ($sockbr) {
      if (%read) {
        if ("title" isin $gettok(%read,1,32)) { set %yt_title $left($noqt($gettok(%read,2-,32)),-2) }
        if ("categoryId" isin $gettok(%read,1,32)) {
          var %a = $left($noqt($gettok(%read,2-,32)),-2)
          set %yt_category $replace(%a,1,Film & Animation,02,Autos & Vehicles,10,Music,15,Pets & Animals,17,Sports,18,Short Movies,19,Travel & Events,20,Gaming,21,Videoblogging,22,People & Blogs,23,Comedy,24,Entertainment,25,News & Politics,26,Howto & Style,27,Education,28,Science & Technology,29,Nonprofits & Activism,30,Movies,31,Anime/Animation,32,Action/Adventure,33,Classics,34,Comedy,35,Documentary,36,Drama,37,Family,38,Foreign,39,Horror,40,Sci-Fi/Fantasy,41,Thriller,42,Shorts,43,Shows,44,Trailers)
        }
        if ("viewCount" isin $gettok(%read,1,32)) { set %yt_views $left($noqt($gettok(%read,2-,32)),-2) }
        if ("likeCount" isin $gettok(%read,1,32)) { set %yt_likes $left($noqt($gettok(%read,2-,32)),-2) }
        if ("dislikeCount" isin $gettok(%read,1,32)) { set %yt_dislikes $left($noqt($gettok(%read,2-,32)),-2) }
        if ("channelTitle" isin $gettok(%read,1,32)) { set %yt_uploaded $left($noqt($gettok(%read,2-,32)),-2) }
        if ("duration" isin $gettok(%read,1,32)) { set %yt_duration $get_duration($left($noqt($gettok(%read,2-,32)),-1)) }
        if ("commentCount" isin $gettok(%read,1,32)) { 
          set %yt_comments $noqt($gettok(%read,2-,32))
          sockclose $sockname
          msg %yt_c ^ You0,4Tube14: 10Title14:11 %yt_title 14| 10Category14:11 %yt_category 14| 10Views14:11 $comma(%yt_views) 14| 10Likes14:9 $comma(%yt_likes) 14| 10Dislikes14:4 $comma(%yt_dislikes)] 14| 10Uploaded by14:11 %yt_uploaded 14| 10Duration14:11 %yt_duration 14| 10Comments14:11 $comma(%yt_comments)
          unset %yt_*
          return 
        }
      }
      sockread -f %read
    }
  }
}
alias get_duration {
  if (!$1) { return 0 }
  var %d = $1
  var %d = $remove(%d,P,T)
  var %d = $replacex(%d,W,wk $chr(32),D,days $chr(32),h,hrs $chr(32),M,mins $chr(32),S,secs)
  var %d = $duration(%d,3)
  var %dd = $duration(%d,3)
  return $iif(%dd,$v1,00:00:00)
}

alias get_date {
  if (!$1-) { return 0 }
  var %d = $1-
  var %d = $remove($replace(%d,$chr(84),$chr(32)),$chr(90))
  if (*.* iswm %d) {
    var %tmp_d = $gettok(%d,1,32)
    var %tmp_t = $remove($gettok(%d,2,32),.)
    var %d = %tmp_d $gettok(%tmp_t,1,58) $+ : $+ $gettok(%tmp_t,2,58) $+ : $+ $mid($gettok(%tmp_t,3,58),4)
  }
  var %d = $ctime($remove(%d,$chr(44)))
  var %d = $date(%d,ddd ddoo mmm yyyy HH:nn:ss)
  if (!$prop) { return %d }
  if ($prop) && ($prop == date) { return $iif(%d,$v1,0) }
  if ($prop) && ($prop == ctime) { return $iif($ctime(%d),$v1,0) }
}

alias -l comma {
  var %a, %b = $regsub($ticks,$1,/\G([+-]?\d+?)(?=(?:\d{3})++(?=\.\d++$|$))/g,\1 $+ $chr(44),%a)
  return %a
}

Do you want to help me make some money? You can do it without paying for nothing! Just visit my site http://humanity.ucoz.com ,turn off your ad blocker, watch an ad and turn it back on! You'll be giving me something less than a cent! Thanks!

Or do you want to donate some bucks because you like my scripts??? Visit https://www.paypal.me/OrFeAsGr
Thx! ^_^

Comments

Sign in to comment.
Candent   -  Feb 25, 2017

youtu.be using the time code, it does not work.
example: https://youtu.be/VBPibnMc1Wg?t=1m58s
https://youtu.be/koXEziPjJXk?t=30m47s
But i like this addon. I like the way it displays the information.
OrFeAsGr, maybe you fix it?

OrFeAsGr  -  Feb 28, 2017

Thanks for letting me know! I fixed this! You can copy & paste the script again and it will work!!!

Candent  -  Mar 03, 2017

Thank you, It works very well.

Candent  -  Mar 12, 2017

Hey,
If someone has two channels or more and uses a command /ame(amsg), it displays information in a one window.
I guess it can not be repaired?

OrFeAsGr  -  Mar 12, 2017

not sure, i'll check it out..

Sign in to comment

mja00   -  Jun 10, 2016

I did a little tweak to the message format.
http://pastebin.com/m4L5rcm4

OrFeAsGr  -  Feb 28, 2017

Sweet!

Sign in to comment

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.