Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; *************** YOUTUBE Title *****************
- ; How to install:
- ; - Save this as a ".mirc" script file and run /load on it (see mIRC help).
- ; - Or, browse "Tools > Scripts Editor" select the "Remote" tab,
- ; "File > New...", paste these contents and save it anywhere
- ;
- ; How to use:
- ; - Set %eccol to an echo color of your choice (mine is 14).
- ; - Do nothing, it will already display every youtube link's video title
- ; for you.
- ; - However, if you want to announce this fancy title to everyone else,
- ; just add the channel you want it to announce to to a global "%ytannounce"
- ; variable. Multiple channels are separated by ... anything (I'm using spaces).
- ; - If there for some reason is another bot on a channel announcing stuff like
- ; this, add it to a global "%ytnodisplay" variable, same rules apply.
- ;
- ; 2013-06-16, FichteFoll
- ; (and some other guy I don't know because I found this somewhere)
- ; ***********************************************
- #youtube on
- on *:INPUT:*: {
- $on_yt_say($chan,$1-)
- }
- on *:TEXT:*:*: {
- $on_yt_say($chan,$1-)
- }
- alias -l on_yt_say {
- var %chan = $1
- if (%chan isin %ytnodisplay) return
- ; $regml(1): host (youtube.com/..., youtuberepeat.com/... or youtu.be/); $regml(2): id
- noop $regex($strip($2-),.*(youtube(?:repeat)?\.(?:com|de)\/(?:watch\/?\?(?:[\w_]+?=[-\w+%_]*?&)*?v=|v\/)|youtu.be\/)([-\w_|~]{11}).*)
- if ($regml(0) == 0) return
- ; vars for later callbacks
- set %youtubechan %chan
- set %youtubeerr $true
- set %youtubemsg $false
- var %youtubeid = $regml(2)
- if (%chan isin %ytannounce) set %youtubemsg $true
- ; this one does not work, don't ask me why
- if (%chan isin %ytspecialonly and $regex($regml(1),youtu\.be)) set %youtubemsg $true
- ; open the socket
- if (!$sock(youtube)) {
- sockopen youtube www.youtube.com 80 | sockmark youtube $+(#,>,%youtubeid)
- }
- }
- on *:sockopen:youtube: {
- sockwrite -n $sockname GET $+(/watch?v=,$gettok($sock(youtube).mark,2,62)) HTTP/1.0
- sockwrite -n $sockname Host: www.youtube.com
- sockwrite -n $sockname $crlf
- }
- on *:sockread:youtube: {
- var %x | sockread %x
- if ($regex(%x,<meta name="title" content="([^\"]+)">)) {
- set %youtubetitle $regml(1)
- set %youtubeerr $false
- ;set %youtubetitle $replace($regml(1),&,&,",")
- ;$regex(%youtubetitle,&#(\d*?);)
- ;var %i = 1
- ;while ($regml(%i) != $null) {
- ;%youtubetitle = $replace(%youtubetitle,&# $+ $regml(%i) $+ ;,$chr(%i))
- ;inc %i
- ;}
- }
- ;elseif ($regex(%x,<strong class="watch-view-count">(.+)</strong><br>)) set %youtubeviews $regml(1)
- ;elseif ($regex(%x,<span class="watch-video-date">(.+)</span>)) set %youtubedate $regml(1)
- ;elseif ($regex(%x,<div class="action-bar-ratings-stats yt-uix-tooltip" title="(.+)"> )) set %youtuberating $regml(1)
- ;elseif ($regex(%x,<a id="watch-username" class="inline-block" href="/user/(.+)">)) set %youtubeuser $regml(1)
- }
- on *:sockclose:youtube: {
- ;msg #CHANNEL $chr(91) $+ YouTube $+ $chr(93) " $+ %youtubetitle $+ " --- %youtubeviews views $&
- ; ( %youtuberating ) uploaded %youtubedate by %youtubeuser ---
- ;if ($chan isin %ytspecialonly and !$isunicode(%youtubetitle)) halt
- if (%youtubeerr == $false) {
- if (%youtubemsg == $true) {
- msg %youtubechan 5[YouTube-Title] $+ %youtubetitle $+
- }
- else {
- echo %eccol %youtubechan [YouTube-Title] $+ %youtubetitle $+
- }
- }
- else {
- echo %eccol %youtubechan --- [YouTube-Title not found]
- }
- ;unset %youtube*
- }
- #youtube end
- ; ************************************************
Advertisement
Add Comment
Please, Sign In to add comment