Sign in to follow this  

Youtube url detector

Youtube url detector


Requested by H0LLYWOOD



Remote script for a bot that will resolve valid Youtube links and return the title and some other information about the video to channels the script is turned on for.





Copy this code, paste it to a new remote and save with a unique filename.

Type +ytdetect in each channel you want the script to run in.(Requires Ops or higher)

-ytdetect to turn the script off for a channel.







>;YouTube Link detector by Ford_Lawnmower #Script-Helpalias -l GetLinkDetectorForYoutube {  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Start Setup;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  ;;;; Change %tagcolor to the color you want for tags:  var %tagcolor $+($chr(15),$chr(2))  ;;;; Change %textcolor to the color you want for normal text  var %textcolor $+($chr(15),$chr(3),04)  ;;;; Change %logo to change the YouTube logo  var %logo $+($chr(2),$chr(3),01,$chr(44),00You,$chr(3),00,$chr(44),04Tube,$chr(2))  ;;;; Change %tagSelection to choose the tags you want displayed.  ;;;; Valid tags are: title views likes dislikes uploader and date   var %tagSelection title views likes dislikes uploader date  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;End Setup;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  var %sockname $+(LinkDetectorForYoutube,$network,$2,$ticks,$r(1,1000))  hadd -m %sockname tags %tagSelection  hadd %sockname tagcolor %tagcolor  hadd %sockname textcolor %textcolor  hadd %sockname logo %logo  sockopen %sockname 80  sockmark %sockname $1-2 $+(/watch?v=,$3)}menu Channel,Status {  .$iif($group(#LinkDetectorForYoutube) == On,$style(1)) LinkDetectorForYoutube  ..$iif($group(#LinkDetectorForYoutube) == On,$style(2)) On: .enable #LinkDetectorForYoutube  ..$iif($group(#LinkDetectorForYoutube) == Off,$style(2)) Off: .disable #LinkDetectorForYoutube}#LinkDetectorForYoutube onOn $*:Text:/(^[\+-])ytdetect$|(http\x3a\/\/|www\.)[\S]*[\S]+\=([\w\d-\S]{11})/Si:#: {  var %action $strip($regml(1)), %id $strip($regml(2))  if (%action isin +-) && ($regex($nick($chan,$nick).pnick,/(!|~|&|@)/)) {    if (%action == +) {      if ($istok(%LinkDetectorForYoutubeChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is already running the LinkDetectorForYoutube script }      else {         .enable #LinkDetectorForYoutube        set %LinkDetectorForYoutubeChanList $addtok(%LinkDetectorForYoutubeChanList,$+($network,$chan),32)        .msg $chan $nick has activated the LinkDetectorForYoutube script for $chan .      }    }    else {      if (!$istok(%LinkDetectorForYoutubeChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is not running the LinkDetectorForYoutube script }      else {         Set %LinkDetectorForYoutubeChanList $remtok(%LinkDetectorForYoutubeChanList,$+($network,$chan),1,32)        .msg $chan $nick has deactivated the LinkDetectorForYoutube script for $chan .       }    }  }  elseif (!$timer($+(LinkDetectorForYoutube,$network,$nick))) && ($istok(%LinkDetectorForYoutubeChanList,$+($network,$chan),32)) {    .timer $+ $+(LinkDetectorForYoutube,$network,$nick) 1 4 noop    GetLinkDetectorForYoutube .msg # %id  }}#LinkDetectorForYoutube endOn *:sockopen:LinkDetectorForYoutube*: {  if (!$sockerr) {    sockwrite -nt $sockname GET $gettok($sock($sockname).mark,3,32) HTTP/1.0    sockwrite -n $sockname Host: $sock($sockname).addr    sockwrite -n $sockname $crlf  }  else { sockclose $sockname | return }}On *:sockread:LinkDetectorForYoutube*: {  if ($sockerr) { sockclose $sockname | return }  else {    var %LinkDetectorForYoutube | sockread %LinkDetectorForYoutube    if ($regex(%LinkDetectorForYoutube,/(.*?).*(.*?)/)) {       hadd $sockname likes $+($hget($sockname,tagcolor),Likes:) $+($hget($sockname,textcolor),$regml(1))       hadd $sockname dislikes $+($hget($sockname,tagcolor),Disikes:) $+($hget($sockname,textcolor),$regml(2))      if ($hget($sockname,tags)) $gettok($sock($sockname).mark,1-2,32) $hget($sockname,logo) $Xchr($regsubex($v1,/([\S]+)/g,$hget($sockname,\t)))      if ($hget($sockname)) hfree $sockname      sockclose $sockname    }    elseif ( isin %LinkDetectorForYoutube) hadd $sockname viewsFound 1    elseif ($hget($sockname,viewsFound)) && ($regex(%LinkDetectorForYoutube,/(.*?)/)) {      hadd $sockname viewsFound 0      hadd $sockname views $+($hget($sockname,tagcolor),Views:) $+($hget($sockname,textcolor),$regml(1))     }    elseif ($regex(%LinkDetectorForYoutube,/(.*?).*class="watch-video-date"\s>(.*?)/)) {      hadd $sockname uploader $+($hget($sockname,tagcolor),Uploader:) $+($hget($sockname,textcolor),$regml(1))      hadd $sockname date $+($hget($sockname,tagcolor),Upload Date:) $+($hget($sockname,textcolor),$regml(2))    }    elseif ($regex(%LinkDetectorForYoutube,/class="long-title".*title="(.*?)">/)) {      hadd $sockname title $+($hget($sockname,tagcolor),Title:) $+($hget($sockname,textcolor),$regml(1))    }    elseif ($regex(%LinkDetectorForYoutube,//)) {      hadd $sockname title $+($hget($sockname,tagcolor),Title:) $+($hget($sockname,textcolor),$regml(1))    }  }}on *:sockclose:LinkDetectorForYoutube*: if ($hget($sockname)) hfree $socknamealias -l Xchr {   var %return $regsubex($regsubex($1-,/([A-F0-9]{1,2});/g,$chr($base($regml(\n),16,10))),/([0-9]{2});/g,$chr(\1))   return $replacecs(%return,–,–,·,·,»,»,«,«,Ü,Ü,ü,ü,Á,Á,á,á,É,$&    É,é,é,Í,Í,í,í,Ó,Ó,ó,ó,Ñ,Ñ,ñ,ñ,Ú,Ú,ú,ú, ,$chr(32),$&    æ,æ,",")} 

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

Sign in to follow this