Bonjour a tous
J'avais un soucis avec le zurl.tcl un peu comem T3ns
J'ai DL celui posté par aliasangelius, et nikel.
Par contre me suis aperçu que lors d'un post d'un User, via ce lien alors que d'autres fonctionnent:
https://www.youtube.com/watch?v=vzAvnEV8Ctg
J'ai ce message en PL qui s'affiche (et rien sur le salon ou le lien youtube est lancé):
Tcl error [public_youtubedl]: can't read "res1": no such variable
Voila ou cela me renvoie dans le tcl posté par aliasangelius
PS: Les packages http et tls sont bien installés.
Merci à vous pour une info
J'avais un soucis avec le zurl.tcl un peu comem T3ns
J'ai DL celui posté par aliasangelius, et nikel.
Par contre me suis aperçu que lors d'un post d'un User, via ce lien alors que d'autres fonctionnent:
https://www.youtube.com/watch?v=vzAvnEV8Ctg
J'ai ce message en PL qui s'affiche (et rien sur le salon ou le lien youtube est lancé):
Tcl error [public_youtubedl]: can't read "res1": no such variable
Voila ou cela me renvoie dans le tcl posté par aliasangelius
PS: Les packages http et tls sont bien installés.
Merci à vous pour une info
tcl
set youtubedl(pattern) {https://.*youtube.*/watch\?(.*)v=([A-Za-z0-9_\-]+)}
set youtubedl(pattern1) {https://youtu.be/([A-Za-z0-9_\-]+)}
namespace eval youtubedl {
}
package require http
package require tls
bind pubm - * public_youtubedl
proc public_youtubedl {nick userhost handle channel args} {
global youtubedl botnick
set args [stripcode $args]
if {[regexp -nocase -- $youtubedl(pattern) $args match fluff video_id] || [regexp -nocase -- $youtubedl(pattern1) $args match video_id]} {
set useragent "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1"
::http::register https 443 [list tls::socket -tls1 1]
set url "https://www.youtube.com/watch?v=$video_id"
::http::config -useragent $useragent
catch { set token [::http::geturl "$url" -timeout 30000] }
if {([info exists token]) && ([::http::status $token] == "ok")} {
set retok [::http::data $token]
if {[string match "*<title>YouTube</title>*" $retok] } { return }
set res ""
regexp {<title>(.+?)</title>} $retok res
regsub -all {<title>} $res "" res
regsub -all {</title>} $res "" res
regsub -all -- "- YouTube" $res "" res
set result [youtubedl::string_filter $res]
regexp {<div class="watch-view-count">(.+?)</div>} $retok res1
regsub -all {<div class="watch-view-count">} $res1 "" res1
regsub -all {</div>} $res1 "" res1
regsub -all "Â " $res1 "," res1
set result1 [youtubedl::string_filter $res1]
regexp {<meta itemprop="duration" content="(.+?)">} $retok res2
regsub -all {<meta itemprop="duration" content=\"} $res2 "" res2
regsub -all {\">} $res2 "" res2
regsub -all {PT} $res2 "" res2
regsub -all {M} $res2 " minutes " res2
regsub -all {S} $res2 " secondes" res2
http::cleanup $token
http::unregister https
puthelp "privmsg $channel :\002\You\0034Tube\003 Titre\002 :$result \002Vues\002 :$res1 \002Durée\002 :$res2"
}
}
}
proc youtubedl::string_filter { str } {
set str [string map -nocase {
"à" "à " "à" "à " "á" "á" "â" "â"
"ã" "ã" "ä" "ä" "å" "Ã¥" "æ" "æ"
"ç" "ç" "è" "è" "é" "é" "ê" "ê"
"ë" "ë" "ì" "ì" "í" "Ã" "î" "î"
"ï" "ï" "ð" "ð" "ñ" "ñ" "ò" "ò"
"ó" "ó" "ô" "ô" "õ" "õ" "ö" "ö"
"÷" "÷" "ø" "ø" "ù" "ù" "ú" "ú"
"û" "û" "ü" "ü" "ý" "ý" "þ" "þ"
"ÿ" "ÿ" """ "\"" "&rsquo;" "'" "€" "€"
"&eacute;" "é" &agrave; "à " &egrave; "è"
"œ" "Å“" "Ÿ" "Ÿ" " " " " "¡" "¡"
"¢" "¢" "£" "£" "&amp;" "&" "¥" "Â¥"
"¦" "¦" "&brkbar;" "¦" "§" "§" "¨" "¨"
"¨" "¨" "©" "©" "ª" "ª" "«" "«"
"¬" "¬" "­" "Â-" "®" "®" "¯" "¯"
"&hibar;" "¯" "°" "°" "±" "±" "²" "²"
"³" "³" "´" "´" "µ" "µ" "¶" "¶"
"·" "·" "¸" "¸" "¹" "¹" "º" "º"
"»" "»" "¼" "¼" "½" "½" "¾" "¾"
"¿" "¿" "À" "À" "Á" "Ã" "Â" "Â"
"Ã" "Ã" "Ä" "Ä" "Å" "Ã…" "Æ" "Æ"
"Ç" "Ç" "È" "È" "É" "É" "Ê" "Ê"
"Ë" "Ë" "Ì" "ÃŒ" "Í" "Ã" "Î" "ÃŽ"
"Ï" "Ã" "Ð" "Ã" "Đ" "Ã" "Ñ" "Ñ"
"Ò" "Ã’" "Ó" "Ó" "Ô" "Ô" "Õ" "Õ"
"Ö" "Ö" "×" "×" "Ø" "Ø" "Ù" "Ù"
"Ú" "Ú" "Û" "Û" "Ü" "Ãœ" "Ý" "Ã"
"Þ" "Þ" "ß" "ß" "\r" "" "\t" ""
"'" "\'" "'" "\'" ">" ">" "<" "<"
""" "\'" "&" "&" "#91;" "\(" "\" "\/"
"]" ")" "{" "(" "}" ")" "£" "£"
"¨" "¨" "©" "©" "«" "«" "" "Â"
"®" "®" "´" "´" "·" "·" "¹" "¹"
"»" "»" "¼" "¼" "½" "½" "¾" "¾"
"À" "À" "Á" "Ã" "Â" "Â" "Ã" "Ã"
"Ä" "Ä" "Å" "Ã…" "Æ" "Æ" "Ç" "Ç"
"È" "È" "É" "É" "Ê" "Ê" "Ë" "Ë"
"Ì" "ÃŒ" "Í" "Ã" "Î" "ÃŽ" "Ï" "Ã"
"Ð" "Ã" "Ñ" "Ñ" "Ò" "Ã’" "Ó" "Ó"
"Ô" "Ô" "Õ" "Õ" "Ö" "Ö" "×" "×"
"Ø" "Ø" "Ù" "Ù" "Ú" "Ú" "Û" "Û"
"Ü" "Ãœ" "Ý" "Ã" "Þ" "Þ" "ß" "ß"
"à" "à " "á" "á" "â" "â" "ã" "ã"
"ä" "ä" "å" "Ã¥" "æ" "æ" "ç" "ç"
"è" "è" "é" "é" "ê" "ê" "ë" "ë"
"ì" "ì" "í" "Ã" "î" "î" "ï" "ï"
"ð" "ð" "ñ" "ñ" "ò" "ò" "ó" "ó"
"ô" "ô" "õ" "õ" "ö" "ö" "÷" "÷"
"ø" "ø" "ù" "ù" "ú" "ú" "û" "û"
"ü" "ü" "ý" "ý" "þ" "þ" "&" "&"
} $str]
regsub -all "<br />" $str " " str
return "${str}"
}
proc stripcode {str} {
return [regsub -all -- {(\d{1,2})?(,\d{1,2})?} $str ""]
}