coding articles

YouTube Sockread Script for mIRC

reads title and posts moone.in link to the video

7157 Views



This mIRC script (MSL) calls any YouTube Video (youtube.com -.de -youtu.be -moone.in) and posts the title of the video on the triggered IRC channel. Just press "alt + r" and put the following code in a new file and hit save as. Easy as that!

;YouTube Info 1.3
;Originally by Neo Nemesis updated by Lightningsoul.com


alias youtube {
%ytube1 = $remove($1,http://,www.,youtube,.com)
sockopen youtube www.youtube.com 80
}
alias youtube2 {
%ytube1 = $remove($1,http://,www.,moone,.in/)
%ytube1 = /watch $+ %ytube1
sockopen youtube www.youtube.com 80
}
alias youtube3 {
%ytube1 = $remove($1,http://,youtu,.be/)
%ytube1 = /watch?v= $+ %ytube1
sockopen youtube www.youtube.com 80
}
on *:SOCKOPEN:youtube: {
sockwrite -n $sockname GET %ytube1 HTTP/1.1
sockwrite -n $sockname Host: www.youtube.com
sockwrite -n $sockname Connection: Keep-Alive
sockwrite -n $sockname Content-Type: text/html
sockwrite -n $sockname $crlf
}
on *:SOCKREAD:youtube: {
sockread %ytube2
if (%ytube2 == $null) && (%sockread == $null) {
msg %ytube3 1,0You0,4Tube15,1 Error receiving information.
set %sockread 1
}
elseif (%ytube2 == $null) && (%sockread != $null) { noop }
elseif (meta name="title" content=" isin %ytube2) {
%endtitle = $pos(%ytube2,/title>,1)
%starttitle = $pos(%ytube2,title>,1)
%inbetween = $calc(%endtitle - %starttitle)
if (%shitstop == 0) msg %ytube3 0,6moone11,1in 15,1 %moonelink
msg %ytube3 %ymoon 15,1 $htmlconv($mid(%ytube2,$calc(%starttitle + 6),$calc(%inbetween -16)))
}
}
on *:TEXT:*youtube*:#: {
%ytube3 = $chan
%ytube4 = 1
%ymoon = 1,0You0,4Tube
while ([ $chr(36) $+ [ %ytube4 ] ]) {
if (www.youtube.com/watch isin [ $chr(36) $+ [ %ytube4 ] ]) {
sockclose youtube
%clearurl = $replace($1,https,http)
youtube %clearurl
%ytlink = $gettok($1-,%ytube4,32)
%moonelink = $replace(%clearurl,www.youtube.com/watch,moone.in/)
%shitstop = 0
}
inc %ytube4
}
}
on *:TEXT:*moone.in*:#: {
%ytube3 = $chan
%ytube4 = 1
%ymoon = 0,6moone11,1in
while ([ $chr(36) $+ [ %ytube4 ] ]) {
if (moone.in/?v= isin [ $chr(36) $+ [ %ytube4 ] ]) {
sockclose youtube
youtube2 [ $chr(36) $+ [ %ytube4 ] ]
%shitstop = 1
}
inc %ytube4
}
}
on *:TEXT:*youtu.be*:#: {
%ytube3 = $chan
%ytube4 = 1
%ymoon = 1,0You0,4Tube
while ([ $chr(36) $+ [ %ytube4 ] ]) {
if (youtu.be/ isin [ $chr(36) $+ [ %ytube4 ] ]) {
sockclose youtube
youtube3 [ $chr(36) $+ [ %ytube4 ] ]
%ytlink = $gettok($1-,%ytube4,32)
%moonelink = $replace(%ytlink,youtu.be/,moone.in/?v=)
%shitstop = 0
}
inc %ytube4
}
}

Yes, I am proud of my shitty formatting and stupid variables. ;) Thanks again to Kati, #help.script (Quakenet) and Neo Nemesis for helping me do it and building it in the first place!


Links: related

Sunday 22nd of December 2013 at 23:23

Share




comments


No comments yet.


Name

Message

You can post URLs (will be clickable automatically) and images via the [img]http://picurl[/img] tag.

Calculate 7 minus 3 (Robot check)

Back to Top

show elements