Besoin d'aide pour TCL radionomy
#1
Bonjour à tous,

J'ai trouvé des morceaux de code par-ci par-là pour coder une TCL pour les webradio radionomy.
Mon but est de faire dans le même principe que la TCL shoutcast (avec les commandes !titre !dedi etc).

Pour l'instant la TCL ne fait qu'afficher le nom de la radio + le titre du son + l'auteur quand on lui demande ( !titre )

Voici le code source :

TCL
bind pub - "!titre" radio:titre
 
set url "http://api.radionomy.com/currentsong.cfm?radiouid=6d854cc4-bb57-4339-b09f-2e5290a0bfda&apikey=6d854cc4-bb57-4339-b09f-2e5290a0bfda&type=xml"
 
package require http
proc radio:titre { nick uhost handle chan args } {
   set page [::http::geturl $::url -timeout 3000]
   set html [::http::data $page]
   regexp -all -- {<title>(.+)?</title>} $html null title
   regexp -all -- {<radioname>(.+)?</radioname} $html null radio
   regexp -all -- {<artists>(.+)?</artists>} $html null artist
   putserv "PRIVMSG $chan :En cours sur \002 .::. [htmlentities_decode $radio] .::. \002: \002[htmlentities_decode $title]\002 par \002[htmlentities_decode $artist]\002"
}
 
proc htmlentities_decode { text } {
    regsub -all "&lt;" $text "<" text
    regsub -all "&gt;" $text ">" text
    regsub -all "&amp;" $text "et" text
    regsub -all "&quot;" $text "" text
    regsub -all "&Aacute;" $text "Á" text
    regsub -all "&Acirc;" $text "Â" text
    regsub -all "&Agrave;" $text "À" text
    regsub -all "&Aring;" $text "Å" text
    regsub -all "&Atilde;" $text "Ã" text
    regsub -all "&Auml;" $text "Ä" text
    regsub -all "&Ccedil;" $text "Ç" text
    regsub -all "&Eacute;" $text "É" text
    regsub -all "&Ecirc;" $text "Ê" text
    regsub -all "&Egrave;" $text "È" text
    regsub -all "&Iacute;" $text "Í" text
    regsub -all "&Icirc;" $text "Î" text
    regsub -all "&Igrave;" $text "í" text
    regsub -all "&Iuml;" $text "Ï" text
    regsub -all "&Ntilde;" $text "Ñ" text
    regsub -all "&Oacute;" $text "Ó" text
    regsub -all "&Ocirc;" $text "Ô" text
    regsub -all "&Ograve;" $text "Ò" text
    regsub -all "&Oslash;" $text "Ø" text
    regsub -all "&Otilde;" $text "Õ" text
    regsub -all "&Ouml;" $text "Ö" text
    regsub -all "&Uacute;" $text "Ê" text
    regsub -all "&Ucirc;" $text "Û" text
    regsub -all "&Ugrave;" $text "Ù" text
    regsub -all "&Uuml;" $text "í" text
    regsub -all "&Yacute;" $text "Ý" text
    regsub -all "&aacute;" $text "á" text
    regsub -all "&aelig;" $text "ae" text
    regsub -all "&oelig;" $text "oe" text
    regsub -all "&agrave;" $text "à" text
    regsub -all -nocase "&#xe0;" $text "à" text
    regsub -all "&aring;" $text "å" text
    regsub -all "&atilde;" $text "ã" text
    regsub -all "&auml;" $text "ä" text
    regsub -all "&ccedil;" $text "ç" text
    regsub -all -nocase "&#xe7;" $text "ç" text
    regsub -all "&eacute;" $text "é" text
    regsub -all -nocase "&#xe9;" $text "é" text
    regsub -all "&euml;" $text "ë" text
    regsub -all "&iacute;" $text "í" text
    regsub -all "&egrave;" $text "è" text
    regsub -all -nocase "&#xe8;" $text "è" text
    regsub -all "&igrave;" $text "ì" text
    regsub -all "&iuml;" $text "ï" text
    regsub -all "&ntilde;" $text "ñ" text
    regsub -all "&oacute;" $text "ó" text
    regsub -all "&ocirc;" $text "ô" text
    regsub -all -nocase "&#xf4;" $text "ô" text
    regsub -all "&acirc;" $text "â" text
    regsub -all -nocase "&#xe2;" $text "â" text
    regsub -all "&ecirc;" $text "ê" text
    regsub -all -nocase "&#xea;" $text "ê" text
    regsub -all "&ograve;" $text "ò" text
    regsub -all "&icirc;" $text "î" text
    regsub -all "&otilde;" $text "õ" text
    regsub -all "&ouml;" $text "ö" text
    regsub -all "&uacute;" $text "ú" text
    regsub -all "&ucirc;" $text "û" text
    regsub -all -nocase "&#xfb;" $text "û" text
    regsub -all "&ugrave;" $text "ù" text
    regsub -all -nocase "&#xf9;" $text "ù" text
    regsub -all "&uuml;" $text "ü" text
    regsub -all "&yuml;" $text "ÿ" text
    regsub -all "&AElig;" $text "AE" text
    regsub -all "&OElig;" $text "OE" text
    regsub -all "&reg;" $text "®" text
    regsub -all -nocase "&#xae;" $text "®" text
    regsub -all "&copy;" $text "©" text
    regsub -all -nocase "&#xa9;" $text "©" text
    regsub -all "&trade;" $text "â„¢" text
    regsub -all "&plusmn;" $text "±" text
    regsub -all "&deg;" $text "°" text
    regsub -all "&sup1;" $text "¹" text
    regsub -all "&apos;" $text "¹" text
    regsub -all "&sup2;" $text "²" text
    regsub -all "&sup3;" $text "³" text
    regsub -all "&times;" $text "×" text
    regsub -all "&divide;" $text "÷" text
    regsub -all "&euro;" $text "euro" text
    regsub -all -nocase "&laquo;" $text "\"" text
    regsub -all -nocase "&raquo;" $text "\"" text
    return $text
}



Je n'ai jamais codé de TCL et j'aimerais, pour le moment, modifier celle-ci de sorte que selon le salon où l'on tape !titre , l'eggy donne le titre de la radio adéquate.
Je ne sais pas si je suis très clair donc pour résumer, pour la même TCL :

- Sur #powersong : !titre donne : En cours sur  .::. Powersong-radio .::. : Dreamin¹ - par Youssoupha feat Indila et Skalpovich
- Sur #pouet : !titre donne : En cours sur  .::. Pouet .::. : blabla - par blabla
- Etc etc.

je vois un peu le truc (faire un set des différentes URL, récupérer dans une variable le chan d'où la commande a été lancée et en fonction, putserv sur le bon chan) mais je ne sais pas du tout comment faire.

Si quelqu'un pouvait m'aider, ça serait très sympa.

Cordialement
Répondre Avertir
#2
Voila un truc tout simple qui peut sûrement aller (pas testé):
TCL
bind pub - "!titre" radio:titre
 
set radio("#chan1") "6d854cc4-bb57-4339-b09f-2e5290a0bfda"
set radio("#chan2") "6d854cc4-bb57-4339-b09f-2e5290a0bfda"
 
package require http
proc radio:titre { nick uhost handle chan args } {
   if { ![info exists $::radio([string tolower $chan])] } { return 0 }
   set url [concat "http://api.radionomy.com/currentsong.cfm?radiouid=" $::radio([string tolower $chan]) "&apikey=" $::radio([string tolower $chan]) "&type=xml"]
   set page [::http::geturl $url -timeout 3000]
   set html [::http::data $page]
   regexp -all -- {<title>(.+)?</title>} $html null title
   regexp -all -- {<radioname>(.+)?</radioname} $html null radio
   regexp -all -- {<artists>(.+)?</artists>} $html null artist
   putserv "PRIVMSG $chan :En cours sur \002 .::. [htmlentities_decode $radio] .::. \002: \002[htmlentities_decode $title]\002 par \002[htmlentities_decode $artist]\002"
}


Répondre
#3
Merci CrazyCat Smile

Mais ça ne fonctionne pas Sad en party line voici l'erreur qu'il me donne :

Code :
[22:29:27] ‹Enjoy› [21:28:43] Tcl error [radio:titre]: can't read "::radio(#accueil)": no such element in array
[22:29:41] ‹Enjoy› [21:28:57] Tcl error [radio:titre]: can't read "::radio(#globalmusicradio)": no such element in array

Un problème dans le tableau si je pige bien ?
Par contre pour corriger ça de moi-même ... Mad

Bon, ça a le mérite de pas avoir fait peur à mon eggy comme ce matin quand j'ai essayé de le faire moi même (l'egg il s'est barré Razz)

Merci déjà pour tout !
Répondre Avertir
#4
En effet, deux erreurs dans mon code.
TCL
bind pub - "!titre" radio:titre
 
set radio(#chan1) "6d854cc4-bb57-4339-b09f-2e5290a0bfda"
set radio(#chan2) "6d854cc4-bb57-4339-b09f-2e5290a0bfda"
 
package require http
proc radio:titre { nick uhost handle chan args } {
   if { ![lsearch [string tolower $chan] [array names ::radio]] } { return 0 }
   set url [concat "http://api.radionomy.com/currentsong.cfm?radiouid=" $::radio([string tolower $chan]) "&apikey=" $::radio([string tolower $chan]) "&type=xml"]
   set page [::http::geturl $url -timeout 3000]
   set html [::http::data $page]
   regexp -all -- {<title>(.+)?</title>} $html null title
   regexp -all -- {<radioname>(.+)?</radioname} $html null radio
   regexp -all -- {<artists>(.+)?</artists>} $html null artist
   putserv "PRIVMSG $chan :En cours sur \002 .::. [htmlentities_decode $radio] .::. \002: \002[htmlentities_decode $title]\002 par \002[htmlentities_decode $artist]\002"
}


Répondre
#5
Salut CrazyCat,

Toujours le même problème d'array ... :/

Merci pour ce que tu fais c'est sympa :Smile
Répondre Avertir
#6
Tu as bien supprimé les guillemets dans les lignes set radio() ?
Tu as bien mis les noms des canaux en minuscule ?
Tu as rehash/restart l'eggdrop ?
Répondre
#7
Salut,

Oui, oui et oui :|
Répondre Avertir
#8
Voici ce que j'ai et qui fonctionne parfaitement:
TCL
bind pub - "!titre" radio:titre
 
set radio(#powersong) "6d854cc4-bb57-4339-b09f-2e5290a0bfda"
set radio(#pouet) "6d854cc4-bb57-4339-b09f-2e5290a0bfda"
 
package require http
proc radio:titre { nick uhost handle chan args } {
   if { [lsearch [string tolower $chan] [array names ::radio]] == -1} { return 0 }
   set url "http://api.radionomy.com/currentsong.cfm?"
   append url "radiouid=" $::radio([string tolower $chan]) "&apikey=" $::radio([string tolower $chan]) "&type=xml"
   putlog "url: $url"
   set page [::http::geturl $url -timeout 3000]
   set html [::http::data $page]
   regexp -all -- {<title>(.+)?</title>} $html null title
   regexp -all -- {<radioname>(.+)?</radioname} $html null radio
   regexp -all -- {<artists>(.+)?</artists>} $html null artist
   putserv "PRIVMSG $chan :En cours sur \002 .::. [htmlentities_decode $radio] .::. \002: \002[htmlentities_decode $title]\002 par \002[htmlentities_decode $artist]\002"
}



Par contre, il y avait une erreur dans le lsearch, est-ce que tu n'obtenais pas l'erreur lorsque tu faisais !titre dans un canal qui n'a pas de radio associée ?
Répondre
#9
Hello !

Désolé mais blocus !

J'ai un eggdrop v1.6.20.
J'envoie ton TCL, je me met en party line et je .rehash
Aucune erreur, et quand je fais !titre sur n'importe quel chan, aucun message en PL mais rien ne s'affiche.

J'ai essayé de ces 3 manières différentes le code :
Code :
set radio(#pouet) "6d854cc4-bb57-4339-b09f-2e5290a0bfda"

Code :
set radio(#pouet) 6d854cc4-bb57-4339-b09f-2e5290a0bfda

Code :
set radio(#pouet) {6d854cc4-bb57-4339-b09f-2e5290a0bfda}

voilà tout ce que je peux dire :l


Merci !
Répondre Avertir
#10
Remplace:
TCL
if { [lsearch [string tolower $chan] [array names ::radio]] == -1} { return 0 }


par:
TCL
if { [lsearch [string tolower $chan] [array names ::radio]] == -1} {
   putserv "PRIVMSG $chan: ***imposible de trouver $chan***"
   return 0
}


Répondre


Atteindre :


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