egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

ourtubeXTRA 1.0

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
WazzaUK
Voice


Joined: 02 Jul 2006
Posts: 19

PostPosted: Sun Jan 12, 2014 11:49 am    Post subject: ourtubeXTRA 1.0 Reply with quote

A rework of ourtube with extra data. Lots of new additions including URL detection. Also removed some of the original functionality such as ability to turn on/off color and multi/single line. Deals with utf-8 via encoding function, i think eggdrop has to be properly patched. I use 1.6.21 and works nicely.

To enable on channels , in dcc add user defined flag with:

.chanset #channel +ourtubeXTRA

or in the channel window:

/msg #channel !youtube enable

if a youtube URL is detected in channel, details are taken from youtube site. Videos can be searched for using:

!youtube <search criteria>

To enable on channels , in dcc add user defined flag with:

.chanset #channel +ourtubeXTRAsearch

or in the channel window:

/msg #channel !youtube enablesearch

Forgive the bad identation. Its perfect in my editor.

EDIT: now detects URLs in Title. Small modifiucation in how $data is set - no longer uses string map, afterall utf-8 decoding is done at time of output.
Parameters maxlen(max length of parsed text), color(00-15 - color of url) and styles(can be style_ul and/or style_bd) added to url_search proc. Called like:
Code:

set text_parsed [url_search 40 07 "style_ul" $text]

If incorrect string classes used/bad values default values should hopefully be set.
Now has 2 user defined channel flags:
ourtubeXTRA for youtube URL detection in a channel.
ourtubeXTRAsearch for youtube video searching.

Code:

setudef flag ourtubeXTRA
setudef flag ourtubeXTRAsearch

global ourtubeXTRA tcl_platform
     
#Flood Protection: after show a link, will ignore all links few seconds
# This means 1 link per 10 seconds.
set ourtubeXTRA(rest) 10
     
#What language you can receive the youTube data? (if works heh)
set ourtubeXTRA(lang) en
     
#Limit of links at same time
set ourtubeXTRA(max) 5
     
#youtube logo
set ourtubeXTRA(youtubelogo) "\002\00304,00You\00300,04Tube\017"
         
set ourtubeXTRA(output) "$ourtubeXTRA(youtubelogo) \00311::\00315 <title> \00311:: \00308Author: \00315<author> \00311:: \00308Added: \00315<added> \00311:: \00308Views: \00315<views> \00311:: \00308Duration: \00315<duration> \00311:: \00308Likes: \00309<likes> \00311:: \00308Dislikes: \00304<dislikes> \00311:: \00308Description: \00315<description>"
         
set ourtubeXTRA(outputsearch) "\00312\037<link>\003\037 \00311:: \00308Title: \00315<title> \00311:: \00308Author: \00315<author> \00311:: \00308Added: \00315<added> \00311:: ;\00308Views: \00315<views> \00311:: \00308Duration: \00315<duration> \00311:: \00308Description: \00315<description>"
         
set ourtubeXTRA(author) "WazzaUK"
set ourtubeXTRA(contact) "WazzaUK <wallison_uk@yahoo.co.uk>"
set ourtubeXTRA(originalauthor) "HackeMate"
set ourtubeXTRA(originalcontact) "HackeMate <Sentencia@eggdrop.es>"
set ourtubeXTRA(name) "ourtubeXTRA"
set ourtubeXTRA(projectName) "ourtubeXTRA"
set ourtubeXTRA(version) "1.0"
set ourtubeXTRA(package.http) [package require http]
set ourtubeXTRA(protection) ""
if {$tcl_platform(os) eq "Linux"} {
   set platfrm "X11"
} else {
   set platfrm $tcl_platform(os)
}

http::config -useragent "Mozilla/5.0 ($platfrm; U; $tcl_platform(os) $tcl_platform(machine); $ourtubeXTRA(lang); rv:1.9.0.3) ourtubeXTRA 1.0" -accept  "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
     
bind pub - !youtube otYoutube
bind pubm - *http://www.youtube.com/watch?* otPub

proc url_search {maxlen color styles text} {
   set i 0
   set newtext ""
   set style_ul ""
   set style_bd ""

   if  {[string is integer -strict $maxlen]} {
           if {($maxlen == "") || ($maxlen < 1)} {set maxlen 100}
        } else { set maxlen 100 }

   if {[string is list -strict $styles]} {
           if {[string match -nocase "*style_ul*" [lrange [split $styles] 0 end]]} {set style_ul "\037"}
           if {[string match -nocase "*style_bd*" [lrange [split $styles] 0 end]]} {set style_bd "\002"}
        }

   if {[string is integer -strict $color]} {
                if {($color < 0) || ($color > 15)} {set color 07}
        } else { set color "07" }

   foreach word [split $text] {
           if {[string length $word] >= 5 && [regexp {(f|ht)tp(s|)://} $word] && ![regexp {://([^/:]*:([^/]*@|\d+(/|$))|.*/\.)} $word]} {
         set urlindex [string first "http" $word 0]
         set newword [string range $word $urlindex [string length $word]]
         set oldlen [expr [string first "http" $word 0] -1 ]
         set oldword [string range $word 0 $oldlen]
                   incr i
      
         set color "\3${color}"

              set word "$oldword${color}${style_ul}${style_bd}$newword\00315${style_ul}${style_bd}"
      if {$word != ""} {
         set newtext [append newtext $word " "]
      }

      set olen [string length $newtext]
      if {$olen >= $maxlen} {
              set newtext [append newtext "..."]
                   return $newtext
            }
   }
   return $newtext
}

proc utfdecodeclean {string} {
   regsub -all -- {([\(\)\[\]\{\}\$\"\\])} $string {\\\1} string
        return $string
}

proc utfdecode {content} {
   if {![regexp -- & $content]} {
      return $content
   }

   set escapes {
      &nbsp; \xa0 &iexcl; \xa1 &cent; \xa2 &pound; \xa3 &curren; \xa4
      &yen; \xa5 &brvbar; \xa6 &sect; \xa7 &uml; \xa8 &copy; \xa9
      &ordf; \xaa &laquo; \xab &not; \xac &shy; \xad &reg; \xae
      &macr; \xaf &deg; \xb0 &plusmn; \xb1 &sup2; \xb2 &sup3; \xb3
      &acute; \xb4 &micro; \xb5 &para; \xb6 &middot; \xb7 &cedil; \xb8
      &sup1; \xb9 &ordm; \xba &raquo; \xbb &frac14; \xbc &frac12; \xbd
      &frac34; \xbe &iquest; \xbf &Agrave; \xc0 &Aacute; \xc1 &Acirc; \xc2
      &Atilde; \xc3 &Auml; \xc4 &Aring; \xc5 &AElig; \xc6 &Ccedil; \xc7
      &Egrave; \xc8 &Eacute; \xc9 &Ecirc; \xca &Euml; \xcb &Igrave; \xcc
      &Iacute; \xcd &Icirc; \xce &Iuml; \xcf &ETH; \xd0 &Ntilde; \xd1
      &Ograve; \xd2 &Oacute; \xd3 &Ocirc; \xd4 &Otilde; \xd5 &Ouml; \xd6
      &times; \xd7 &Oslash; \xd8 &Ugrave; \xd9 &Uacute; \xda &Ucirc; \xdb
      &Uuml; \xdc &Yacute; \xdd &THORN; \xde &szlig; \xdf &agrave; \xe0
      &aacute; \xe1 &acirc; \xe2 &atilde; \xe3 &auml; \xe4 &aring; \xe5
      &aelig; \xe6 &ccedil; \xe7 &egrave; \xe8 &eacute; \xe9 &ecirc; \xea
      &euml; \xeb &igrave; \xec &iacute; \xed &icirc; \xee &iuml; \xef
      &eth; \xf0 &ntilde; \xf1 &ograve; \xf2 &oacute; \xf3 &ocirc; \xf4
      &otilde; \xf5 &ouml; \xf6 &divide; \xf7 &oslash; \xf8 &ugrave; \xf9
      &uacute; \xfa &ucirc; \xfb &uuml; \xfc &yacute; \xfd &thorn; \xfe
      &yuml; \xff &fnof; \u192 &Alpha; \u391 &Beta; \u392 &Gamma; \u393 &Delta; \u394
      &Epsilon; \u395 &Zeta; \u396 &Eta; \u397 &Theta; \u398 &Iota; \u399
      &Kappa; \u39A &Lambda; \u39B &Mu; \u39C &Nu; \u39D &Xi; \u39E
      &Omicron; \u39F &Pi; \u3A0 &Rho; \u3A1 &Sigma; \u3A3 &Tau; \u3A4
      &Upsilon; \u3A5 &Phi; \u3A6 &Chi; \u3A7 &Psi; \u3A8 &Omega; \u3A9
      &alpha; \u3B1 &beta; \u3B2 &gamma; \u3B3 &delta; \u3B4 &epsilon; \u3B5
      &zeta; \u3B6 &eta; \u3B7 &theta; \u3B8 &iota; \u3B9 &kappa; \u3BA
      &lambda; \u3BB &mu; \u3BC &nu; \u3BD &xi; \u3BE &omicron; \u3BF
      &pi; \u3C0 &rho; \u3C1 &sigmaf; \u3C2 &sigma; \u3C3 &tau; \u3C4
      &upsilon; \u3C5 &phi; \u3C6 &chi; \u3C7 &psi; \u3C8 &omega; \u3C9
      &thetasym; \u3D1 &upsih; \u3D2 &piv; \u3D6 &bull; \u2022
      &hellip; \u2026 &prime; \u2032 &Prime; \u2033 &oline; \u203E
      &frasl; \u2044 &weierp; \u2118 &image; \u2111 &real; \u211C
      &trade; \u2122 &alefsym; \u2135 &larr; \u2190 &uarr; \u2191
      &rarr; \u2192 &darr; \u2193 &harr; \u2194 &crarr; \u21B5
      &lArr; \u21D0 &uArr; \u21D1 &rArr; \u21D2 &dArr; \u21D3 &hArr; \u21D4
      &forall; \u2200 &part; \u2202 &exist; \u2203 &empty; \u2205
      &nabla; \u2207 &isin; \u2208 &notin; \u2209 &ni; \u220B &prod; \u220F
      &sum; \u2211 &minus; \u2212 &lowast; \u2217 &radic; \u221A
      &prop; \u221D &infin; \u221E &ang; \u2220 &and; \u2227 &or; \u2228
      &cap; \u2229 &cup; \u222A &int; \u222B &there4; \u2234 &sim; \u223C
      &cong; \u2245 &asymp; \u2248 &ne; \u2260 &equiv; \u2261 &le; \u2264
      &ge; \u2265 &sub; \u2282 &sup; \u2283 &nsub; \u2284 &sube; \u2286
      &supe; \u2287 &oplus; \u2295 &otimes; \u2297 &perp; \u22A5
      &sdot; \u22C5 &lceil; \u2308 &rceil; \u2309 &lfloor; \u230A
      &rfloor; \u230B &lang; \u2329 &rang; \u232A &loz; \u25CA
      &spades; \u2660 &clubs; \u2663 &hearts; \u2665 &diams; \u2666
      &quot; \x22 &amp; \x26 &lt; \x3C &gt; \x3E O&Elig; \u152 &oelig; \u153
      &Scaron; \u160 &scaron; \u161 &Yuml; \u178 &circ; \u2C6
      &tilde; \u2DC &ensp; \u2002 &emsp; \u2003 &thinsp; \u2009
      &zwnj; \u200C &zwj; \u200D &lrm; \u200E &rlm; \u200F &ndash; \u2013
      &mdash; \u2014 &lsquo; \u2018 &rsquo; \u2019 &sbquo; \u201A
      &ldquo; \u201C &rdquo; \u201D &bdquo; \u201E &dagger; \u2020
      &Dagger; \u2021 &permil; \u2030 &lsaquo; \u2039 &rsaquo; \u203A
      &euro; \u20AC &apos; \u0027 &lrm; "" &rlm; "" ‬ "" ‭ ""
      ‮ "" — \u2014
   }
   set content [string map $escapes $content]
        regsub -all -- {&[a-zA-Z]+?;} [utfdecodeclean $content] {?} content
        regsub -all -- {&#(\d{1,3});} $content {[format %c [scan \1 %d]]} content
        return [subst $content]
}
     
proc otYoutube {nick uhost hand chan text} {
   global ourtubeXTRA

   if {![channel get $chan ourtubeXTRA]} {
           if {$text eq "enable"} {
                   channel set $chan +ourtubeXTRA
         if {[channel get $chan ourtubeXTRA]} {
                        putquick "NOTICE $nick :$ourtubeXTRA(youtubelogo) \00311:: \00315ourtubeXTRA 1.0"
            putquick "NOTICE $nick :Youtube URL detection was successfully ENABLED on $chan"
            return
         }
         return
                }
        }

   if {![channel get $chan ourtubeXTRAsearch]} {
           if {$text eq "enablesearch"} {
                   channel set $chan +ourtubeXTRAsearch
         if {[channel get $chan ourtubeXTRAsearch]} {
            putquick "NOTICE $nick :$ourtubeXTRA(youtubelogo) \00311:: \00315ourtubeXTRA 1.0"
            putquick "NOTICE $nick :Video search was successfully ENABLED on $chan"
            return
         }
      }
                putquick "NOTICE $nick :$ourtubeXTRA(youtubelogo) \00311:: \00315ourtubeXTRA 1.0"
      putquick "NOTICE $nick :$chan has the youtube search command DISABLED"
                if {[matchattr $hand n]} {
                   putquick "NOTICE $nick :You can ENABLE it directly by typing:\002 /msg $chan !youtube enablesearch\002"
      }
      return
   }


        #This is a generic protection to prevent flood
        #No utimer required
        #
        if {![info exists ourtubeXTRA(protection)]} {
           set ourtubeXTRA(protection) [clock seconds]
        } else {
           if {![string is digit -strict $ourtubeXTRA(protection)]} {
                   set ourtubeXTRA(protection) [clock seconds]
                } else {
                        set time [expr [clock seconds]-$ourtubeXTRA(protection)]
                        if {$time >= $ourtubeXTRA(rest)} {
                           set ourtubeXTRA(protection) [clock seconds]
                        } else {
            set floodsecs [expr [clock seconds]-$ourtubeXTRA(protection)]
            putserv "NOTICE $nick :$ourtubeXTRA(youtubelogo) \00311:: \00315Flood protection triggered: $floodsecs second(s) remaining."
                                return
                        }
                }
        }
     
        if {$text eq ""} {
                putquick "NOTICE $nick :$ourtubeXTRA(youtubelogo) \00311:: \00315Usage: !youtube <search criteria>"
                return
        }

   if {[string length $text] <= 3} {
                putquick "NOTICE $nick :$ourtubeXTRA(youtubelogo) \00311:: \00315Error - Search parameter '$arg' is too short."
                return
   }

        set data [ourtubeXTRAGet $text]
       
          if {[string length $data] == 0} {
      set data "I was unable to connect to that website. Probably I get timeout."
      return
        }

   #Display results
        foreach line $data {
      putquick "PRIVMSG $chan :$line"
        }   
}
     
proc ourtubeXTRAGet {ask} {
   global ourtubeXTRA
   set resultcount "0"
        regsub -all -- {\s+} $ask "" search
        set search [http::formatQuery $search]
        http::config -useragent "Mozilla/5.0 (Windows NT; U; Windows NT x86; en-ES; rv:1.9.0.3) Firefox 3.0.7" -accept "text/html,application/xhtml,+xml,application/xml;q=0.9,*/*;q=0.8"
        set token [http::geturl http://www.youtube.com/results?search_query=$search]
        upvar #0 $token state
        set data $state(body)
        regsub -all {\n|\t} $data "" data
        set ncode ""
        regexp {[0-9]{3}} $state(http) ncode
        if {$ncode eq ""} {
           set ncode $state(http)
        }
        set list {}
        switch -- $ncode {
         "200" {
            regexp {<p class=\"num-results\">About <strong>(.*?)</strong>} $data "" resultcount
            regexp -- {<ol id=\"search-results\" class=\"result-list context-data-container\">(.*)$} $data -> data
                      set videos [regexp -all -inline {<li class=\"yt-lockup clearfix yt-uix-tile result-item-padding yt-lockup-video yt-lockup-tile vve-check context-data-item\"(.*?)</li></ul></div>} $data]
                      set total [expr [llength $videos] /2]

                      if {$total >= $ourtubeXTRA(max)} {
                   set numitems $ourtubeXTRA(max)
            } else {
                   set numitems $total
                      }
 
            if {$resultcount == 0} {
                   set numitems 0
                   set list [list "$ourtubeXTRA(youtubelogo) \00311:: \00315$resultcount \00315result(s) found for items matching '$ask'."]
            } else {
                             set list [list "$ourtubeXTRA(youtubelogo) \00311:: \00315Showing \00300$numitems \00315of \00300$resultcount \00315result(s) found for items matching '$ask'."]
         }

                   set i 2
         if {$resultcount > 0} {
                      foreach {id line} $videos {
                              set map {}
                         set title ""
                         set description ""
               set description_parsed ""
                         set added "Unknown"
                         set viewcount "0"
                         set author "Unknown"
                         set link ""
               set duration ""

                              foreach {entity number} [regexp -all -inline {&#(\d+);} $line] {
                                    lappend map $entity [format \\u%04x [scan $number %d]]
               }
                       
               set line [string map [subst -nocomm -novar $map] $line]
                   
                              regexp {data-context-item-title=\"(.*?)\"} $line "" title
                              regsub -all -- {\<[^\>]*\>|\t} $title "" title
                    set title_parsed [url_search 40 07 "style_ul" $title]

                    if {![regexp {data-context-item-views=\"(.*?)views} $line "" viewcount]} { set viewcount "0" }
                              regsub -all -- {\<[^\>]*\>|\t} $viewcount "" viewcount
                              regexp {data-context-item-time=\"(.*?)\"} $line "" duration
                              regsub -all -- {\<[^\>]*\>|\t} $duration "" duration
                              regexp {<div class=\"yt-lockup-description yt-ui-ellipsis yt-ui-ellipsis-2\" dir=\"ltr\">(.*?)</div>} $line "" description
                              regsub -all -- {\<[^\>]*\>|\t} $description "" description

               if {$description == ""} {
                  set description "This video doesn't have any description ..."
               }

                    set description_parsed [url_search 100 07 "style_ul" $description]
                              regexp {</a></li><li>(.*?)</li>} $line "" added
                              regexp {data-context-item-user=\"(.*?)\"} $line "" author
                              regsub -all -- {\<[^\>]*\>|\t} $author "" author
                              regexp {data-context-item-id=\"(.*?)\"} $line "" link
                              set link "http://www.youtube.com/watch?v=$link"

                              set output [string map [list "<link>" $link "<title>" $title_parsed "<author>" $author "<added>" $added "<views>" $viewcount "<duration>" $duration "<description>" $description_parsed] $ourtubeXTRA(outputsearch)]

                              lappend list $output
                              if {$i > $ourtubeXTRA(max)} {
                                     break
                              }
                              incr i
            }
         }

                   set list [utfdecode $list]
         return [encoding convertto utf-8 $list]
      }
      "404" {
              http::cleanup $token
                   return [list "No such file or webpage."]
           }
               default {
                   http::cleanup $token
                   return [list "unforeseen circumstance. Server responded: $ncode"]
               }
   }   
}
     
proc otPub {nick uhost hand chan text} {
   global ourtubeXTRA
   if {![channel get $chan ourtubeXTRA]} {
                putquick "NOTICE $nick :$ourtubeXTRA(youtubelogo) \00311:: \00315ourtubeXTRA 1.0"
      putquick "NOTICE $nick :$chan has the youtube URL detector DISABLED"
                if {[matchattr $hand n]} {
                   putquick "NOTICE $nick :You can ENABLE it directly by typing:\002 /msg $chan !youtube enable\002"
      }
                return
        }

        set webTarget [lsearch -inline [split $text] {*http://*.youtube.*/watch?*}]
        if {([info exists ourtubeXTRA(protection)]) && ([string is digit -strict $ourtubeXTRA(protection)])} {
           set rest [expr [clock seconds]-$ourtubeXTRA(protection)]
               if {$rest >= $ourtubeXTRA(rest)} {
                   set ourtubeXTRA(protection) ""
      }
        } else {
                  set ourtubeXTRA(protection) ""
        }

        if {$webTarget ne ""} {
           if {! [regexp -nocase {^(http://)?([^/:]+)(:([0-9]+))?(/.*)?$} $webTarget]} {
                   return
               }
               if {$ourtubeXTRA(protection) ne ""} {
         set floodsecs [expr [clock seconds]-$ourtubeXTRA(protection)]
         putserv "NOTICE $nick :$ourtubeXTRA(youtubelogo) \00311:: \00315Flood protection triggered: $floodsecs second(s) remaining."
                   return
               }
               set ourtubeXTRA(protection) [clock seconds]
               set data [otGet $webTarget]
               if {[string length $data] == 0} {
                   set data "I was not able to reach Youtube's link. Probably I get a timeout. Try again."
               }
               putquick "PRIVMSG $chan :$data"
               utimer $ourtubeXTRA(rest) [list set ourtubeXTRA(protection) ""]
        }
}
     
proc otGet {web {relocation ""}} {
   global ourtubeXTRA
        set token [http::geturl $web -timeout 4000]
        upvar #0 $token state
        set lastcode $state(http)
        set ncode ""
        regexp {[0-9]{3}} $lastcode ncode
        if {$ncode eq ""} {
            set ncode $lastcode
        }
        switch -- $ncode {
           "200" {
      }
               "302" {
                   foreach {flag value} $state(meta) {
                          if {$flag eq "Location"} {
                              # Due to invalid youtube link but valid url syntax we can
                              # receive an url forward. this handles that
                              http::cleanup $token
                              return [otGet $value "(Relocated)"]
                          }
                   }
               }
      "303" {
                   http::cleanup $token
                   return "That video does not exists. Server responded: $lastcode"
               }
               "404" {
                   http::cleanup $token
                   return "$web - No such webpage"
               }
               default {
                   http::cleanup $token
                   return "unforeseen circumstances. Server responded: $lastcode"
               }
   }

   set data $state(body)
     
        http::cleanup $token
   set title ""
        set author "Unknown"
   set added "Unknown"
        set description "This video doesn't have any description..."
        set views "0"
   set author "Unknown"
        set likes "0"
   set dislikes "0"
   set userinfo ""
   set duration ""
   set totalseconds 0
   set videosecs 0
   set videomins 0

        regexp {<title>(.*?)</title>} $data "" title
   set title [string trimright $title " - YouTube"]
        regsub -all -- {\<[^\>]*\>|\t} $title "" title
   set title_parsed [url_search 40 07 "style_ul" $title]

        regexp {<meta name=\"description\" content=\"(.*?)\">.*} $data " " description
   regexp {<span id=\"eow-date\" class=\"watch-video-date\" >(.*?)</span>} $data "" added

        # following two lines were edited from original
        if {![regexp {<span class=\"watch-view-count \" >(.*?)</span>} $data "" views]} { set views "0" }
   set views [string trim $views]
   set added [string trimleft $added]

   if {[regexp -nocase {<meta itemprop=\"duration\" content=\"(.*?)\">.*} $data match duration]} {
        set youtubelength $duration
        if {[regexp {M(.*?)S} $duration match duration]} {
             set videosecs $duration
        }
        set duration $youtubelength
        if {[regexp {PT(.*?)M} $duration match duration]} {
             set videomins $duration
        }
      set totalseconds [expr {($videomins * 60) + $videosecs}]           
      set duration [clock format $totalseconds -format {%H:%M:%S}]
   }

   regexp -- {<div id=\"watch7-user-header\" class=\"spf-nolink\">(.*?)<div class=\"yt-dialog hid\">} $data -> userinfo
        if {![regexp {data-name=\"watch\">(.*?)</a>} $userinfo "" author]} { set author "Unknown" }

        if {![regexp {<span class=\"likes-count\">(.*?)</span>} $data "" likes]} { set likes "0" }
        if {![regexp {<span class=\"dislikes-count\">(.*?)</span>} $data "" dislikes]} { set dislikes "0" }

        regsub -all -- {\<[^\>]*\>|\t} $description "" description
        regsub -all -- {\<[^\>]*\>|\t} $views "" views

        if {$description eq ""} {
            set description "This video doesn't have any description ..."
        }

   set description_parsed [url_search 100 07 "style_ul" $description]

        set output [string map [list "<title>" $title_parsed "<author>" $author "<added>" $added "<views>" $views "<duration>" $duration "<likes>" $likes "<dislikes>" $dislikes "<description>" $description_parsed] $ourtubeXTRA(output)]

        set output [utfdecode $output]

   return [encoding convertto utf-8 $output]
}

putlog "\002\00304,00You\00300,04Tube\017 \00311:: \002\00300*Loaded* \002\00315ourtubeXTRA 1.0 by \002WazzaUK\002\00311 :: \00315based on ourtube by \002Hackemate\002."

set ourtubeXTRA(Loaded) 1
Back to top
View user's profile Send private message
bunnybump
Voice


Joined: 17 Aug 2012
Posts: 9

PostPosted: Fri Feb 21, 2014 3:39 pm    Post subject: Reply with quote

i've try this tcl but it keeps telling me that there's an error with the script. here what i got:

Code:
 can't read "maxlen": no such variable
    while executing
"string is integer -strict $maxlen"
    invoked from within
"if  {[string is integer -strict $maxlen]} {
           if {($maxlen == "") || ($maxlen < 1)} {set maxlen 100}
        } else { set maxlen "100" }"
    (file "scripts/you.tcl" line 50)


what should i do to fix it? thank you in advance for the help.
_________________
In the Beginning... Was the Command Line
Back to top
View user's profile Send private message Visit poster's website
Anahel
Halfop


Joined: 03 Jul 2009
Posts: 48
Location: Dom!

PostPosted: Mon Feb 24, 2014 2:41 pm    Post subject: Reply with quote

WazzaUK each time I want to load your script i get this:

Code:
[19:38:11] Tcl error in file 'neko.conf':
[19:38:11] missing close-brace
    while executing
"proc url_search {maxlen color styles text} {
   set i 0
   set newtext ""
   set style_ul ""
   set style_bd ""

   if  {[string is integer -strict $m..."
    (file "scripts/ourtube.tcl" line 43)
    invoked from within
"source scripts/ourtube.tcl"
    (file "neko.conf" line 1509)
[19:38:11] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)


Could you post your script somewhere instead of inside [code] on forum?
Back to top
View user's profile Send private message
WazzaUK
Voice


Joined: 02 Jul 2006
Posts: 19

PostPosted: Wed Feb 26, 2014 1:10 pm    Post subject: OurTubeXTRA re-codes Reply with quote

Ok so there was a few errors in the last release. It didnt help that youtube changed theyre form data structure. I know this one works, im still working on the utf-8 encoding. Laughing

Code:

setudef flag ourtubeXTRA

global ourtubeXTRA tcl_platform
     
#Flood Protection: after show a link, will ignore all links few seconds
# This means 1 link per 10 seconds.
set ourtubeXTRA(rest) 10
     
#What language you can receive the youTube data? (if works heh)
set ourtubeXTRA(lang) en
     
#Limit of links at same time
set ourtubeXTRA(max) 5
     
#youtube logo
set ourtubeXTRA(youtubelogo) "\002\00304,00You\00300,04Tube\017"
         
set ourtubeXTRA(output) "$ourtubeXTRA(youtubelogo) \00311:: \002\00309<title>\002\00311:: \00308Author: \00314<author> \00311:: \00308Added: \00314<added> \00311:: \00308Views:

\00314<views> \00311:: \00308Duration: \00314<duration> \00311:: \00308Likes: \00309<likes> \00311:: \00308Dislikes: \00304<dislikes> \00311::\002\00312\<badgelist>

\017\00314<description>"
         
set ourtubeXTRA(outputsearch) "\00309<title>\00311:: \00312\037<link>\003\037 \00311:: \00308Author: \00314<author> \00311:: \00308Added: \00314<added> \00311:: \00308Views:

\00314<views> \00311:: \00308Duration: \00314<duration> \00311::\002\00312<badgelist>\017\00314<description>"
         
set ourtubeXTRA(author) "WazzaUK"
set ourtubeXTRA(contact) "WazzaUK <wallison_uk@yahoo.co.uk>"
set ourtubeXTRA(originalauthor) "HackeMate"
set ourtubeXTRA(originalcontact) "HackeMate <Sentencia@eggdrop.es>"
set ourtubeXTRA(name) "ourtubeXTRA"
set ourtubeXTRA(projectName) "ourtubeXTRA"
set ourtubeXTRA(version) "1.0"
set ourtubeXTRA(package.http) [package require http]
set ourtubeXTRA(protection) ""

if {$tcl_platform(os) eq "Linux"} {
   set platfrm "X11"
} else {
   set platfrm $tcl_platform(os)
}

http::config -useragent "Mozilla/5.0 ($platfrm; U; $tcl_platform(os) $tcl_platform(machine); $ourtubeXTRA(lang); rv:1.9.0.3) ourtubeXTRA 1.0" -accept

"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
     
bind pub - !youtube otYoutube
bind pubm - *http://www.youtube.com/watch?* otPub


proc create_badgelist {badges} {
   set badgelist ""
   if { $badges ne "" } {
      foreach badge [split $badges] {
         append badgelist " \[$badge\]"
      }
   }
   return $badgelist
}

proc url_search {maxlen color styles text} {
   set i 0
   set newtext ""
   set style_ul ""
   set style_bd "" 


   if {![string is integer -strict $maxlen]} {set maxlen [ string length $text ] }
        if {($maxlen == "") || ($maxlen < 1)} {set maxlen [ string length $text ]}


   if {![string is alpha -strict $styles]} {set styles "style_ul"}
   if {[string match -nocase style_ul $styles]} {set style_ul "\037"}
   if {[string match -nocase style_bd $styles]} {set style_bd "\002"}



   if {![string is integer -strict $color]} {set color "07"}
        if {($color < 0) || ($color > 15)} {set color 07}
   

   foreach word [split $text] {
      set urlindex -1
           if {[string length $word] >= 5 && [regexp {(f|ht)tp(s|)://} $word] && ![regexp {://([^/:]*:([^/]*@|\d+(/|$))|.*/\.)} $word]} {
         set wprotocol ""
         regexp {(f|ht)tp(s|)://} $word "" wprotocol
         set urlindex [string first $wprotocol $word 0]

         set newword [string range $word $urlindex [string length $word]]
         set oldlen [expr [string first $wprotocol $word 0] -1 ]
         set oldword [string range $word 0 $oldlen]
                   incr i
         if { $urlindex > 0 } { append oldword " " }
              set word "$oldword\003${color}${style_bd}${style_ul}$newword\00314${style_bd}${style_ul}"
      }

      append newtext $word " "
   }

   return $newtext
}

proc utfdecodeclean {string} {
   regsub -all -- {([\(\)\[\]\{\}\$\"\\])} $string {\\\1} string
        return $string
}

proc utfdecode {content} {
   if {![regexp -- & $content]} {
      return $content
   }

   set escapes {
      &nbsp; \xa0 &iexcl; \xa1 &cent; \xa2 &pound; \xa3 &curren; \xa4
      &yen; \xa5 &brvbar; \xa6 &sect; \xa7 &uml; \xa8 &copy; \xa9
      &ordf; \xaa &laquo; \xab &not; \xac &shy; \xad &reg; \xae
      &macr; \xaf &deg; \xb0 &plusmn; \xb1 &sup2; \xb2 &sup3; \xb3
      &acute; \xb4 &micro; \xb5 &para; \xb6 &middot; \xb7 &cedil; \xb8
      &sup1; \xb9 &ordm; \xba &raquo; \xbb &frac14; \xbc &frac12; \xbd
      &frac34; \xbe &iquest; \xbf &Agrave; \xc0 &Aacute; \xc1 &Acirc; \xc2
      &Atilde; \xc3 &Auml; \xc4 &Aring; \xc5 &AElig; \xc6 &Ccedil; \xc7
      &Egrave; \xc8 &Eacute; \xc9 &Ecirc; \xca &Euml; \xcb &Igrave; \xcc
      &Iacute; \xcd &Icirc; \xce &Iuml; \xcf &ETH; \xd0 &Ntilde; \xd1
      &Ograve; \xd2 &Oacute; \xd3 &Ocirc; \xd4 &Otilde; \xd5 &Ouml; \xd6
      &times; \xd7 &Oslash; \xd8 &Ugrave; \xd9 &Uacute; \xda &Ucirc; \xdb
      &Uuml; \xdc &Yacute; \xdd &THORN; \xde &szlig; \xdf &agrave; \xe0
      &aacute; \xe1 &acirc; \xe2 &atilde; \xe3 &auml; \xe4 &aring; \xe5
      &aelig; \xe6 &ccedil; \xe7 &egrave; \xe8 &eacute; \xe9 &ecirc; \xea
      &euml; \xeb &igrave; \xec &iacute; \xed &icirc; \xee &iuml; \xef
      &eth; \xf0 &ntilde; \xf1 &ograve; \xf2 &oacute; \xf3 &ocirc; \xf4
      &otilde; \xf5 &ouml; \xf6 &divide; \xf7 &oslash; \xf8 &ugrave; \xf9
      &uacute; \xfa &ucirc; \xfb &uuml; \xfc &yacute; \xfd &thorn; \xfe
      &yuml; \xff &fnof; \u192 &Alpha; \u391 &Beta; \u392 &Gamma; \u393 &Delta; \u394
      &Epsilon; \u395 &Zeta; \u396 &Eta; \u397 &Theta; \u398 &Iota; \u399
      &Kappa; \u39A &Lambda; \u39B &Mu; \u39C &Nu; \u39D &Xi; \u39E
      &Omicron; \u39F &Pi; \u3A0 &Rho; \u3A1 &Sigma; \u3A3 &Tau; \u3A4
      &Upsilon; \u3A5 &Phi; \u3A6 &Chi; \u3A7 &Psi; \u3A8 &Omega; \u3A9
      &alpha; \u3B1 &beta; \u3B2 &gamma; \u3B3 &delta; \u3B4 &epsilon; \u3B5
      &zeta; \u3B6 &eta; \u3B7 &theta; \u3B8 &iota; \u3B9 &kappa; \u3BA
      &lambda; \u3BB &mu; \u3BC &nu; \u3BD &xi; \u3BE &omicron; \u3BF
      &pi; \u3C0 &rho; \u3C1 &sigmaf; \u3C2 &sigma; \u3C3 &tau; \u3C4
      &upsilon; \u3C5 &phi; \u3C6 &chi; \u3C7 &psi; \u3C8 &omega; \u3C9
      &thetasym; \u3D1 &upsih; \u3D2 &piv; \u3D6 &bull; \u2022
      &hellip; \u2026 &prime; \u2032 &Prime; \u2033 &oline; \u203E
      &frasl; \u2044 &weierp; \u2118 &image; \u2111 &real; \u211C
      &trade; \u2122 &alefsym; \u2135 &larr; \u2190 &uarr; \u2191
      &rarr; \u2192 &darr; \u2193 &harr; \u2194 &crarr; \u21B5
      &lArr; \u21D0 &uArr; \u21D1 &rArr; \u21D2 &dArr; \u21D3 &hArr; \u21D4
      &forall; \u2200 &part; \u2202 &exist; \u2203 &empty; \u2205
      &nabla; \u2207 &isin; \u2208 &notin; \u2209 &ni; \u220B &prod; \u220F
      &sum; \u2211 &minus; \u2212 &lowast; \u2217 &radic; \u221A
      &prop; \u221D &infin; \u221E &ang; \u2220 &and; \u2227 &or; \u2228
      &cap; \u2229 &cup; \u222A &int; \u222B &there4; \u2234 &sim; \u223C
      &cong; \u2245 &asymp; \u2248 &ne; \u2260 &equiv; \u2261 &le; \u2264
      &ge; \u2265 &sub; \u2282 &sup; \u2283 &nsub; \u2284 &sube; \u2286
      &supe; \u2287 &oplus; \u2295 &otimes; \u2297 &perp; \u22A5
      &sdot; \u22C5 &lceil; \u2308 &rceil; \u2309 &lfloor; \u230A
      &rfloor; \u230B &lang; \u2329 &rang; \u232A &loz; \u25CA
      &spades; \u2660 &clubs; \u2663 &hearts; \u2665 &diams; \u2666
      &quot; \x22 &amp; \x26 &lt; \x3C &gt; \x3E O&Elig; \u152 &oelig; \u153
      &Scaron; \u160 &scaron; \u161 &Yuml; \u178 &circ; \u2C6
      &tilde; \u2DC &ensp; \u2002 &emsp; \u2003 &thinsp; \u2009
      &zwnj; \u200C &zwj; \u200D &lrm; \u200E &rlm; \u200F &ndash; \u2013
      &mdash; \u2014 &lsquo; \u2018 &rsquo; \u2019 &sbquo; \u201A
      &ldquo; \u201C &rdquo; \u201D &bdquo; \u201E &dagger; \u2020
      &Dagger; \u2021 &permil; \u2030 &lsaquo; \u2039 &rsaquo; \u203A
      &euro; \u20AC &apos; \u0027 &lrm; "" &rlm; "" ‬ "" ‭ ""
      ‮ "" — \u2014
   }
   set content [string map $escapes $content]
        regsub -all -- {&[a-zA-Z]+?;} [utfdecodeclean $content] {?} content
        regsub -all -- {&#(\d{1,3});} $content {[format %c [scan \1 %d]]} content
        return [subst $content]
}

proc otYoutube {nick uhost hand chan text} {
   global ourtubeXTRA
   if {![channel get $chan ourtubeXTRA]} {
           if {$text eq "enable"} {
                   channel set $chan +ourtubeXTRA
                        return
                } else {
         putquick "NOTICE $nick :$ourtubeXTRA(youtubelogo) \00311:: \00315$chan has this command disabled."
                       }
      if {[matchattr $hand n]} {
         putquick "NOTICE $nick :You can enable it directly typing: /msg $chan !youtube enable"
      }
      return
        }

        #This is a generic protection to prevent flood
        #No utimer required

        if {![info exists ourtubeXTRA(protection)]} {
           set ourtubeXTRA(protection) [clock seconds]
        } else {
           if {![string is digit -strict $ourtubeXTRA(protection)]} {
                   set ourtubeXTRA(protection) [clock seconds]
                } else {
                        set time [expr [clock seconds]-$ourtubeXTRA(protection)]
                        if {$time >= $ourtubeXTRA(rest)} {
                           set ourtubeXTRA(protection) [clock seconds]
                        } else {
            set floodsecs [expr [clock seconds]-$ourtubeXTRA(protection)]
            putserv "NOTICE $nick :$ourtubeXTRA(youtubelogo) \00311:: \00315Flood protection triggered: $floodsecs second(s) remaining."
                                return
                        }
                }
        }


        if {$text eq ""} {
                putquick "NOTICE $nick :$ourtubeXTRA(youtubelogo) \00311:: \00315Usage: !youtube <search criteria>"
                return
        }

   if {[string length $text] <= 3} {
                putquick "NOTICE $nick :$ourtubeXTRA(youtubelogo) \00311:: \00315Error - Search parameter '$text' is too short."
                return
   }

        set data [ourtubeXTRAGet $text]
       
          if {[string length $data] == 0} {
      set data "I was unable to connect to that website. Probably I get timeout."
      return
        }

   #Display results
        foreach line $data {
      putquick "PRIVMSG $chan :$line"
        }   
}


     
proc ourtubeXTRAGet {ask} {
   global ourtubeXTRA
   set resultcount "0"
        regsub -all -- {\s+} $ask "" search
        set search [http::formatQuery $search]
        set token [http::geturl http://www.youtube.com/results?search_query=$search&sm=12]
 
        upvar #0 $token state
        set data $state(body)

        #regsub -all {\s|\n|\r|\t|\f} $data "" data

   set data [ utfdecode $data ]

        regsub -all {\n|\t|\r} $data "" data

        set ncode ""
        regexp {[0-9]{3}} $state(http) ncode
        if {$ncode eq ""} {
           set ncode $state(http)
        }
       

   set list {}
        switch -- $ncode {
         "200" {
            regexp {<p class=\"num-results\">About <strong>(.*?)</strong>} $data "" uresultcount
                        
            regexp -- {<ol id=\"search-results\" class=\"result-list\">(.*?)$} $data -> data
            
set videos [ regexp -all -inline {<li class=\"yt-lockup clearfix yt-uix-tile result-item-padding yt-lockup-video yt-lockup-tile vve-check\"(.*?)<li class="yt-lockup clearfix

yt-uix-tile result-item-padding yt-lockup-video yt-lockup-tile vve-check\"} $data ]

            regsub -all {,} $uresultcount "" resultcount

                      set total [expr [llength $videos] /2]

                      if {$total >= $ourtubeXTRA(max)} {
                   set numitems $ourtubeXTRA(max)
            } else {
                   set numitems $total
                      }

            if {$resultcount == 0} {
                   set numitems 0
                   set list [list "$ourtubeXTRA(youtubelogo) \00311:: \00315$uresultcount \00315result(s) found for items matching '$ask'."]
            } else {
                             set list [list "$ourtubeXTRA(youtubelogo) \00311:: \00315Showing \00300$numitems \00315of \00300$uresultcount \00315result(s) found for

items matching '$ask'."]
         }

                   set i 2
         if {$resultcount > 0} {
                      foreach {id line} $videos {
                              set map {}
                         set title ""
               set title_parsed ""
                         set description "This video does not have any description"
               set description_parsed ""
                         set added "Unknown"
                         set viewcount "0"
                         set author "Unknown"
                         set link ""
               set duration ""
               set item_info ""
               set item_badges ""
               set badge_info ""
               set badge ""
               set badge1 ""
               set badge2 ""
               set badgelist ""

                              foreach {entity number} [regexp -all -inline {&#(\d+);} $line] {
                                    lappend map $entity [format \\u%04x [scan $number %d]]
               }

               set line [string map [subst -nocomm -novar $map] $line]

               regexp -all -- {<div class=\"yt-lockup-content\">(.*?)$} $line "" item_info
                              regexp {title=\"(.*?)\"} $item_info "" title
                              regsub -all -- {\<[^\>]*\>|\t} $title "" title

               set tlen [ string length $title ]
                    
               set title_parsed [url_search $tlen "07" "style_ul" $title]

               regexp {href=\"(.*?)\"} $item_info "" link

               regexp {<div class=\"yt-lockup-description yt-ui-ellipsis yt-ui-ellipsis-2\" dir=\"ltr\">(.*?)</div>} $item_info "" description

                              regexp {<span class=\"video-time\">(.*?)</span>} $line "" duration
                              regsub -all -- {\<[^\>]*\>|\t} $duration "" duration               
                              
               regexp {data-name=\"\">(.*?)</a></li><li>(.*?)</li><li>(.*?) views</li>} $line "" author added viewcount
                              regsub -all -- {\<[^\>]*\>|\t} $author "" author
               regsub -all -- {\<[^\>]*\>|\t} $added "" added
               regsub -all -- {\<[^\>]*\>|\t} $viewcount "" viewcount
               regsub -all -- {\<[^\>]*\>|\t} $description "" description

               
               regexp -all -- {li class=\"yt-lockup-badge-item\">(.*?)$} $line "" item_info

               while {[regexp {<span class=\"yt-badge \" >(.*?)</span></li>} $item_info "" badge1]} {
                  if { $badge1 != "" } {
                     if {[ string first $badge1 $badgelist 0] == -1 } {
                        set badgelist [ append badgelist "$badge1 " ]
                     }
                     regsub -- {<span class=\"yt-badge \" >(.*?)</span></li>} $item_info "" item_info
                     set badge1 ""
                  }
               }

               set badgelist [ string trimright $badgelist " " ]
               set badgelist [ create_badgelist $badgelist ]
               
               set tlen [ string length $description ]


                    set description_parsed [url_search $tlen "07" "style_ul" $description]
                              set yturl "http://www.youtube.com$link"

               set output [string map [list "<title>" $title_parsed "<link>" $yturl "<author>" $author "<added>" $added "<views>" $viewcount

"<duration>" $duration "<badgelist>" $badgelist "<description>" $description_parsed] $ourtubeXTRA(outputsearch)]
                              lappend list $output
                              if {$i > $ourtubeXTRA(max)} {
                                     break
                              }
               incr i
            }
         }
             
         return [encoding convertto utf-8 $list]
      }
      "404" {
              http::cleanup $token
                   return [list "No such file or webpage."]
           }
               default {
                   http::cleanup $token
                   return [list "unforeseen circumstance. Server responded: $ncode"]
               }
   }   
}

     
proc otPub {nick uhost hand chan text} {
   if {![channel get $chan ourtubeXTRA]} {
            return
        }
        global ourtubeXTRA       
        set webTarget [lsearch -inline [split $text] {*http://*.youtube.*/watch?*}]
        if {([info exists ourtubeXTRA(protection)]) && ([string is digit -strict $ourtubeXTRA(protection)])} {
           set rest [expr [clock seconds]-$ourtubeXTRA(protection)]
               if {$rest >= $ourtubeXTRA(rest)} {
                   set ourtubeXTRA(protection) ""
      }
        } else {
                  set ourtubeXTRA(protection) ""
        }

        if {$webTarget ne ""} {
           if {! [regexp -nocase {^(http://)?([^/:]+)(:([0-9]+))?(/.*)?$} $webTarget]} {
                   return
               }
               if {$ourtubeXTRA(protection) ne ""} {
         set floodsecs [expr [clock seconds]-$ourtubeXTRA(protection)]
         putserv "NOTICE $nick :$ourtubeXTRA(youtubelogo) \00311:: \00315Flood protection triggered: $floodsecs second(s) remaining."
                   return
               }
               set ourtubeXTRA(protection) [clock seconds]
               set data [otGet $webTarget]
               if {[string length $data] == 0} {
                   set data "I was not able to reach Youtube's link. Probably I get a timeout. Try again."
               }
               putquick "PRIVMSG $chan :$data"
               utimer $ourtubeXTRA(rest) [list set ourtubeXTRA(protection) ""]
        }
}
     
proc otGet {web} {
   global ourtubeXTRA
        set token [http::geturl $web -timeout 4000]
        upvar #0 $token state

        set data $state(body)

   set data [ utfdecode $data ]

        regsub -all {\n|\t|\r} $data "" data

        set ncode ""
        regexp {[0-9]{3}} $state(http) ncode
        if {$ncode eq ""} {
           set ncode $state(http)
        }

        switch -- $ncode {
           "200" {

      }
               "302" {
                   foreach {flag value} $state(meta) {
                          if {$flag eq "Location"} {
                              http::cleanup $token
                              return "Invalid youtube link: $ncode"
                          }
                   }
               }
      "303" {
                   http::cleanup $token
                   return "That video does not exists. Server responded: $ncode"
               }
               "404" {
                   http::cleanup $token
                   return "$ncode - $web - No such webpage"
               }
               default {
                   http::cleanup $token
                   return "unforeseen circumstances. Server responded: $ncode"
               }
   }
   
   set durationfmt "%M:%S"
   set badges ""
   set badge1 ""
   set badge2 ""

   set agestrict ""

   set title ""
   set title_parsed ""

        if {[regexp {<meta property=\"og:title\" content=\"(.*?)\">} $data "" title]} {
      set tlen [ string length $title ]
      
      set title_parsed [url_search $tlen "07" "style_ul" $title]
   }

   if {[regexp {<meta property=\"og:video:height\" content=\"(.*?)\">} $data "" videoHeight]} {
      if { $videoHeight >= 720 } { set badges [ append badges "HD "] }
   }

   if {[regexp {<meta property=\"og:restrictions:age\" content=\"(.*?)\">} $data "" agestrict]} {
      set badges [ append badges "$agestrict "]
   }

   set badges [ string trimright $badges " " ]
;
        regexp {<meta property=\"og:description\" content=\"(.*?)\">} $data "" description

   if { $description eq "" } { set description "This video does not have a description" }

   set badgelist [ create_badgelist $badges ]

   set tlen [ string length $description ]

   set description_parsed [url_search $tlen "07" "style_ul" $description]

   set added "Unknown"
   regexp {<span id=\"eow-date\" class=\"watch-video-date\" >(.*?)</span>} $data "" added

   set views "0"
        regexp {<span class=\"watch-view-count \" >(.*?)</span>} $data "" views
   set views [string trimright $views " views" ]
   set views [string trimleft $views]

        if {![regexp -all {<span class=\"likes-count\">(.*?)</span>} $data "" likes]} { set likes 0 }
        if {![regexp -all {<span class=\"dislikes-count\">(.*?)</span>} $data "" dislikes]} { set dislikes 0 }

   set author "Unknown"
        regexp -all {data-name=\"watch\">(.*?)</a><span class=\"yt-user-separator\">} $data "" author
   regexp -all {data-name=\"watch\">(.*?)</a>} $data "" author

   if {![regexp -all {<meta itemprop=\"duration\" content=\"PT(.*?)M(.*?)S\">} $data "" videomins videosecs]} {
      set videomins 0
      set videosecs 0
   }
   
   set totalseconds [expr {($videomins * 60) + $videosecs}]
   if { $videomins >= 60 } { set durationfmt "%H:%M:%S" }
   set duration [clock format $totalseconds -format $durationfmt]

        set yt_output [string map [list "<title>" $title_parsed "<author>" $author "<added>" $added "<views>" $views "<duration>" $duration "<likes>" $likes "<dislikes>"

$dislikes "<badgelist>" $badgelist "<description>" $description_parsed] $ourtubeXTRA(output)]

   return [ encoding convertto utf-8 $yt_output ]
}

putlog "\002\00304,00You\00300,04Tube\017 \00311:: \002\00300*Loaded* \002\00315ourtubeXTRA 1.0 by \002WazzaUK\002\00311 :: \00315based on ourtube by \002Hackemate\002."

set ourtubeXTRA(Loaded) 1
Back to top
View user's profile Send private message
Anahel
Halfop


Joined: 03 Jul 2009
Posts: 48
Location: Dom!

PostPosted: Thu Feb 27, 2014 1:35 pm    Post subject: Reply with quote

WazzaUK you should check script you're posting on site - you updated it but (tho it still doesn't work for me) somewhere you added word wrap making the script unusable - you need to fix broken lines in script.

Could you just upload the .tcl somewhere? or paste it to some pastebin instead of adding it in [code]
Back to top
View user's profile Send private message
WazzaUK
Voice


Joined: 02 Jul 2006
Posts: 19

PostPosted: Sun Mar 02, 2014 11:26 am    Post subject: OurtubeXTRA search fix... Reply with quote

it seems youtube changed output data again...

find the:

Code:

set videos [ regexp -all -inline {<li class=\"yt-lockup clearfix yt-uix-tile result-item-padding yt-lockup-video yt-lockup-tile vve-check\"(.*?)<li class=\"yt-lockup clearfix yt-uix-tile result-item-padding yt-lockup-video yt-lockup-tile vve-check\"} $data ]


and change to:

Code:

set videos [ regexp -all -inline {<li class=\"yt-lockup clearfix yt-uix-tile result-item-padding yt-lockup-video yt-lockup-tile\"(.*?)<li class=\"yt-lockup clearfix yt-uix-tile result-item-padding yt-lockup-video yt-lockup-tile\"} $data ]



Whole source uploaded to pastebin. Full TCL script
Back to top
View user's profile Send private message
bunnybump
Voice


Joined: 17 Aug 2012
Posts: 9

PostPosted: Mon Mar 03, 2014 7:51 am    Post subject: Reply with quote

and now here what we got with your script:

Code:

Tcl error in file 'Eggdrop.conf':
invalid command name "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
    while executing
""text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8""
    (file "scripts/OurtubeXTRA.tcl" line 71)
    invoked from within
"source scripts/OurtubeXTRA.tcl"
    (file "in" line 203)
* CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)


are you sure that you already test it before make a post in here? cause every change that you've made seems never working Sad
_________________
In the Beginning... Was the Command Line
Back to top
View user's profile Send private message Visit poster's website
WazzaUK
Voice


Joined: 02 Jul 2006
Posts: 19

PostPosted: Mon Mar 03, 2014 10:34 pm    Post subject: re: bunnybump Reply with quote

Quote:

and now here what we got with your script:

Code:

Tcl error in file 'Eggdrop.conf':
invalid command name "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
while executing
""text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8""
(file "scripts/OurtubeXTRA.tcl" line 71)
invoked from within
"source scripts/OurtubeXTRA.tcl"
(file "in" line 203)
* CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)

are you sure that you already test it before make a post in here? cause every change that you've made seems never working Sad


that line should be:

Code:

http::config -useragent "Mozilla/5.0 ($platfrm; U; $tcl_platform(os) $tcl_platform(machine); $ourtubeXTRA(lang); rv:1.9.0.3) ourtubeXTRA 1.0" -accept "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
Back to top
View user's profile Send private message
WazzaUK
Voice


Joined: 02 Jul 2006
Posts: 19

PostPosted: Tue Mar 04, 2014 3:28 pm    Post subject: new version of code - in namespace... Reply with quote

Code:

namespace eval ourtubeXTRA {

   setudef flag ourtubeXTRA
   global tcl_platform
   
   #What language you can receive the youTube data? (if works heh)
   set lang en

   #youtube logo
   set youtubelogo "\002\00304,00You\00300,04Tube\017"
       
   set outputline "$youtubelogo \00311:: \002\00309<title> \002\00311:: \00308Author: \00314<author> \700311:: \00308Added: \00314<added> \00311:: \00308Views: \00314<views> \00311:: \00308Duration: \00314<duration> \00311:: \00308Likes: \00309<likes> \00311:: \00308Dislikes: \00304<dislikes> \00311::\002\00312 <badgelist> \017\00314<full_description>\n"
         
   set outputsearch " \00308<vcount>. \00312\037<link>\003\037 \00311:: \00309<title> \00311:: \00308Author: \00314<author> \00311:: \00308Added: \00314<added> \00311::  \00308Views: \00314<views> \00311:: \00308Duration: \00314<duration> \00311: \002\00312 <badgelist>\017\00314<description>"

         
   set author "WazzaUK"
   set contact "WazzaUK <wallison_uk@yahoo.co.uk>"
   set originalauthor "HackeMate"
   set originalcontact "HackeMate <Sentencia@eggdrop.es>"
   set name "ourtubeXTRA"
   set projectName "ourtubeXTRA"
   set package.http [package require http]
   set protection ""
   set ytrest 10     
   set max_links 5

   if {$tcl_platform(os) eq "Linux"} {
      set platfrm "X11"
   } else {
      set platfrm $tcl_platform(os)
   }

   http::config -useragent "Mozilla/5.0 ($platfrm; U; $tcl_platform(os) $tcl_platform(machine); $lang; rv:1.9.0.3) ourtubeXTRA 1.0" -accept "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
     
   bind pubm - *http://www.youtube.com/watch?* ourtubeXTRA::otPub
   bind pub - !youtube ourtubeXTRA::otYoutube

   proc create_badgelist {badges} {
      set badgelist ""
      if { [string length $badges] > 1} {
         foreach badge [split $badges] {
            if { $badge ne " " } {
               append badgelist "\[$badge\] "
            }
         }
      }
      return $badgelist
   }

   proc parse_text {maxlen text} {
      set newtext ""
      set ccount 0
      set linelist ""
      foreach word [split $text] {
         set prednum [ expr {([string length $word] + $ccount) + 1}]
         if {$prednum >= $maxlen} {
            set ccount 0
            lappend linelist $newtext
            set newtext ""
         } else {
            append newtext $word " "
            incr ccount
         }
         
         set ccount [ expr {[string length $word] + $ccount}]
      }

      if {$ccount >0} {
         lappend linelist $newtext
      }
      return $linelist
   
   }

   proc url_search {maxlen color styles text} {
      set i 0
      set newtext ""
      set style_ul ""
      set style_bd "" 


      if {![string is integer -strict $maxlen]} {set maxlen [ string length $text ] }
           if {($maxlen == "") || ($maxlen < 1)} {set maxlen [ string length $text ]}


      if {![string is alpha -strict $styles]} {set styles "style_ul"}
      if {[string match -nocase style_ul $styles]} {set style_ul "\037"}
      if {[string match -nocase style_bd $styles]} {set style_bd "\002"}



      if {![string is integer -strict $color]} {set color "07"}
           if {($color < 0) || ($color > 15)} {set color 07}
   
      foreach word [split $text] {
         set urlindex -1
         set isurl 0
              if {[string length $word] >= 5 && [regexp {(f|ht)tp(s|)://} $word] && ![regexp {://([^/:]*:([^/]*@|\d+(/|$))|.*/\.)} $word]} {
            set wprotocol ""
            set isurl 1
            regexp {(f|ht)tp(s|)://} $word "" wprotocol
            set urlindex [string first $wprotocol $word 0]

            set newword [string range $word $urlindex [string length $word]]
            set oldlen [expr [string first $wprotocol $word 0] -1 ]
            set oldword [string range $word 0 $oldlen]
                      incr i
            if { $urlindex > 0 } { append oldword " " }
                 set word "$oldword\003${color}${style_bd}${style_ul}$newword\00314${style_bd}${style_ul}"
         
         }
         append newtext $word " "
      }
      return $newtext
   }

   proc utfdecodeclean {string} {
      regsub -all -- {([\(\)\[\]\{\}\$\"\\])} $string {\\\1} string
           return $string
   }

   proc utfdecode {content} {
      if {![regexp -- & $content]} {
         return $content
      }

      set escapes {
         &nbsp; \xa0 &iexcl; \xa1 &cent; \xa2 &pound; \xa3 &curren; \xa4
         &yen; \xa5 &brvbar; \xa6 &sect; \xa7 &uml; \xa8 &copy; \xa9
         &ordf; \xaa &laquo; \xab &not; \xac &shy; \xad &reg; \xae
         &macr; \xaf &deg; \xb0 &plusmn; \xb1 &sup2; \xb2 &sup3; \xb3
         &acute; \xb4 &micro; \xb5 &para; \xb6 &middot; \xb7 &cedil; \xb8
         &sup1; \xb9 &ordm; \xba &raquo; \xbb &frac14; \xbc &frac12; \xbd
         &frac34; \xbe &iquest; \xbf &Agrave; \xc0 &Aacute; \xc1 &Acirc; \xc2
         &Atilde; \xc3 &Auml; \xc4 &Aring; \xc5 &AElig; \xc6 &Ccedil; \xc7
         &Egrave; \xc8 &Eacute; \xc9 &Ecirc; \xca &Euml; \xcb &Igrave; \xcc
         &Iacute; \xcd &Icirc; \xce &Iuml; \xcf &ETH; \xd0 &Ntilde; \xd1
         &Ograve; \xd2 &Oacute; \xd3 &Ocirc; \xd4 &Otilde; \xd5 &Ouml; \xd6
         &times; \xd7 &Oslash; \xd8 &Ugrave; \xd9 &Uacute; \xda &Ucirc; \xdb
         &Uuml; \xdc &Yacute; \xdd &THORN; \xde &szlig; \xdf &agrave; \xe0
         &aacute; \xe1 &acirc; \xe2 &atilde; \xe3 &auml; \xe4 &aring; \xe5
         &aelig; \xe6 &ccedil; \xe7 &egrave; \xe8 &eacute; \xe9 &ecirc; \xea
         &euml; \xeb &igrave; \xec &iacute; \xed &icirc; \xee &iuml; \xef
         &eth; \xf0 &ntilde; \xf1 &ograve; \xf2 &oacute; \xf3 &ocirc; \xf4
         &otilde; \xf5 &ouml; \xf6 &divide; \xf7 &oslash; \xf8 &ugrave; \xf9
         &uacute; \xfa &ucirc; \xfb &uuml; \xfc &yacute; \xfd &thorn; \xfe
         &yuml; \xff &fnof; \u192 &Alpha; \u391 &Beta; \u392 &Gamma; \u393 &Delta; \u394
         &Epsilon; \u395 &Zeta; \u396 &Eta; \u397 &Theta; \u398 &Iota; \u399
         &Kappa; \u39A &Lambda; \u39B &Mu; \u39C &Nu; \u39D &Xi; \u39E
         &Omicron; \u39F &Pi; \u3A0 &Rho; \u3A1 &Sigma; \u3A3 &Tau; \u3A4
         &Upsilon; \u3A5 &Phi; \u3A6 &Chi; \u3A7 &Psi; \u3A8 &Omega; \u3A9
         &alpha; \u3B1 &beta; \u3B2 &gamma; \u3B3 &delta; \u3B4 &epsilon; \u3B5
         &zeta; \u3B6 &eta; \u3B7 &theta; \u3B8 &iota; \u3B9 &kappa; \u3BA
         &lambda; \u3BB &mu; \u3BC &nu; \u3BD &xi; \u3BE &omicron; \u3BF
         &pi; \u3C0 &rho; \u3C1 &sigmaf; \u3C2 &sigma; \u3C3 &tau; \u3C4
         &upsilon; \u3C5 &phi; \u3C6 &chi; \u3C7 &psi; \u3C8 &omega; \u3C9
         &thetasym; \u3D1 &upsih; \u3D2 &piv; \u3D6 &bull; \u2022
         &hellip; \u2026 &prime; \u2032 &Prime; \u2033 &oline; \u203E
         &frasl; \u2044 &weierp; \u2118 &image; \u2111 &real; \u211C
         &trade; \u2122 &alefsym; \u2135 &larr; \u2190 &uarr; \u2191
         &rarr; \u2192 &darr; \u2193 &harr; \u2194 &crarr; \u21B5
         &lArr; \u21D0 &uArr; \u21D1 &rArr; \u21D2 &dArr; \u21D3 &hArr; \u21D4
         &forall; \u2200 &part; \u2202 &exist; \u2203 &empty; \u2205
         &nabla; \u2207 &isin; \u2208 &notin; \u2209 &ni; \u220B &prod; \u220F
         &sum; \u2211 &minus; \u2212 &lowast; \u2217 &radic; \u221A
         &prop; \u221D &infin; \u221E &ang; \u2220 &and; \u2227 &or; \u2228
         &cap; \u2229 &cup; \u222A &int; \u222B &there4; \u2234 &sim; \u223C
         &cong; \u2245 &asymp; \u2248 &ne; \u2260 &equiv; \u2261 &le; \u2264
         &ge; \u2265 &sub; \u2282 &sup; \u2283 &nsub; \u2284 &sube; \u2286
         &supe; \u2287 &oplus; \u2295 &otimes; \u2297 &perp; \u22A5
         &sdot; \u22C5 &lceil; \u2308 &rceil; \u2309 &lfloor; \u230A
         &rfloor; \u230B &lang; \u2329 &rang; \u232A &loz; \u25CA
         &spades; \u2660 &clubs; \u2663 &hearts; \u2665 &diams; \u2666
         &quot; \x22 &amp; \x26 &lt; \x3C &gt; \x3E O&Elig; \u152 &oelig; \u153
         &Scaron; \u160 &scaron; \u161 &Yuml; \u178 &circ; \u2C6
         &tilde; \u2DC &ensp; \u2002 &emsp; \u2003 &thinsp; \u2009
         &zwnj; \u200C &zwj; \u200D &lrm; \u200E &rlm; \u200F &ndash; \u2013
         &mdash; \u2014 &lsquo; \u2018 &rsquo; \u2019 &sbquo; \u201A
         &ldquo; \u201C &rdquo; \u201D &bdquo; \u201E &dagger; \u2020
         &Dagger; \u2021 &permil; \u2030 &lsaquo; \u2039 &rsaquo; \u203A
         &euro; \u20AC &apos; \u0027 &lrm; "" &rlm; "" ‬ "" ‭ ""
         ‮ "" — \u2014
      }
      set content [string map $escapes $content]
           regsub -all -- {&[a-zA-Z]+?;} [utfdecodeclean $content] {?} content
           regsub -all -- {&#(\d{1,3});} $content {[format %c [scan \1 %d]]} content
           return [subst $content]
   }

   proc otYoutube {nick uhost hand chan text} {
      if {![channel get $chan ourtubeXTRA]} {
              if {$text eq "enable"} {
                      channel set $chan +ourtubeXTRA
                           return
                     } else {
            putquick "NOTICE $nick :${ourtubeXTRA::youtubelogo} \00311:: \00315$chan has this command disabled."
         }
         if {[matchattr $hand n]} {
            putquick "NOTICE $nick :You can enable it directly typing: /msg $chan !youtube enable"
         }
         return
           }

      global ourtubeXTRA::ytrest protection

           #This is a generic protection to prevent flood
           #No utimer required

           if {![info exists protection ]} {
              set protection [clock seconds]
           } else {
              if {![string is digit -strict $protection ]} {

                      set protection [clock seconds]

                   } else {
                           set time [expr [clock seconds]-$protection]

                           if { $time >= $ytrest } {
                              set protection [clock seconds]
                           } else {
               set floodsecs [expr [clock seconds]-$protection]
               putserv "NOTICE $nick :${ourtubeXTRA::youtubelogo} \00311:: \00315Flood protection triggered: $floodsecs second(s) remaining."
                                   return
                           }
                   }
           }      

           if {$text eq ""} {
                   putquick "NOTICE $nick :${ourtubeXTRA::youtubelogo} \00311:: \00315Usage: !youtube <search criteria>"
                   return
           }

      if {[string length $text] <= 3} {
                   putquick "NOTICE $nick :${ourtubeXTRA::youtubelogo} \00311:: \00315Error - Search parameter '$text' is too short."
                   return
      }

           set data [ourtubeXTRAGet $text $chan]
       
             if {[string length $data] == 0} {
         set data "I was unable to connect to that website. Probably I get timeout."
         return
           }

      #Display results

           foreach line $data {
         putquick "PRIVMSG $chan :$line"
           }   
   }


     
   proc ourtubeXTRAGet {ask chan} {
      global ourtubeXTRA::max_links
      set resultcount "0"
           regsub -all -- {\s+} $ask "" search
           set search [http::formatQuery $search]


           set token [http::geturl http://www.youtube.com/results?search_query=$search&sm=12]

           upvar #0 $token state
           set data $state(body)

           regsub -all {\n|\t|\r} $data "" data

           set ncode ""
           regexp {[0-9]{3}} $state(http) ncode
           if {$ncode eq ""} {
              set ncode $state(http)
           }
       

      set ytlist ""
           switch -- $ncode {
            "200" {
               regexp {<p class=\"num-results\">About <strong>(.*?)</strong>} $data "" uresultcount
                        
               regexp -- {<ol id=\"search-results\" class=\"result-list\">(.*?)$} $data -> data
            
               set videos [ regexp -all -inline {<li class=\"yt-lockup clearfix yt-uix-tile result-item-padding yt-lockup-video yt-lockup-tile\"(.*?)<li

class=\"yt-lockup clearfix yt-uix-tile result-item-padding yt-lockup-video yt-lockup-tile\"} $data ]

               regsub -all {,} $uresultcount "" resultcount

                         set total [expr [llength $videos] /2]

                         if {$total >= $max_links } {
                      set numitems $max_links
               } else {
                      set numitems $total
                         }

               if {$resultcount == 0} {
                      set numitems 0
                      set yts "${ourtubeXTRA::youtubelogo} \00311:: \00315$uresultcount \00315result(s) found for items matching '$ask'."
               } else {
                                set yts "${ourtubeXTRA::youtubelogo} \00311:: \00315Showing \00300$numitems \00315of \00300$uresultcount \00315result(s) found

for items matching '$ask'."
            }
            putquick "PRIVMSG $chan :$yts"
            putlog "Search URL: http://www.youtube.com/results?search_query=$search&sm=12"
                      set i 2
            set vcount 1
            if {$resultcount > 0} {
                         foreach {id line} $videos {
                                 set map ""
                            set title ""
                  set title_parsed ""
                            set description "This video does not have any description"
                  set description_parsed ""
                            set added "Unknown"
                            set viewcount "0"
                            set author "Unknown"
                            set link ""
                  set duration ""
                  set item_info ""
                  set item_badges ""
                  set badge_info ""
                  set badge ""
                  set badge1 ""
                  set badge2 ""
                  set badgelist ""

                                 foreach {entity number} [regexp -all -inline {&#(\d+);} $line] {
                                       lappend map $entity [format \\u%04x [scan $number %d]]
                  }

                  set line [string map [subst -nocomm -novar $map] $line]

                  regexp -all -- {<div class=\"yt-lockup-content\">(.*?)$} $line "" item_info
                                 regexp {title=\"(.*?)\"} $item_info "" title

                  set tlen [ string length $title ]
                    
                  set title_parsed [url_search $tlen "07" "style_ul" $title]

                  regexp {href=\"(.*?)\"} $item_info "" link

                  regexp {<div class=\"yt-lockup-description yt-ui-ellipsis yt-ui-ellipsis-2\" dir=\"ltr\">(.*?)</div>} $item_info "" description

                  regsub -all -- {(<[^>]+>)|(\t)} $description "" description 

                  set description [ string trimleft $description " " ]

                  regexp {<span class=\"video-time\">(.*?)</span>} $line "" duration

                  regexp {data-name=\"\">(.*?)</a></li><li>(.*?)\<} $line "" author added                              
                  regexp {data-name=\"\">(.*?)</a></li><li>(.*?)</li><li>(.*?) view} $line "" author added viewcount
               



                  regexp -all -- {li class=\"yt-lockup-badge-item\">(.*?)$} $line "" item_info

                  while {[regexp {<span class=\"yt-badge \" >(.*?)</span></li>} $item_info "" badge1]} {
                     if { $badge1 != "" } {
                        if {[ string first $badge1 $badgelist 0] == -1 } {
                           set badgelist [ append badgelist "$badge1 " ]
                        }
                        regsub -- {<span class=\"yt-badge \" >(.*?)</span></li>} $item_info "" item_info
                        set badge1 ""
                     }
                  }

                  set badgelist [ string trimright $badgelist " " ]
                  set badgelist [ create_badgelist $badgelist ]
               
                  set tlen [ string length $description ]
               
                       set description_parsed [url_search $tlen "07" "style_ul" $description]
                                 set yturl "http://www.youtube.com$link"

                  set description_parsed [string range $description_parsed 0 100]

                  set ytoutput [string map [list "<vcount>" $vcount "<link>" $yturl "<title>" $title_parsed "<author>" $author "<added>" $added

"<views>" $viewcount "<duration>" $duration "<badgelist>" $badgelist "<description>" $description_parsed] ${ourtubeXTRA::outputsearch}]

                  set ytoutput [utfdecode $ytoutput]
                  set ytoutput [encoding convertto utf-8 $ytoutput]

                                 lappend ytlist $ytoutput
                                 if {$i > $ourtubeXTRA::max_links } {
                                        break
                                 }
                  incr i
                  incr vcount
               }
            }

            return $ytlist
         }
         "404" {
                 http::cleanup $token
                      return [list "No such file or webpage."]
              }
                  default {
                      http::cleanup $token
                      return [list "unforeseen circumstance. Server responded: $ncode"]
                  }
      }   
   }

     
   proc otPub {nick uhost hand chan text} {
      if {![channel get $chan ourtubeXTRA]} {
                  return
           }

      global ourtubeXTRA::ytrest protection
       
           set webTarget [lsearch -inline [split $text] {*http://*.youtube.*/watch?*}]
           
      if {([info exists protection]) && ([string is digit -strict $protection ])} {
                       
         set rest [expr [clock seconds]-$protection]

                  if { $rest >= $ytrest } {
                      set protection ""
         }
           } else {
                  set protection ""
           }


           if {$webTarget ne ""} {
              if {![regexp -nocase {^(http://)?([^/:]+)(:([0-9]+))?(/.*)?$} $webTarget]} {
                      return
                  }

                  if { $protection ne "" } {
            set floodsecs [expr [clock seconds]-$protection]
            putserv "NOTICE $nick :${ourtubeXTRA::youtubelogo} \00311:: \00315Flood protection triggered: $floodsecs second(s) remaining."
                      return
                  }

                  set protection [clock seconds]

                  set data [otGet $webTarget]
                  if {[string length $data] == 0} {
                      set data "I was not able to reach Youtube's link. Probably I get a timeout. Try again."
                  }

         foreach line [ split $data \n ] {
                     putquick "PRIVMSG $chan :$line"
         }

                  utimer $ytrest [list set protection ""]
              }
   }
     
   proc otGet {web} {

           set token [http::geturl $web -timeout 4000]
   
           upvar #0 $token state

           set data $state(body)

           regsub -all {\n|\t|\r} $data "" data

           set ncode ""
           regexp {[0-9]{3}} $state(http) ncode
           if {$ncode eq ""} {
              set ncode $state(http)
           }

           switch -- $ncode {
              "200" {

         }
                  "302" {
                      foreach {flag value} $state(meta) {
                             if {$flag eq "Location"} {
                                 http::cleanup $token
                                 return "Invalid youtube link: $ncode"
                             }
                      }
                  }
         "303" {
                      http::cleanup $token
                      return "That video does not exists. Server responded: $ncode"
                  }
                  "404" {
                      http::cleanup $token
                      return "$ncode - $web - No such webpage"
                  }
                  default {
                      http::cleanup $token
                      return "unforeseen circumstances. Server responded: $ncode"
                  }
      }
   
      set durationfmt "%M:%S"
      set badges ""
      set badge1 ""
      set badge2 ""
      set numcomments 0

      set agestrict ""

      set title ""
      set title_parsed ""
      set description "This video does not have a description"
      set full_description "This video does not have a description"
           if {[regexp {<meta property=\"og:title\" content=\"(.*?)\">} $data "" title]} {
         set tlen [ string length $title ]
      
         set title_parsed [url_search $tlen "07" "style_ul" $title]
      }

      if {[regexp {<meta property=\"og:video:height\" content=\"(.*?)\">} $data "" videoHeight]} {
         if { $videoHeight >= 720 } { set badges [ append badges "HD "] }
      }

      if {[regexp {<meta property=\"og:restrictions:age\" content=\"(.*?)\">} $data "" agestrict]} {
         set badges [ append badges "$agestrict "]
      }

      set badges [ string trimright $badges " " ]

           regexp {<meta property=\"og:description\" content=\"(.*?)\">} $data "" description

      #regexp -all {<p id=\"eow-description\" >(.*?)</p>} $data "" full_description
      regexp -all {<div id=\"watch-description-text\">(.*?)</div>} $data "" full_description
   
      #regsub -all -- {\<[^\>]*\>|\t} $full_description "" full_description

      #set full_description [encoding convertfrom utf-8 $full_description ]
      set full_description [string trimleft $full_description " "]

      #regsub -all {<(.|\n)*?>} $full_description "" full_description

      #regsub -all -- {(<[^>]+>)|(\t)} $full_description "" full_description 

      set tlen [string length $full_description]

      set full_description [url_search $tlen "07" "style_ul" $full_description]

      set full_description_parsed [parse_text 380 $full_description]

      if {[string length $description] <= 1} { set description "This video does not have a description" }
   
      set badgelist [ create_badgelist $badges ]

      set tlen [ string length $description ]

      set description_parsed [url_search $tlen "07" "style_ul" $description]

      if {[llength $full_description_parsed] == 0 } {
         set full_description_parsed {}
         lappend full_description_parsed $description_parsed
      }

      set added "Unknown"
      regexp {<span id=\"eow-date\" class=\"watch-video-date\" >(.*?)</span>} $data "" added

      set views "0"
           regexp {<span class=\"watch-view-count \" >(.*?)</span>} $data "" views
      set views [string trimright $views " views" ]
      set views [string trimleft $views]
      set added [string trimleft $added]

           if {![regexp -all {<span class=\"likes-count\">(.*?)</span>} $data "" likes]} { set likes 0 }
           if {![regexp -all {<span class=\"dislikes-count\">(.*?)</span>} $data "" dislikes]} { set dislikes 0 }

      set author "Unknown"
             regexp -all {data-name=\"watch\">(.*?)</a><span class=\"yt-user-separator\">} $data "" author
      regexp -all {data-name=\"watch\">(.*?)</a>} $data "" author


      if {![regexp -all {<meta itemprop=\"duration\" content=\"PT(.*?)M(.*?)S\">} $data "" videomins videosecs]} {
         set videomins 0
         set videosecs 0
      }
   
      set totalseconds [expr {($videomins * 60) + $videosecs}]
      if { $videomins >= 60 } { set durationfmt "%H:%M:%S" }
      set duration [clock format $totalseconds -format $durationfmt]

           set yt_output [string map [list "<title>" $title "<author>" $author "<added>" $added "<views>" $views "<duration>" $duration "<likes>" $likes "<dislikes>"

$dislikes "<badgelist>" $badgelist "<full_description>" $description_parsed] ${ourtubeXTRA::outputline} ]

      return [ utfdecode [encoding convertto utf-8 $yt_output] ]
   }


   putlog "\002\00304,00You\00300,04Tube\017 \00311:: \002\00300*Loaded* \002\00315ourtubeXTRA 1.0 by \002WazzaUK\002\00311 :: \00315based on ourtube by \002Hackemate\002."

   set Loaded 1
}
Back to top
View user's profile Send private message
bunnybump
Voice


Joined: 17 Aug 2012
Posts: 9

PostPosted: Sat Mar 08, 2014 3:19 am    Post subject: KEEP IN FAILED Reply with quote

i dunno how could you made this script works. i've try it so many times but it keeps FAILED. how can i use your script for my eggdrop? what command that i have to use so i can use it as what you said?

please check the screenshot below (and probably you would be happy to made a test with your own script right before post it in here):

Quote:

_________________
In the Beginning... Was the Command Line
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber