OmerTu / GoogleHomeKodi

Control kodi via Google Home / Assistant
522 stars 163 forks source link

New Spanish broker #296

Closed pacocf closed 4 years ago

pacocf commented 4 years ago

I have translated a new broker file in Spanish, which I want to share with you. I adjust it.

es.txt

However, I can´t run it. I follow the next steps:

Anyone know what I'm doing wrong?

Thank you very much!! Feel free to use the es.json file, if you think it's correct

keydon commented 4 years ago

Hey thank you for the spanish version, I will gladly add it to the project very soon. So you wont have to do special stuff to use this app in spanish.

But nevertheless, I am not sure why it does not work for you with your custom language file. Maybe you named it wrong, it should say es.json and not es.txt Your file works for me, here is how I have done it:

mkdir /storage/ghk-config
cd /storage/ghk-config
wget https://github.com/OmerTu/GoogleHomeKodi/files/4603417/es.txt
mv es.txt es.json

docker run \
   --detach \
   --publish 8099:8099 \
   --restart always \
     -v "/storage/ghk-config:/config:ro" \
   -e KODI_PROTOCOL="http" \
   -e KODI_IP="openelec" \
   -e KODI_PORT="8080" \
   -e KODI_USER="keydon" \
   -e KODI_PASSWORD="mypassword" \
   -e AUTH_TOKEN="mytoken" \
   --name googlehomekodi \
   omertu/googlehomekodi

If the problem persists, attach the logs plz (docker logs googlehomekodi)

pacocf commented 4 years ago

Thanks for your quick response. The problem didn´t be the file format (.txt). I have to transform mi es.json to es.txt because github messages doesn´t let me load .json files. But I had to implement the file wrongly. I had used your method and now it run ok. Now, I noticed that I have to change some things in the new es.json file. I send you the new version when I finish it. Thanks for all.

keydon commented 4 years ago

glad you got it working :)

uNbAs commented 4 years ago

Good morning!

Thanks for great projet and for new broker (pacocf). I have a problem when I say "kodi (reproduce|inicia $movie)"

The log in docker say this: ==== BEGIN === route: /broker Broker processing phrase: 'reproduce avatar' (es) request failed route: /broker query: { phrase: 'reproduce avatar', lang: 'es' } error: Error: Broker unknown phrase: 'reproduce avatar' (es) at exports.processRequest (/home/node/app/broker.js:94:11) at /home/node/app/server.js:48:9 at Layer.handle [as handle_request] (/home/node/app/node_modules/express/lib/router/layer.js:95:5) at next (/home/node/app/node_modules/express/lib/router/route.js:137:13) at next (/home/node/app/node_modules/express/lib/router/route.js:131:14) at next (/home/node/app/node_modules/express/lib/router/route.js:131:14) at next (/home/node/app/node_modules/express/lib/router/route.js:131:14) at next (/home/node/app/node_modules/express/lib/router/route.js:131:14) at next (/home/node/app/node_modules/express/lib/router/route.js:131:14) at next (/home/node/app/node_modules/express/lib/router/route.js:131:14) body: { token: 'a2f84**64674c', kodiid: 'kodi' } versions: { node: '14.1.0', v8: '8.1.307.31-node.32', uv: '1.37.0', zlib: '1.2.11', brotli: '1.0.7', ares: '1.16.0', modules: '83', nghttp2: '1.40.0', napi: '6', llhttp: '2.0.4', openssl: '1.1.1g', cldr: '36.1', icu: '66.1', tz: '2019c', unicode: '13.0' }

I execute docker in openmediavault from Docker Hub and add new broker in /config with name es.json I need make more changes?

pacocf commented 4 years ago

Hello uNbas, te escribo es español puesto que si estas usando este broker es por algo. Lo primero es que el broker que he mandado es una prueba inicial, no pude comprobar su funcionamiento porque tenia problemas para la inclusión del archivo en el contendor docker, que Lukas ya me ha solventado. En cualquier caso, quiero revisar todos los comandos a ver si funcionan y enviar una versión definitiva. Respecto a tu caso en concreto, en el fichero no esta incluida la opción reproducir o reproduce, gran fallo por mi parte. Prueba con estas incia | lanza | pon | play| reinicia , que son las que están incluidas a ver si te funciona, y de paso dime si lo hacen. Incluiré la palabra "reproduce" en la versión mejorada. saludos.

uNbAs commented 4 years ago

Buenas Paco.

En el broker, en el apartado de movies lo he colocado asi:

"kodiPlayMovie": "(reproduce|incia|lanza|pon|play|reinicia) (?.+)",

Con esto en teoria deberia de entender la palabra reproduce, el caso es que haciendo mas pruebas me ha funcionado bien, iba a comentarlo justo ahora. Que no sabia debido a que podia haber fallado (¿quizas la tarea de ifttt?) pero ahora funciona bien.

Si quieres que te eche un cable, dimelo y me pongo con ello, con esto de la cuarentena estoy poniendome con estos temas.

De hecho antes de descubrir este proyecto, iba a ponerme con otro llamado NodeRed pero no se hasta que punto se alcanzaria un legunaje "natural"

Actualmente con hassio y kodi, para ver los canales de PVR llamamos a los canales de diveras maneras "hey google pon al ferreras" (esto activaria la sexta), hey google activa a los frikis (cambiaria a TNT) aunque tambien le decimos hey google pon tnt|fox|accion|la sexta

Tengo que tratear mas con IFTTT a ver si se puede alcanzar frases mas naturales. Lo dicho si quieres probar cosas, o ayuda ...

pacocf commented 4 years ago

Buenas uNbAs de nuevo, gracias por tu respuesta. Yo ayer tuve de nuevo problemas de conexión con el .json, y no se por qué. Trataré de averiguarlo. Pero soy muy novato en esto y me cuesta. Aparte trabajo desde casa y tengo pongo tiempo, pero me gusta aprender. Si pudieses ir probando las distintas ordenes que he puesto sería estupendo, incluso proponer algunas nuevas que no se me hayan ocurrido. Ya lo del ferreras, me parece excesivo, jajajaj un saludo.

uNbAs commented 4 years ago

Yo tambien trabajo desde casa, con esta tesitura ... Hace bastante tiempo con Tasker y Autovoice tenia algo similar. Lo de ferreras fue de cachondeo, pero es que ese hombre siempre esta pongas cuando pongas la sexta ... jajjajaj asi que nos parecio gracioso.

Estoy probando con kodi reproduce nuevo episodio de the wire, para que reproduzca el ultimo sin ver, pero no lo he conseguido, si quieres sube el broker a tu git, y te voy a haciendo request en cuanto consiga cosas.

keydon commented 4 years ago

do you guys need help with regex?

uNbAs commented 4 years ago

Hi @Keydon

For now I think we are managing. I am slowly translating the broker regex en.js and checking that they work.

I've only encountered one problem, but I'm still not sure why ...

For example In the en.js there is: "kodiPlayAlbum": "play the album (? . +)", "kodiPlayArtist": "play the artist (? . +)",

In the es.js broker I would like to write something like this: "kodiPlayAlbum": "inicia|pon|lanza the album (? . +)", "kodiPlayArtist": "inicia|pon|lanza the artist (? . +)",

In your languaje, inicia|pon|lanza its similar to init|put|launch

but when there are phrases that match the same word, the broker always chooses the first one in the list.

Does this also happen in your language?

keydon commented 4 years ago

try putting parenthesis around the different options. ie. (inicia|pon|lanza) the album (?.+) you only can omit the parenthesis, if each "option" is the whole command.

and yes the order of the phrases is important for matching. They should not be sorted alphabetically but in order from most specific to least specific.

uNbAs commented 4 years ago

Thanks Keydon! I try to proof

pacocf commented 4 years ago

do you guys need help with regex?

Hi Lukas, I attached as a .txt file the last and definitive version of es.json. I have to mention to you two things: 1.- When I say "mostrar "carpeta"" (Show "windows") I have to say the name of folder in english. I don´t know if there is a solution, but I think that the folder tree in kodi is in english and we can´t modify it. 2.- On the other hand, sometimes, and only sometimes, the navigation orders does not understand the numbers. I pasted a log in which "abajo 2" is "down 2" in english.

==== BEGIN === route:  /broker
Broker processing phrase: 'abajo 2' (es)
redirecting request to: 'kodiNavDown
Navigate down request received
no number given, falling back: 1
Sending command to kodi http://192.168.1.100:8080/jsonrpc:
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "Input.Down"
}
==== END === route:  /broke

Thanks a lot. es.txt

keydon commented 4 years ago

kodiNavDown supports to be executed without a number. So just saying abajo should ideally work as intended. The missing amount would default to 1. And this is exactly what happens with your faulty regex, it doesent "see" the number.

your original regex is (abajo|baja) ( (?<q>.+))?. I will now simplify the regex but keep the error to make my point more easily to abajo ( (?<q>.+))?. The later group ending with a ? is an optional group and in your case the regex does NOT match with the optional group, leading to no number beeing detected. It does not match because of too many spaces in your regex. The phrase abajo 2 conains exactly one space. But for the regex abajo ( (?<q>.+))? to match that very same phrase would have to have two spaces!

Since incoming phrases would never have additional spaces we can fix the regex by removing one obsolete space like so abajo( (?<q>.+))?. This regex now would just look for "abajo" and then optionally it would look for a number separated by exactly one space. In conclusion we end up with (abajo|baja)( (?<q>.+))?, which should work fine for both abajo 2 and abajo :)

keydon commented 4 years ago

and for the first question. yes, currently the kodiShowWindow command is only supported in english. We would need to add some translation layer for this windowmapping. I will look into it someday :)

https://github.com/OmerTu/GoogleHomeKodi/blob/ad44c2842ef04478f2854454ba2fdd6cdb382d4d/kodi-connection/windows.js#L24-L130

pacocf commented 4 years ago

kodiNavDown supports to be executed without a number. So just saying abajo should ideally work as intended. The missing amount would default to 1. And this is exactly what happens with your faulty regex, it doesent "see" the number.

your original regex is (abajo|baja) ( (?<q>.+))?. I will now simplify the regex but keep the error to make my point more easily to abajo ( (?<q>.+))?. The later group ending with a ? is an optional group and in your case the regex does NOT match with the optional group, leading to no number beeing detected. It does not match because of too many spaces in your regex. The phrase abajo 2 conains exactly one space. But for the regex abajo ( (?<q>.+))? to match that very same phrase would have to have two spaces!

Since incoming phrases would never have additional spaces we can fix the regex by removing one obsolete space like so abajo( (?<q>.+))?. This regex now would just look for "abajo" and then optionally it would look for a number separated by exactly one space. In conclusion we end up with (abajo|baja)( (?<q>.+))?, which should work fine for both abajo 2 and abajo :)

Thank for all. I foward the "es" file with the spaces problem solved.

es.txt