Sign in to follow this  
chain

Youtube URL Checker

To use:
 

  • Copy this code and paste to a new file in wordpad or w/e *not notepad*
  • Save with a unique filename with the extension .tcl
  • Copy/Upload the .tcl file to your eggdrops scripts directory.
  • Add a line like this to your eggdrop.conf -:
    Code
     
    1
    source scripts/youtubeurl.tcl
     
     
     
  • Rehash or restart the eggdrop.
  • (In the Party Line) Type .chanset #ChannelName +youtubeURL
  • +/- youtubeURL as needed.


That's it. The script will respond in channels with the +youtubeURL flag.
See the top of the script to change the logo or text color.

 

 

 

 ####################################################################
## To use this script you must set channel flag +youtubeURL (ie .chanset #chan +youtubeURL) ##
##############################################################################################
##############################################################################################
##  ##                             Start Setup.                                         ##  ##
##############################################################################################
proc youtubesurl {nick host hand chan text} {
  if {[lsearch -exact [channel info $chan] +youtubeURL] != -1} {
## Change the characters between the "" below to change the logo shown with each result.    ##
    set youtubelogo "\002\00301,00You\00300,04Tube\002\017"
## Change the format codes between the "" below to change the color/state of the text.      ##
    set textf "\002\017"
 set tagcolor "\002"
##############################################################################################
##  ##                           End Setup.                                              ## ##
##############################################################################################
    set youtubecheck [regexp -all -nocase {(?:\/watch\?v=|youtu\.be\/)([\d\w-]{11})} $text match youtubeid]
    if {$youtubeid != ""} {
      set youtubesite www.youtube.com
      set youtubeurl "/watch?v=${youtubeid}"
   set youtubeviews ""
   set youtubedesc ""
   set youtubeuser ""
   set youtubelikes ""
   set youtubedislikes ""
   set youtubedate ""
      if {[catch {set youtubesock [socket -async $youtubesite 80]} sockerr]} {
        putlog "$youtubesite $youtubeurl $sockerr error"
        return 0
        } else {
        puts $youtubesock "GET $youtubeurl HTTP/1.0"
        puts $youtubesock "Host: $youtubesite"
        puts $youtubesock "User-Agent: Opera 9.6"
        puts $youtubesock ""
        flush $youtubesock
        while {![eof $youtubesock]} {
          set youtubevar " [gets $youtubesock] "
    if {[string match "*<span class=?watch-view-count*" $youtubevar]} {
      set youtubeviews "found"
    } elseif {[regexp -nocase {<title>(.*?)\s-\sYouTube<\/title>} $youtubevar match youtubedesc]} {
      set youtubedesc "${tagcolor}Title: ${textf}${youtubedesc}"
    } elseif {[regexp -nocase {attribution\scontent=(.*?)\%} $youtubevar match youtubeuser]} {
      set youtubeuser "${tagcolor}Uploader: ${textf}${youtubeuser}"
    } elseif {[regexp -nocase {dir="ltr">(.*?)<\/a><span class="yt-user-separator">} $youtubevar match youtubeuser]} {
      set youtubeuser "${tagcolor}Uploader: ${textf}${youtubeuser}"
          } elseif {[string match "found" $youtubeviews]} {
   set youtubeviews "${tagcolor}Views: ${textf}[string trimright [string trimleft ${youtubevar}]]"
    } elseif {[regexp -nocase {\"likes-count\">(.*?)<} $youtubevar match youtubelikes]} {
      set youtubelikes "${tagcolor}Likes: ${textf}${youtubelikes}"
    } elseif {[regexp -nocase {watch-video-date"\s>(.*?)<\/span>} $youtubevar match youtubedate]} {
      set youtubedate "${tagcolor}Uploaded: ${textf}${youtubedate}"
            putserv "PRIVMSG $chan :[yturldehex "${youtubelogo} ${youtubedesc} ${youtubeviews} ${youtubelikes} ${youtubedislikes} ${youtubeuser} ${youtubedate}"]" 
   close $youtubesock
   return 0
    } elseif {[regexp -nocase {\"dislikes-count\">(.*?)<} $youtubevar match youtubedislikes]} {
      set youtubedislikes "${tagcolor}Dislikes: ${textf}${youtubedislikes}"
          } elseif {[regexp {<\/body>} $youtubevar 1] != 0} {
              close $youtubesock
              return 0
            }
        }
        close $youtubesock
        return 0
      }
    }
  }
}
proc yturldehex {string} {
  regsub -all {[\[\]]} $string "" string
  set string [subst [regsub -nocase -all {\([0-9]{2});} $string {[format %c \1]}]]
  return [string map {" \"} $string]
}
proc yturlencode {instring} {
  return [subst [regsub -nocase -all {([^a-z0-9])} $instring {%[format %x [scan "\\&" %c]]}]]
}
bind pubm -|- "*youtube.*watch?v=*" youtubesurl
bind pubm -|- "*youtu.be/*" youtubesurl
setudef flag youtubeURL
putlog "\002*Loaded* \00301,00You\00300,04Tube\002\017 \002URL check V 00.01 by Ford_Lawnmower irc.GeekShed.net #Script-Help"

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