Advertisement
Guest User

OurtubeXTRA 1.0

a guest
Mar 2nd, 2014
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.49 KB | None | 0 0
  1. setudef flag ourtubeXTRA
  2.  
  3. global ourtubeXTRA tcl_platform
  4.  
  5. #Flood Protection: after show a link, will ignore all links few seconds
  6. # This means 1 link per 10 seconds.
  7. set ourtubeXTRA(rest) 10
  8.  
  9. #What language you can receive the youTube data? (if works heh)
  10. set ourtubeXTRA(lang) en
  11.  
  12. #Limit of links at same time
  13. set ourtubeXTRA(max) 5
  14.  
  15. #youtube logo
  16. set ourtubeXTRA(youtubelogo) "\002\00304,00You\00300,04Tube\017"
  17.  
  18. set ourtubeXTRA(output) "$ourtubeXTRA(youtubelogo) \00311:: \002\00309<title> \002\00311:: \00308Author: \00314<author> \00311:: \00308Added: \00314<added> \00311:: \00308Views:
  19.  
  20. \00314<views> \00311:: \00308Duration: \00314<duration> \00311:: \00308Likes: \00309<likes> \00311:: \00308Dislikes: \00304<dislikes> \00311::\002\00312 <badgelist>
  21.  
  22. \017\00314<description>"
  23.  
  24. set ourtubeXTRA(outputsearch) "\00309<title> \00311:: \00312\037<link>\003\037 \00311:: \00308Author: \00314<author> \00311:: \00308Added: \00314<added> \00311:: \00308Views:
  25.  
  26. \00314<views> \00311:: \00308Duration: \00314<duration> \00311::\002\00312 <badgelist>\017\00314<description>"
  27.  
  28. set ourtubeXTRA(author) "WazzaUK"
  29. set ourtubeXTRA(contact) "WazzaUK <wallison_uk@yahoo.co.uk>"
  30. set ourtubeXTRA(originalauthor) "HackeMate"
  31. set ourtubeXTRA(originalcontact) "HackeMate <Sentencia@eggdrop.es>"
  32. set ourtubeXTRA(name) "ourtubeXTRA"
  33. set ourtubeXTRA(projectName) "ourtubeXTRA"
  34. set ourtubeXTRA(version) "1.0"
  35. set ourtubeXTRA(package.http) [package require http]
  36. set ourtubeXTRA(protection) ""
  37.  
  38. if {$tcl_platform(os) eq "Linux"} {
  39. set platfrm "X11"
  40. } else {
  41. set platfrm $tcl_platform(os)
  42. }
  43.  
  44. 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
  45.  
  46. "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
  47.  
  48. bind pub - !youtube otYoutube
  49. bind pubm - *http://www.youtube.com/watch?* otPub
  50.  
  51.  
  52. proc create_badgelist {badges} {
  53. set badgelist ""
  54. if { [string length $badges] > 1} {
  55. foreach badge [split $badges] {
  56. if { $badge ne " " } {
  57. append badgelist "\[$badge\] "
  58. }
  59. }
  60. }
  61. return $badgelist
  62. }
  63.  
  64. proc url_search {maxlen color styles text} {
  65. set i 0
  66. set newtext ""
  67. set style_ul ""
  68. set style_bd ""
  69.  
  70.  
  71. if {![string is integer -strict $maxlen]} {set maxlen [ string length $text ] }
  72. if {($maxlen == "") || ($maxlen < 1)} {set maxlen [ string length $text ]}
  73.  
  74.  
  75. if {![string is alpha -strict $styles]} {set styles "style_ul"}
  76. if {[string match -nocase style_ul $styles]} {set style_ul "\037"}
  77. if {[string match -nocase style_bd $styles]} {set style_bd "\002"}
  78.  
  79.  
  80.  
  81. if {![string is integer -strict $color]} {set color "07"}
  82. if {($color < 0) || ($color > 15)} {set color 07}
  83.  
  84. foreach word [split $text] {
  85. set urlindex -1
  86. if {[string length $word] >= 5 && [regexp {(f|ht)tp(s|)://} $word] && ![regexp {://([^/:]*:([^/]*@|\d+(/|$))|.*/\.)} $word]} {
  87. set wprotocol ""
  88. regexp {(f|ht)tp(s|)://} $word "" wprotocol
  89. set urlindex [string first $wprotocol $word 0]
  90.  
  91. set newword [string range $word $urlindex [string length $word]]
  92. set oldlen [expr [string first $wprotocol $word 0] -1 ]
  93. set oldword [string range $word 0 $oldlen]
  94. incr i
  95. if { $urlindex > 0 } { append oldword " " }
  96. set word "$oldword\003${color}${style_bd}${style_ul}$newword\00314${style_bd}${style_ul}"
  97. }
  98. append newtext $word " "
  99. }
  100. return $newtext
  101. }
  102.  
  103. proc utfdecodeclean {string} {
  104. regsub -all -- {([\(\)\[\]\{\}\$\"\\])} $string {\\\1} string
  105. return $string
  106. }
  107.  
  108. proc utfdecode {content} {
  109. if {![regexp -- & $content]} {
  110. return $content
  111. }
  112.  
  113. set escapes {
  114. &nbsp; \xa0 &iexcl; \xa1 &cent; \xa2 &pound; \xa3 &curren; \xa4
  115. &yen; \xa5 &brvbar; \xa6 &sect; \xa7 &uml; \xa8 &copy; \xa9
  116. &ordf; \xaa &laquo; \xab &not; \xac &shy; \xad &reg; \xae
  117. &macr; \xaf &deg; \xb0 &plusmn; \xb1 &sup2; \xb2 &sup3; \xb3
  118. &acute; \xb4 &micro; \xb5 &para; \xb6 &middot; \xb7 &cedil; \xb8
  119. &sup1; \xb9 &ordm; \xba &raquo; \xbb &frac14; \xbc &frac12; \xbd
  120. &frac34; \xbe &iquest; \xbf &Agrave; \xc0 &Aacute; \xc1 &Acirc; \xc2
  121. &Atilde; \xc3 &Auml; \xc4 &Aring; \xc5 &AElig; \xc6 &Ccedil; \xc7
  122. &Egrave; \xc8 &Eacute; \xc9 &Ecirc; \xca &Euml; \xcb &Igrave; \xcc
  123. &Iacute; \xcd &Icirc; \xce &Iuml; \xcf &ETH; \xd0 &Ntilde; \xd1
  124. &Ograve; \xd2 &Oacute; \xd3 &Ocirc; \xd4 &Otilde; \xd5 &Ouml; \xd6
  125. &times; \xd7 &Oslash; \xd8 &Ugrave; \xd9 &Uacute; \xda &Ucirc; \xdb
  126. &Uuml; \xdc &Yacute; \xdd &THORN; \xde &szlig; \xdf &agrave; \xe0
  127. &aacute; \xe1 &acirc; \xe2 &atilde; \xe3 &auml; \xe4 &aring; \xe5
  128. &aelig; \xe6 &ccedil; \xe7 &egrave; \xe8 &eacute; \xe9 &ecirc; \xea
  129. &euml; \xeb &igrave; \xec &iacute; \xed &icirc; \xee &iuml; \xef
  130. &eth; \xf0 &ntilde; \xf1 &ograve; \xf2 &oacute; \xf3 &ocirc; \xf4
  131. &otilde; \xf5 &ouml; \xf6 &divide; \xf7 &oslash; \xf8 &ugrave; \xf9
  132. &uacute; \xfa &ucirc; \xfb &uuml; \xfc &yacute; \xfd &thorn; \xfe
  133. &yuml; \xff &fnof; \u192 &Alpha; \u391 &Beta; \u392 &Gamma; \u393 &Delta; \u394
  134. &Epsilon; \u395 &Zeta; \u396 &Eta; \u397 &Theta; \u398 &Iota; \u399
  135. &Kappa; \u39A &Lambda; \u39B &Mu; \u39C &Nu; \u39D &Xi; \u39E
  136. &Omicron; \u39F &Pi; \u3A0 &Rho; \u3A1 &Sigma; \u3A3 &Tau; \u3A4
  137. &Upsilon; \u3A5 &Phi; \u3A6 &Chi; \u3A7 &Psi; \u3A8 &Omega; \u3A9
  138. &alpha; \u3B1 &beta; \u3B2 &gamma; \u3B3 &delta; \u3B4 &epsilon; \u3B5
  139. &zeta; \u3B6 &eta; \u3B7 &theta; \u3B8 &iota; \u3B9 &kappa; \u3BA
  140. &lambda; \u3BB &mu; \u3BC &nu; \u3BD &xi; \u3BE &omicron; \u3BF
  141. &pi; \u3C0 &rho; \u3C1 &sigmaf; \u3C2 &sigma; \u3C3 &tau; \u3C4
  142. &upsilon; \u3C5 &phi; \u3C6 &chi; \u3C7 &psi; \u3C8 &omega; \u3C9
  143. &thetasym; \u3D1 &upsih; \u3D2 &piv; \u3D6 &bull; \u2022
  144. &hellip; \u2026 &prime; \u2032 &Prime; \u2033 &oline; \u203E
  145. &frasl; \u2044 &weierp; \u2118 &image; \u2111 &real; \u211C
  146. &trade; \u2122 &alefsym; \u2135 &larr; \u2190 &uarr; \u2191
  147. &rarr; \u2192 &darr; \u2193 &harr; \u2194 &crarr; \u21B5
  148. &lArr; \u21D0 &uArr; \u21D1 &rArr; \u21D2 &dArr; \u21D3 &hArr; \u21D4
  149. &forall; \u2200 &part; \u2202 &exist; \u2203 &empty; \u2205
  150. &nabla; \u2207 &isin; \u2208 &notin; \u2209 &ni; \u220B &prod; \u220F
  151. &sum; \u2211 &minus; \u2212 &lowast; \u2217 &radic; \u221A
  152. &prop; \u221D &infin; \u221E &ang; \u2220 &and; \u2227 &or; \u2228
  153. &cap; \u2229 &cup; \u222A &int; \u222B &there4; \u2234 &sim; \u223C
  154. &cong; \u2245 &asymp; \u2248 &ne; \u2260 &equiv; \u2261 &le; \u2264
  155. &ge; \u2265 &sub; \u2282 &sup; \u2283 &nsub; \u2284 &sube; \u2286
  156. &supe; \u2287 &oplus; \u2295 &otimes; \u2297 &perp; \u22A5
  157. &sdot; \u22C5 &lceil; \u2308 &rceil; \u2309 &lfloor; \u230A
  158. &rfloor; \u230B &lang; \u2329 &rang; \u232A &loz; \u25CA
  159. &spades; \u2660 &clubs; \u2663 &hearts; \u2665 &diams; \u2666
  160. &quot; \x22 &amp; \x26 &lt; \x3C &gt; \x3E O&Elig; \u152 &oelig; \u153
  161. &Scaron; \u160 &scaron; \u161 &Yuml; \u178 &circ; \u2C6
  162. &tilde; \u2DC &ensp; \u2002 &emsp; \u2003 &thinsp; \u2009
  163. &zwnj; \u200C &zwj; \u200D &lrm; \u200E &rlm; \u200F &ndash; \u2013
  164. &mdash; \u2014 &lsquo; \u2018 &rsquo; \u2019 &sbquo; \u201A
  165. &ldquo; \u201C &rdquo; \u201D &bdquo; \u201E &dagger; \u2020
  166. &Dagger; \u2021 &permil; \u2030 &lsaquo; \u2039 &rsaquo; \u203A
  167. &euro; \u20AC &apos; \u0027 &lrm; "" &rlm; "" &#8236; "" &#8237; ""
  168. &#8238; "" &#8212; \u2014
  169. }
  170. set content [string map $escapes $content]
  171. regsub -all -- {&[a-zA-Z]+?;} [utfdecodeclean $content] {?} content
  172. regsub -all -- {&#(\d{1,3});} $content {[format %c [scan \1 %d]]} content
  173. return [subst $content]
  174. }
  175.  
  176. proc otYoutube {nick uhost hand chan text} {
  177. global ourtubeXTRA
  178. if {![channel get $chan ourtubeXTRA]} {
  179. if {$text eq "enable"} {
  180. channel set $chan +ourtubeXTRA
  181. return
  182. } else {
  183. putquick "NOTICE $nick :$ourtubeXTRA(youtubelogo) \00311:: \00315$chan has this command disabled."
  184. }
  185. if {[matchattr $hand n]} {
  186. putquick "NOTICE $nick :You can enable it directly typing: /msg $chan !youtube enable"
  187. }
  188. return
  189. }
  190.  
  191. #This is a generic protection to prevent flood
  192. #No utimer required
  193.  
  194. if {![info exists ourtubeXTRA(protection)]} {
  195. set ourtubeXTRA(protection) [clock seconds]
  196. } else {
  197. if {![string is digit -strict $ourtubeXTRA(protection)]} {
  198. set ourtubeXTRA(protection) [clock seconds]
  199. } else {
  200. set time [expr [clock seconds]-$ourtubeXTRA(protection)]
  201. if {$time >= $ourtubeXTRA(rest)} {
  202. set ourtubeXTRA(protection) [clock seconds]
  203. } else {
  204. set floodsecs [expr [clock seconds]-$ourtubeXTRA(protection)]
  205. putserv "NOTICE $nick :$ourtubeXTRA(youtubelogo) \00311:: \00315Flood protection triggered: $floodsecs second(s) remaining."
  206. return
  207. }
  208. }
  209. }
  210.  
  211.  
  212. if {$text eq ""} {
  213. putquick "NOTICE $nick :$ourtubeXTRA(youtubelogo) \00311:: \00315Usage: !youtube <search criteria>"
  214. return
  215. }
  216.  
  217. if {[string length $text] <= 3} {
  218. putquick "NOTICE $nick :$ourtubeXTRA(youtubelogo) \00311:: \00315Error - Search parameter '$text' is too short."
  219. return
  220. }
  221.  
  222. set data [ourtubeXTRAGet $text]
  223.  
  224. if {[string length $data] == 0} {
  225. set data "I was unable to connect to that website. Probably I get timeout."
  226. return
  227. }
  228.  
  229. #Display results
  230. foreach line $data {
  231. putquick "PRIVMSG $chan :$line"
  232. }
  233. }
  234.  
  235.  
  236.  
  237. proc ourtubeXTRAGet {ask} {
  238. global ourtubeXTRA
  239. set resultcount "0"
  240. regsub -all -- {\s+} $ask "" search
  241. set search [http::formatQuery $search]
  242. set token [http::geturl http://www.youtube.com/results?search_query=$search&sm=12]
  243.  
  244. upvar #0 $token state
  245. set data $state(body)
  246.  
  247. #regsub -all {\s|\n|\r|\t|\f} $data "" data
  248.  
  249.  
  250. regsub -all {\n|\t|\r} $data "" data
  251.  
  252. set ncode ""
  253. regexp {[0-9]{3}} $state(http) ncode
  254. if {$ncode eq ""} {
  255. set ncode $state(http)
  256. }
  257.  
  258.  
  259. set list {}
  260. switch -- $ncode {
  261. "200" {
  262. regexp {<p class=\"num-results\">About <strong>(.*?)</strong>} $data "" uresultcount
  263.  
  264. regexp -- {<ol id=\"search-results\" class=\"result-list\">(.*?)$} $data -> data
  265.  
  266. 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
  267.  
  268. result-item-padding yt-lockup-video yt-lockup-tile\"} $data ]
  269.  
  270. regsub -all {,} $uresultcount "" resultcount
  271.  
  272. set total [expr [llength $videos] /2]
  273.  
  274. if {$total >= $ourtubeXTRA(max)} {
  275. set numitems $ourtubeXTRA(max)
  276. } else {
  277. set numitems $total
  278. }
  279.  
  280. if {$resultcount == 0} {
  281. set numitems 0
  282. set list [list "$ourtubeXTRA(youtubelogo) \00311:: \00315$uresultcount \00315result(s) found for items matching '$ask'."]
  283. } else {
  284. set list [list "$ourtubeXTRA(youtubelogo) \00311:: \00315Showing \00300$numitems \00315of \00300$uresultcount \00315result(s) found for
  285.  
  286. items matching '$ask'."]
  287. }
  288. putlog "Search URL: http://www.youtube.com/results?search_query=$search&sm=12"
  289. set i 2
  290. if {$resultcount > 0} {
  291. foreach {id line} $videos {
  292. set map {}
  293. set title ""
  294. set title_parsed ""
  295. set description "This video does not have any description"
  296. set description_parsed ""
  297. set added "Unknown"
  298. set viewcount "0"
  299. set author "Unknown"
  300. set link ""
  301. set duration ""
  302. set item_info ""
  303. set item_badges ""
  304. set badge_info ""
  305. set badge ""
  306. set badge1 ""
  307. set badge2 ""
  308. set badgelist ""
  309.  
  310. foreach {entity number} [regexp -all -inline {&#(\d+);} $line] {
  311. lappend map $entity [format \\u%04x [scan $number %d]]
  312. }
  313.  
  314. set line [string map [subst -nocomm -novar $map] $line]
  315.  
  316. regexp -all -- {<div class=\"yt-lockup-content\">(.*?)$} $line "" item_info
  317. regexp {title=\"(.*?)\"} $item_info "" title
  318.  
  319. set tlen [ string length $title ]
  320.  
  321. set title_parsed [url_search $tlen "07" "style_ul" $title]
  322.  
  323. regexp {href=\"(.*?)\"} $item_info "" link
  324.  
  325. regexp {<div class=\"yt-lockup-description yt-ui-ellipsis yt-ui-ellipsis-2\" dir=\"ltr\">(.*?)</div>} $item_info "" description
  326. set description [string trimleft $description " "]
  327.  
  328. regexp {<span class=\"video-time\">(.*?)</span>} $line "" duration
  329.  
  330. regexp {data-name=\"\">(.*?)</a></li><li>(.*?)</li><li>(.*?) view} $line "" author added viewcount
  331.  
  332.  
  333.  
  334. regexp -all -- {li class=\"yt-lockup-badge-item\">(.*?)$} $line "" item_info
  335.  
  336. while {[regexp {<span class=\"yt-badge \" >(.*?)</span></li>} $item_info "" badge1]} {
  337. if { $badge1 != "" } {
  338. if {[ string first $badge1 $badgelist 0] == -1 } {
  339. set badgelist [ append badgelist "$badge1 " ]
  340. }
  341. regsub -- {<span class=\"yt-badge \" >(.*?)</span></li>} $item_info "" item_info
  342. set badge1 ""
  343. }
  344. }
  345.  
  346. set badgelist [ string trimright $badgelist " " ]
  347. set badgelist [ create_badgelist $badgelist ]
  348.  
  349. set tlen [ string length $description ]
  350.  
  351. regsub -all -- {\<[^\>]*\>|\t} $description "" description
  352.  
  353. set description_parsed [url_search $tlen "07" "style_ul" $description]
  354. set yturl "http://www.youtube.com$link"
  355.  
  356. set output [string map [list "<title>" $title_parsed "<link>" $yturl "<author>" $author "<added>" $added "<views>" $viewcount
  357.  
  358. "<duration>" $duration "<badgelist>" $badgelist "<description>" $description_parsed] $ourtubeXTRA(outputsearch)]
  359. lappend list $output
  360. if {$i > $ourtubeXTRA(max)} {
  361. break
  362. }
  363. incr i
  364. }
  365. }
  366.  
  367. return [ utfdecode [encoding convertto utf-8 $list] ]
  368. }
  369. "404" {
  370. http::cleanup $token
  371. return [list "No such file or webpage."]
  372. }
  373. default {
  374. http::cleanup $token
  375. return [list "unforeseen circumstance. Server responded: $ncode"]
  376. }
  377. }
  378. }
  379.  
  380.  
  381. proc otPub {nick uhost hand chan text} {
  382. if {![channel get $chan ourtubeXTRA]} {
  383. return
  384. }
  385. global ourtubeXTRA
  386. set webTarget [lsearch -inline [split $text] {*http://*.youtube.*/watch?*}]
  387. if {([info exists ourtubeXTRA(protection)]) && ([string is digit -strict $ourtubeXTRA(protection)])} {
  388. set rest [expr [clock seconds]-$ourtubeXTRA(protection)]
  389. if {$rest >= $ourtubeXTRA(rest)} {
  390. set ourtubeXTRA(protection) ""
  391. }
  392. } else {
  393. set ourtubeXTRA(protection) ""
  394. }
  395.  
  396. if {$webTarget ne ""} {
  397. if {! [regexp -nocase {^(http://)?([^/:]+)(:([0-9]+))?(/.*)?$} $webTarget]} {
  398. return
  399. }
  400. if {$ourtubeXTRA(protection) ne ""} {
  401. set floodsecs [expr [clock seconds]-$ourtubeXTRA(protection)]
  402. putserv "NOTICE $nick :$ourtubeXTRA(youtubelogo) \00311:: \00315Flood protection triggered: $floodsecs second(s) remaining."
  403. return
  404. }
  405. set ourtubeXTRA(protection) [clock seconds]
  406. set data [otGet $webTarget]
  407. if {[string length $data] == 0} {
  408. set data "I was not able to reach Youtube's link. Probably I get a timeout. Try again."
  409. }
  410.  
  411. foreach line [ split $data \n ] {
  412. putquick "PRIVMSG $chan :$line"
  413. }
  414. utimer $ourtubeXTRA(rest) [list set ourtubeXTRA(protection) ""]
  415. }
  416. }
  417.  
  418. proc otGet {web} {
  419. global ourtubeXTRA
  420.  
  421. set token [http::geturl $web -timeout 4000]
  422.  
  423. upvar #0 $token state
  424.  
  425. set data $state(body)
  426.  
  427. regsub -all {\n|\t|\r} $data "" data
  428.  
  429. set ncode ""
  430. regexp {[0-9]{3}} $state(http) ncode
  431. if {$ncode eq ""} {
  432. set ncode $state(http)
  433. }
  434.  
  435. switch -- $ncode {
  436. "200" {
  437.  
  438. }
  439. "302" {
  440. foreach {flag value} $state(meta) {
  441. if {$flag eq "Location"} {
  442. http::cleanup $token
  443. return "Invalid youtube link: $ncode"
  444. }
  445. }
  446. }
  447. "303" {
  448. http::cleanup $token
  449. return "That video does not exists. Server responded: $ncode"
  450. }
  451. "404" {
  452. http::cleanup $token
  453. return "$ncode - $web - No such webpage"
  454. }
  455. default {
  456. http::cleanup $token
  457. return "unforeseen circumstances. Server responded: $ncode"
  458. }
  459. }
  460.  
  461. set durationfmt "%M:%S"
  462. set badges ""
  463. set badge1 ""
  464. set badge2 ""
  465.  
  466. set agestrict ""
  467.  
  468. set title ""
  469. set title_parsed ""
  470. set description "This video does not have a description"
  471.  
  472. if {[regexp {<meta property=\"og:title\" content=\"(.*?)\">} $data "" title]} {
  473. set tlen [ string length $title ]
  474.  
  475. set title_parsed [url_search $tlen "07" "style_ul" $title]
  476. }
  477.  
  478. if {[regexp {<meta property=\"og:video:height\" content=\"(.*?)\">} $data "" videoHeight]} {
  479. if { $videoHeight >= 720 } { set badges [ append badges "HD "] }
  480. }
  481.  
  482. if {[regexp {<meta property=\"og:restrictions:age\" content=\"(.*?)\">} $data "" agestrict]} {
  483. set badges [ append badges "$agestrict "]
  484. }
  485.  
  486. set badges [ string trimright $badges " " ]
  487.  
  488. regexp {<meta property=\"og:description\" content=\"(.*?)\">} $data "" description
  489.  
  490. #regexp -all {<p id=\"eow-description\" >(.*?)</p>} $data "" full_description
  491. regexp -all {<div id=\"watch-description-text\">(.*?)</div>} $data "" full_description
  492.  
  493. #regsub -all -- {\<[^\>]*\>|\t} $full_description "" full_description
  494.  
  495. #set full_description [encoding convertfrom utf-8 $full_description ]
  496. set full_description [string trimleft $full_description " "]
  497.  
  498. #regsub -all {<(.|\n)*?>} $full_description "" full_description
  499.  
  500. #regsub -all -- {(<[^>]+>)|(\t)} $full_description "" full_description
  501.  
  502. set tlen [ string length $full_description ]
  503.  
  504. set full_description_parsed [url_search $tlen "07" "style_ul" $full_description]
  505.  
  506. if {[string length $description] == 0} { set description "This video does not have a description" }
  507.  
  508. set badgelist [ create_badgelist $badges ]
  509.  
  510. set tlen [ string length $description ]
  511.  
  512. set description_parsed [url_search $tlen "07" "style_ul" $description]
  513.  
  514. set added "Unknown"
  515. regexp {<span id=\"eow-date\" class=\"watch-video-date\" >(.*?)</span>} $data "" added
  516.  
  517. set views "0"
  518. regexp {<span class=\"watch-view-count \" >(.*?)</span>} $data "" views
  519. set views [string trimright $views " views" ]
  520. set views [string trimleft $views]
  521.  
  522. if {![regexp -all {<span class=\"likes-count\">(.*?)</span>} $data "" likes]} { set likes 0 }
  523. if {![regexp -all {<span class=\"dislikes-count\">(.*?)</span>} $data "" dislikes]} { set dislikes 0 }
  524.  
  525. set author "Unknown"
  526. regexp -all {data-name=\"watch\">(.*?)</a><span class=\"yt-user-separator\">} $data "" author
  527. regexp -all {data-name=\"watch\">(.*?)</a>} $data "" author
  528.  
  529. if {![regexp -all {<meta itemprop=\"duration\" content=\"PT(.*?)M(.*?)S\">} $data "" videomins videosecs]} {
  530. set videomins 0
  531. set videosecs 0
  532. }
  533.  
  534. set totalseconds [expr {($videomins * 60) + $videosecs}]
  535. if { $videomins >= 60 } { set durationfmt "%H:%M:%S" }
  536. set duration [clock format $totalseconds -format $durationfmt]
  537.  
  538. set yt_output [string map [list "<title>" $title_parsed "<author>" $author "<added>" $added "<views>" $views "<duration>" $duration "<likes>" $likes "<dislikes>"
  539.  
  540. $dislikes "<badgelist>" $badgelist "<description>" $description_parsed] $ourtubeXTRA(output)]
  541.  
  542. return [ utfdecode [encoding convertto utf-8 $yt_output] ]
  543. }
  544.  
  545. 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."
  546.  
  547. set ourtubeXTRA(Loaded) 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement