thansk for post my script )))
SET
set l [regexp -all -inline -- {<meta name="title" content="(.*?)">.*?<span class="watch-view-count">.*?<strong>(.*?)</strong>} $data]
To
set l [regexp -all -inline -- {<title>(.*?)</title>.*?<span class="watch-view-count " >(.*?)</span>} $data]
4:06:34pm / * <iRoc> http://www.youtube.com/watch?v=NsmJ_l4jZFQ
4:06:36pm / * <iB0T> Tom Ford OWN Visionaires documentary - YouTube' ( 41 minutes 33 seconds ) Viewed 302.397
(16/05/2012, 09:44)CrazyCat a écrit : Je remonte ce sujet un peu ancien car j'ai eu hier la demande d'avoir un script fonctionnel pour les urls normales et raccourcies de youtube (en youtu.be).
Après quelques efforts, voici ce que ça a donné:
tcl
package require http bind PUBM - * mu proc mu {nick uhost hand chan text} { set web(page) http://www.youtube.com set watch [regexp -nocase -- {\/watch\?v\=([^\s]{11})} $text youtubeid] if { $watch == 0 } { set watch [regexp -nocase -- {youtu\.be\/([^\s]{11})} $text a youtubeid] set youtubeid "/watch?v=$youtubeid" } set logoo "\002\00301,00You\00300,04Tube\002\017" if {$watch && $youtubeid != ""} { putlog "$web(page)$youtubeid" set agent "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1" set t [::http::config -useragent $agent] set t [::http::geturl "$web(page)$youtubeid" -timeout 30000] set data [::http::data $t] ::http::cleanup $t set l [regexp -all -inline -- {<meta name="title" content="(.*?)">.*?<span class="watch-view-count">.*?<strong>(.*?)</strong>} $data] regexp {"length_seconds": (\d+),} $data "" length foreach {black a b c d e} $l { set a [string map -nocase {\&\#39; \x27 & \x26 " \x22} $a] set b [string map [list \n ""] $b] set c [string map [list \n ""] $c] set d [string map [list \n ""] $d] set e [string map -nocase {\&\#39; \x27 & \x26 " \x22} $e] regsub -all {<.*?>} $a {} a regsub -all {<.*?>} $b {} b regsub -all {<.*?>} $c {} c regsub -all {<.*?>} $d {} d regsub -all {<.*?>} $e {} e putserv "PRIVMSG $chan :$a' ( [duration $length] ) Viewed $b" proc duration {s} { variable etube set hours [expr {$s / 3600}] set minutes [expr {($s / 60) % 60}] set seconds [expr {$s % 60}] set res "" if {$hours != 0} {append res "$hours hours"} if {$minutes != 0} {append res " $minutes minutes"} if {$seconds != 0} {append res " $seconds seconds"} return $res } } } } putlog "youtitle.tcl loaded..."
J'espère que cela en aidera certains.
SET
set l [regexp -all -inline -- {<meta name="title" content="(.*?)">.*?<span class="watch-view-count">.*?<strong>(.*?)</strong>} $data]
To
set l [regexp -all -inline -- {<title>(.*?)</title>.*?<span class="watch-view-count " >(.*?)</span>} $data]
4:06:34pm / * <iRoc> http://www.youtube.com/watch?v=NsmJ_l4jZFQ
4:06:36pm / * <iB0T> Tom Ford OWN Visionaires documentary - YouTube' ( 41 minutes 33 seconds ) Viewed 302.397
(27/03/2013, 18:10)Hitsu a écrit : Bonjour,
je viens de tester ce script et voici le résultat :
[17:06] <Hitsu> http://www.youtube.com/watch?v=KY44zvhWhp4
[17:06] <VDMBot> Lil Wayne - Love Me (Explicit) ft. Drake, Future' ( 4 minutes 26 seconds ) Viewed Publiée le 14 févr. 2013
Il semblerait que le nombre de vues n'apparaisse pas...
Une idée ? J'ai regardé au niveau du $b mais je suis perdu...
Ah oui, et il semblerait que le script rajoute un ' à la fin de chaque titre cf " Future' "