Problème d'accent avec shoutcast.tcl
#4
Bonjour CrazyCat ,
l'eggdrop lit les titres de la shoutcast sur la page admin et les ressorts sur mon #chan je met le code au cas ou :

TCL
# shoutcast.tcl --
#
# Copyright (C) 2010 - 2011 Dj_KennY
# 
# The shoutcast.tcl V0.9.3 is free software: you can redistribute it
# and/or modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
# 
# The shoutcast.tcl is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with the shoutcast.tcl. If not,
#    see <http://www.gnu.org/licenses/>.
# 
# 
# 
# Contact (2011)
#   - Dj_KennY   <guillaume@djkenny.net>
 
 
namespace eval ::sc {
	package require http
	package require msgcat
	variable sc

	# Configuration mot de passe/ip/port du serveur 
	# annonce:
	# 1- le bot annonce les morceaux sur le salon. 
	# 0- le bot n'annonce pas les morceaux.
	# il est important de laisser le "\" à la fin de chaque lignes!!
	# kpl: faut-il kicker la pl 1-oui / 0-non
	array set sc [list\
		adminpass monpasse \
		ip monip \
		port leport \
		lien url \
		annonce 1 \
		kpl 1 \
	]

	# Salon d'administration de la radio
	variable achan #radio

	# Salons par défaut ou le bot annonce les morceaux
	# Seulement pour le premier lancement!!
	# les salons seront stocker dans le fichier shoutcast.chan 
	variable rchan "#radios"

	# Méssages
	# Auditeurs
	::msgcat::mcset fr m0 "auditeurs %d (%d)"
	# Lancement de la radio
	::msgcat::mcset fr m1 "La radio vient d'être lancée."
	# Arret de la radio
	::msgcat::mcset fr m2 "La radio vient d'être arretée."
	# Annonces
	::msgcat::mcset fr m3 "En ce moment à l'antenne >> %s"
	# Biterate
	::msgcat::mcset fr m4 "bitrate: %d kb/s"
	# dédicaces
	::msgcat::mcset fr m5 "Tu as oublié de mettre ta dédicace"
	::msgcat::mcset fr m6 "La radio est arretée."
	::msgcat::mcset fr m7 "Ta dédicace à bien été enregistrée. Elle sera diffusée d'ici quelques instants."
	::msgcat::mcset fr m8 "\[Shoutcast\] dédicace de %s : %s"
	::msgcat::mcset fr m9 "dédicace de %s - %s"
	# !dj
	::msgcat::mcset fr m10 "Actuellement, l'Animateur est >> %s"
	::msgcat::mcset fr m11 "Actuellement, tu écoutes la Playlist."
	# !offair
	::msgcat::mcset fr m12 "\[Animateur\] %s vient de quitter les platines \[Animateur\]"
	::msgcat::mcset fr m13 "Le dj est déjà %s"
	# !onair
	::msgcat::mcset fr m14 "Bonne Anime."
	::msgcat::mcset fr m15 "%s vient de prendre le contrôle des platines"
	::msgcat::mcset fr m16 "\[Animateur\] %s vient de prendre le controle des platines \[Animateur\]"
	# !titre
	::msgcat::mcset fr m17 "Vous écoutez >> %s"
	# !radio
	::msgcat::mcset fr m18 "Pour nous écouter >> %s"

 
	# Binds
	bind time - "* * * * *" [namespace current]::controle
	bind pub A !onair [namespace current]::setdjp
	bind msg A onair [namespace current]::setdjm
	bind pub A !offair [namespace current]::unsetdjp
	bind msg A offair [namespace current]::unsetdjm
 
	bind msg B radioadd [namespace current]::addchan
	bind msg B radiodel [namespace current]::delchan
	bind msg B radiolist [namespace current]::listchan
 
	bind pub - !dj [namespace current]::djp
	bind msg - dj [namespace current]::djm
	bind pub - !dedi [namespace current]::dedip
	bind msg - dedi [namespace current]::dedim
	bind pub - !titre [namespace current]::titre
	bind pub - !radio [namespace current]::url
 
	bind nick - * [namespace current]::nkchg
 
	bind evnt - save [namespace current]::savechan
 
	::msgcat::mclocale fr
	
	# Ne pas modifier
	variable file [file join [pwd] [file dirname [info script]] shoutcast.chan]
	if ![file exists $file] {
		catch {open $file w} a
		catch {close $a}
	} else {
		set a [open $file r+]
		set c [gets $a]
		close $a
		if ![string equal $c ""] {set rchan $c}
	}
 
}
 
proc sc::savechan event {
	variable file
	variable rchan
	if [string equal $rchan ""] return
	set a [open $file w+]
	puts $a [join $rchan]
	close $a
	putlog "\[Shoutcast\] Sauvegarde de la liste des salons"
}
 
proc sc::addchan {nick host hand arg} {
	variable rchan
	set chan [string tolower [lindex $arg 0]]
	if {$chan==""} {putserv "NOTICE $nick :\002Syntaxe:\002 /msg $::botnick radioadd #salon";return}
	if {[lsearch -nocase $rchan $chan]!=-1} {putserv "NOTICE $nick :Ce salon est déjà dans la liste.";return}
	lappend rchan $chan
	if ![validchan $chan] {channel add $chan;savechannels}
	putserv "NOTICE $nick :Salon ajouté avec succès."
	return 1
}
 
proc sc::delchan {nick host hand arg} {
	variable rchan
	set chan [string tolower [lindex $arg 0]]
	if {$chan==""} {putserv "NOTICE $nick :\002Syntaxe:\002 /msg $::botnick radiodel #salon";return}
	if {[set a [lsearch -nocase $rchan $chan]]==-1} {putserv "NOTICE $nick :Ce salon n'est pas dans la liste.";return}
	set rchan [lreplace $rchan $a $a]
	if [validchan $chan] {channel remove $chan;savechannels}
	putserv "NOTICE $nick :Salon supprimé avec succès."
	return 1
}
 
proc sc::listchan {nick host hand arg} {
	variable rchan
	putserv "notice $nick :[join $rchan]"
	return 1
}
 
proc sc::url {nick host hand chan arg} {
	variable sc
	putserv "PRIVMSG $chan :[::msgcat::mc m18 $sc(lien)]"
}
 
proc sc::nkchg {nick host hand chan nnick} {
	variable dj
	if {[info exists dj] && [string equal -nocase $dj $nick]} {
		set dj $nnick
	}
}
 
proc sc::send {type arg} {
	variable rchan
	if [string equal $rchan ""] {set rchan [channels]}
	putserv "PRIVMSG [join $rchan ,] :$arg"
#	foreach c $rchan {
#		putserv "PRIVMSG $c :$arg"
#	}
}
 
proc sc::equal {vname1 vname2} {
	upvar 1 $vname1 v1
	upvar 1 $vname2 v2
	expr {[info exists v1] && [string equal $v1 $v2]}
}
 
proc sc::getinfo {type varname} {
	upvar info info
	uplevel 1 [list regexp "<$type>*(\[^<\]*)" $info _all_ $varname]
}
 
proc ::sc::controle {1 2 3 4 5} {
	variable sc
	variable title
	variable listeners
	variable rlisteners
	variable status
	variable bitrate
	variable stitle
	variable sgenre
	variable lastmusic
	variable achan

#	putlog "\00310shoutcast: vérification du stream"
 
	set url "http://[set sc(ip)]:[set sc(port)]/admin.cgi?pass=[set sc(adminpass)]&mode=viewxml&page=0&sid=1"
	set httpconfig [::http::config -useragent "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"]
	set marque [http::geturl $url -timeout 30000]
	set info [http::data $marque]
	http::cleanup $marque
	set info [sc::clean $info]
 
	if [getinfo STREAMSTATUS s] {
		if ![equal status s] {
			set status $s
			if $s {
				putserv "PRIVMSG $achan :[::msgcat::mc m1]"
			} else {
				putserv "PRIVMSG $achan :[::msgcat::mc m2]"
			}
		}
		if !$s return
	}
 
	if {[getinfo SONGTITLE t] && ![equal title t]} {
		set title $t
		lappend lastmusic $t
		if {[llength $lastmusic]>3} {
			set lastmusic [lreplace $lastmusic 0 0]
		}
		if [set sc(annonce)] {send PRIVMSG [::msgcat::mc m3 [string tolower $t]]}
	}
	set x 0
	if {[getinfo CURRENTLISTENERS l] && ![equal listeners l]} {
		set listeners $l
		set x 1
	}
	if {[getinfo REPORTEDLISTENERS rl] && ![equal rlisteners rl]} {
		set rlisteners $rl
		set x 1
	}
	if $x {
		putserv "PRIVMSG $achan :[::msgcat::mc m0 $l $rl]"
	}
	if {[getinfo BITRATE br] && ![equal bitrate br]} {
		set bitrate $br
		putserv "PRIVMSG $achan :[::msgcat::mc m4 $br]"
	}
	if {[getinfo SERVERTITLE st] && ![equal stitle st]} {
		set stitle $st
		set x 1
	}
	if {[getinfo SERVERGENRE sg] && ![equal sgenre sg]} {
		set sgenre $sg
		set x 1
	}
}
 
proc sc::titre {nick host hand chan arg} {
	variable status
	variable title
	variable rchan
	if {[info exists status] && !$status} return
	if {$rchan!="" && [lsearch -nocase $rchan $chan]==-1} return
	putserv "NOTICE $nick :[::msgcat::mc m17 $title]"
}
 
proc sc::dedim {nick host hand arg} {
	dedi $nick $arg
}
 
proc sc::dedip {nick host hand chan arg} {
	variable rchan
	if {$rchan!="" && [lsearch -nocase $rchan $chan]==-1} return
	dedi $nick $arg
}
 
proc sc::dedi {nick arg} {
	variable dj
	variable status
	if {$arg == ""} { putserv "NOTICE $nick :[::msgcat::mc m5]";return}
	if {[info exists status] && !$status} {putserv "NOTICE $nick :[::msgcat::mc m6]";return}
	putserv "NOTICE $nick :[msgcat::mc m7]"
	putlog [::msgcat::mc m8 $nick $arg]
	putserv "PRIVMSG $dj :[::msgcat::mc m9 $nick $arg]" 
}
 
proc sc::djm {nick host hand arg} {
	dj $nick
}
 
proc sc::djp {nick host hand chan arg} {
	variable rchan
#	if {$rchan!="" && [lsearch -nocase $rchan $chan]==-1} return
	dj $nick
}
 
proc sc::dj nick {
	variable dj
	if [info exists dj] {
		putserv "NOTICE $nick :[::msgcat::mc m10 $dj]"
	} else {
		putserv "NOTICE $nick :[::msgcat::mc m11]"
	}
}
 
proc sc::unsetdjm {nick host hand arg} {
	unsetdj $nick [lindex $arg 0]
}
 
proc sc::unsetdjp {nick host hand chan arg} {
	unsetdj $nick [lindex $arg 0]
}
 
proc sc::unsetdj {nick {djnick {}}} {
	variable dj
	send PRIVMSG [::msgcat::mc m12 $dj]
	unset -nocomplain dj
}
 
proc sc::setdjm {nick host hand arg} {
	setdj $nick [lindex $arg 0]
}
 
proc sc::setdjp {nick host hand chan arg} {
	setdj $nick [lindex $arg 0]
}
 
proc sc::setdj {nick {djnick {}}} {
	variable sc
	variable dj
	variable achan
 
	if [string equal $djnick ""] {set djnick $nick}
	if {[info exists dj] && [string equal -nocase $dj $djnick]} {
		putserv "NOTICE $nick :[::msgcat::mc m13 $dj]"
		return
	}
	set dj $djnick
 
	if [set sc(kpl)] {
		set url "http://[set sc(ip)]:[set sc(port)]/admin.cgi?pass=[set sc(adminpass)]&mode=kicksrc"
		set httpconfig [::http::config -useragent "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"]
		set marque [http::geturl $url -timeout 30000]
		http::cleanup $marque
	}
 
	putserv "NOTICE $djnick :[::msgcat::mc m14]"
	putserv "PRIVMSG $achan :[::msgcat::mc m15 $dj]"
	send PRIVMSG [::msgcat::mc m16 $dj]
}
 
proc sc::clean arg {
	string map [list \
		"&#x3C;" < \
		"&#x3E;" > \
		"&#x26;" + \
		"&#x22;" \" \
		"&#x27;" ' \
		"&#x96;" - \
		"&#xB7;" · \
		"&#xDF;" ß \
		"&#xE1;" á \
		"&#xE0;" à \
		"&#xE2;" â \
		"&#xE4;" ä \
		"&#xC0;" À \
		"&#xC3;" Ã \
		"&#xC4;" Ä \
		"&#xE9;" é \
		"&#xE8;" è \
		"&#xEA;" ê \
		"&#xEB;" ë \
		"&#xEE;" î \
		"&#xEF;" ï \
		"&#xED;" í \
		"&#xF4;" ô \
		"&#xF6;" ö \
		"&#xD4;" Ô \
		"&#xD6;" Ö \
		"&#xF9;" ù \
		"&#xFB;" û \
		"&#xFC;" ü \
		"&#xDB;" Û \
		"&#xDC;" Ü \
		"&#xFF;" ÿ \
		"&#xE7;" ç \
		"&#xC7;" Ç \
		"&#xc9;" É \
		"&#xb0;" ° \
		"'" \' \
		"'" \' \
		""" \' \
		"&" & \
		"[" ( \
		"\" / \
		"]" ) \
		"{" ( \
		"}" ) \
		"£" £ \
		"¨" ¨ \
		"©" © \
		"«" « \
		"­" "­" \
		"®" ® \
		"´" ´ \
		"·" · \
		"¹" ¹ \
		"»" » \
		"¼" ¼ \
		"½" ½ \
		"¾" ¾ \
		"À" À \
		"Á" Á \
		"Â" Â \
		"Ã" Ã \
		"Ä" Ä \
		"Å" Å \
		"Æ" Æ \
		"Ç" Ç \
		"È" È \
		"É" É \
		"Ê" Ê \
		"Ë" Ë \
		"Ì" Ì \
		"Í" Í \
		"Î" Î \
		"Ï" Ï \
		"Ð" Ð \
		"Ñ" Ñ \
		"Ò" Ò \
		"Ó" Ó \
		"Ô" Ô \
		"Õ" Õ \
		"Ö" Ö \
		"×" × \
		"Ø" Ø \
		"Ù" Ù \
		"Ú" Ú \
		"Û" Û \
		"Ü" Ü \
		"Ý" Ý \
		"Þ" Þ \
		"ß" ß \
		"à" à \
		"á" á \
		"â" â \
		"ã" ã \
		"ä" ä \
		"å" å \
		"æ" æ \
		"ç" ç \
		"è" è \
		"é" é \
		"ê" ê \
		"ë" ë \
		"ì" ì \
		"í" í \
		"î" î \
		"ï" ï \
		"ð" ð \
		"ñ" ñ \
		"ò" ò \
		"ó" ó \
		"ô" ô \
		"õ" õ \
		"ö" ö \
		"÷" ÷ \
		"ø" ø \
		"ù" ù \
		"ú" ú \
		"û" û \
		"ü" ü \
		"ý" ý \
		"þ" þ \
		"&lt;" < \
		"&gt;" > \
		"&agrave;" à \
		"&agrave;" à \
		"&aacute;" á \
		"&acirc;" â \
		"&eacute;" ã \
		"&auml;" ä \
		"&aring;" å \
		"&aelig;" æ \
		"&ccedil;" ç \
		"&egrave;" è \
		"&eacute;" é \
		"&ecirc;" ê \
		"&euml;" ë \
		"&igrave;" ì \
		"&iacute;" í \
		"&icirc;" î \
		"&iuml;" ï \
		"&eth;" ð \
		"&ntilde;" ñ \
		"&ograve;" ò \
		"&oacute;" ó \
		"&ocirc;" ô \
		"&otilde;" õ \
		"&ouml;" ö \
		"&divide;" ÷ \
		"&oslash;" ø \
		"&ugrave;" ù \
		"&uacute;" ú \
		"&ucirc;" û \
		"&uuml;" ü \
		"&yacute;" ý \
		"&thorn;" þ \
		"&yuml;" ÿ \
		"&quot;" \" \
		"&amp;" & \
		"&euro;" \€ \
		"&oelig;" œ \
		"&Yuml;" Ÿ \
		"&nbsp;" " " \
		"&iexcl;" ¡ \
		"&cent;" ¢ \
		"&pound;" £ \
		"&curren;" ¤ \
		"&yen;" ¥ \
		"&brvbar;" ¦ \
		"&brkbar;" ¦ \
		"&sect;" § \
		"&uml;" ¨ \
		"&die;" ¨ \
		"&copy;" © \
		"&ordf;" ª \
		"&laquo;" « \
		"&not;" ¬ \
		"&shy;" ­- \
		"&reg;" ® \
		"&macr;" ¯ \
		"&hibar;" ¯ \
		"&deg;" ° \
		"&plusmn;" ± \
		"&sup2;" ² \
		"&sup3;" ³ \
		"&acute;" ´ \
		"&micro;" µ \
		"&para;" ¶ \
		"&middot;" · \
		"&cedil;" ¸ \
		"&sup1;" ¹ \
		"&ordm;" º \
		"&raquo;" » \
		"&frac14;" ¼ \
		"&frac12;" ½ \
		"&frac34;" ¾ \
		"&iquest;" ¿ \
		"&Agrave;" À \
		"&Aacute;" Á \
		"&Acirc;" Â \
		"&Atilde;" Ã \
		"&Auml;" Ä \
		"&Aring;" Å \
		"&AElig;" Æ \
		"&Ccedil;" Ç \
		"&Egrave;" È \
		"&Eacute;" É \
		"&Ecirc;" Ê \
		"&Euml;" Ë \
		"&Igrave;" Ì \
		"&Iacute;" Í \
		"&Icirc;" Î \
		"&Iuml;" Ï \
		"&ETH;" Ð \
		"&Dstrok;" Ð \
		"&Ntilde;" Ñ \
		"&Ograve;" Ò \
		"&Oacute;" Ó \
		"&Ocirc;" Ô \
		"&Otilde;" Õ \
		"&Ouml;" Ö \
		"&times;" × \
		"&Oslash;" Ø \
		"&Ugrave;" Ù \
		"&Uacute;" Ú \
		"&Ucirc;" Û \
		"&Uuml;" Ü \
		"&Yacute;" Ý \
		"&THORN;" Þ \
		"&szlig;" "ß"
	] $arg
}
 
putlog "ShoutcastCharger"



j'ai modifier une lignes pour que le bot puisse lire les titres:

TCL
set url "http://[set sc(ip)]:[set sc(port)]/admin.cgi?pass=[set sc(adminpass)]&mode=viewxml&page=0"



qui j'ai remplacé pas celle ci :

TCL
set url "http://[set sc(ip)]:[set sc(port)]/admin.cgi?pass=[set sc(adminpass)]&mode=viewxml&page=0&sid=1"




Après pour l'encodage au niveau de la shoutcast je ne vois pas comment voir ça , regarder le code source sur la page admin depuis mon navigateur peut être ?
Répondre Avertir


Messages dans ce sujet
RE: Problème d'accent avec shoutcast.tcl - par Naruto - 04/08/2013, 11:55

Atteindre :


Utilisateur(s) parcourant ce sujet : 1 visiteur(s)
Tchat 100% gratuit -Discutez en toute liberté