• 1
  • 12
  • 13
  • 14(current)
  • 15
  • 16
  • 176
Release Kanzi: Amazon Alexa skill for Kodi
(2016-10-17, 15:34)freemans13 Wrote: I've forked the excellent work done by m0ngr31 to add some PVR functionality.
This version let's you change channel ('alexa, ask kodi to watch ITV 2 plus 1').
It also lets you switch channel by calling out the progam name ('alexa, ask kodi to switch to Strictly Come Dancing'). This will scan the EPG to find the channels that are/will-be broadcasting the program and switches to the channel automatically.

What I want to do next is add the ability to record programs but the Kodi API doesn't give us this functionality yet Sad
It does appear that the up and coming Krypton will address this.
I'm considering adding the recording feature via tvheadend in the mean time. That does have an API that I could use but ideally I integrate with kodi.

https://github.com/freemans13/kodi-alexa-pvr

I'd rather this go back into m0ngr31 repository but not until I've ironed out the bugs and added all the functionality needed.

Hope this helps.

It would be good if you could get this to a stage where you can collaborate and add this to m0ngr31's repo. That is what Git is all about Smile

The basic workflow would be (in case you don't know) to fork the repo you want to collaborate on (keep the name the same to not confuse things). Create a new branch from the master branch and give it a name relevant to the feature you are adding e.g. "pvr-control". Make your changes on the new branch and then when ready you push the branch to your GitHub and then submit a pull request back to the original repo. It will only get merged when m0ngr31 is happy with it.

At the moment it seems that what you have so far is very specific to your local needs, with UK channels being hard coded into the wsgi.py file. So it not ready to be merged into the main repo just yet. But with a bit of polishing it could be.
Reply
(2016-10-18, 13:11)rlg6767 Wrote:
(2016-10-14, 14:32)jonjon Wrote: You would need to make a small adjustment to kodi.py to enable https

Change the following (currently at line 94)

Code:
url = "http://%s:%d/jsonrpc" % (KODI, PORT)

to

Code:
url = "https://%s:%d/jsonrpc" % (KODI, PORT)

You could install on the same machine, though to be safer and to have more control then install it on a Pi because your Kodi install is on what sounds an important box on of your network.

You can also deny connections from all IPs other than those you specify. Heroku might publish the ip range they use, AWS do and you can filter by service and region. This lets me only allow requests from AWS Lambda in the EU region

I've got the NGINX server running but am a bit stuck when it comes to the configuration for the Kodi webserver.

The below is for couchpotato, do you know how I should edit this to reflect a Kodi configuration (not on the same box....)? I know what the IP address and port are for the Kodi box, but a bit stuck with the rest of it.

Also, from a port forwarding perpsective, do I just allow 80 and 443 through to the NGINX server or do I also need to forward the inbound Kodi port to the NGINX server as well? A bit confused as to how that bit works.....

location /couchpotato {
proxy_pass http://127.0.0.1:5050;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}

Have you setup your LetsEncrypt certificate? If so then close those ports for the moment.

I have written a reply in more detail but I am waiting on some pull requests to be merged to save you making the minor tweaks yourself
Reply
(2016-10-18, 17:23)jonjon Wrote: Have you setup your LetsEncrypt certificate? If so then close those ports for the moment.

I have written a reply in more detail but I am waiting on some pull requests to be merged to save you making the minor tweaks yourself

Yep., LetsEncrypt certificate is up and running. I am able to browse to Plex using https://mydynamicdns/plex and login. Just can't seem to get it working for Kodi webserver.

Thanks for your input!! Much appreciated.
Kodi 16.1 on main HTPC Win 7 64-bit, 8 GB RAM, Quad Core 2.4 Ghz
3 x Pi2 running Kodi 16.1 (OSMC)
TVHeadend PVR server providing Freeview HD and Freesat HD
Reply
(2016-10-18, 13:17)jonjon Wrote:
(2016-10-17, 15:34)freemans13 Wrote: I've forked the excellent work done by m0ngr31 to add some PVR functionality.
This version let's you change channel ('alexa, ask kodi to watch ITV 2 plus 1').
It also lets you switch channel by calling out the progam name ('alexa, ask kodi to switch to Strictly Come Dancing'). This will scan the EPG to find the channels that are/will-be broadcasting the program and switches to the channel automatically.

What I want to do next is add the ability to record programs but the Kodi API doesn't give us this functionality yet Sad
It does appear that the up and coming Krypton will address this.
I'm considering adding the recording feature via tvheadend in the mean time. That does have an API that I could use but ideally I integrate with kodi.

https://github.com/freemans13/kodi-alexa-pvr

I'd rather this go back into m0ngr31 repository but not until I've ironed out the bugs and added all the functionality needed.

Hope this helps.

It would be good if you could get this to a stage where you can collaborate and add this to m0ngr31's repo. That is what Git is all about Smile

The basic workflow would be (in case you don't know) to fork the repo you want to collaborate on (keep the name the same to not confuse things). Create a new branch from the master branch and give it a name relevant to the feature you are adding e.g. "pvr-control". Make your changes on the new branch and then when ready you push the branch to your GitHub and then submit a pull request back to the original repo. It will only get merged when m0ngr31 is happy with it.

At the moment it seems that what you have so far is very specific to your local needs, with UK channels being hard coded into the wsgi.py file. So it not ready to be merged into the main repo just yet. But with a bit of polishing it could be.


I've renamed the repo back to kodi-alexa.
I've kept it on the master branch for now.
I've removed all logic that rendered the system 'UK only'.
I've added the concept of 'channel aliases' which caters for me being lazy and asking for bbc 1 rather than bbc 1 london. At the moment the aliases are hard coded but for non-UK kodi pvr users things should still work fine - you just won't have any aliases.
For the EPG program search I've added logic to grab as much as it can within 15 seconds and then to scan the grabbed data for upto a maximum of another 15 seconds. I've had to do this to allow for people like me who are deploying this as an AWS lambda and have to make sure the alexa skills handler doesn't timeout.
In theory everything I've done should work for any PVR user.

Hope this helps.
https://github.com/freemans13/kodi-alexa
Reply
(2016-10-18, 17:23)jonjon Wrote: Have you setup your LetsEncrypt certificate? If so then close those ports for the moment.

I have written a reply in more detail but I am waiting on some pull requests to be merged to save you making the minor tweaks yourself

Can you share the nginx configuration for the Kodi location please? The following doesn't work as the kodi webserver root is "" I believe, and this is trying to access http://serveraddress/kodi. But If I remove "kodi" from the location it complains that I have set two roots.... I'm so close yet still quite far away.....

location /kodi {
proxy_pass http://192.168.1.68:8745;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

I have everything else working.....
Kodi 16.1 on main HTPC Win 7 64-bit, 8 GB RAM, Quad Core 2.4 Ghz
3 x Pi2 running Kodi 16.1 (OSMC)
TVHeadend PVR server providing Freeview HD and Freesat HD
Reply
(2016-10-19, 09:50)rlg6767 Wrote: Can you share the nginx configuration for the Kodi location please? The following doesn't work as the kodi webserver root is "" I believe, and this is trying to access http://serveraddress/kodi. But If I remove "kodi" from the location it complains that I have set two roots.... I'm so close yet still quite far away.....

I feel your pain, I wanted to wait till the pull requests were done but as you appear to know what you are doing, the following might help


Because you can control traffic based on the "subfolder" of the url used. Use this to add another security step. It can also be used to control multiple Kodi installs.

The two locations below mean that traffic to:

https://DYNDNS.DOMAINNAME.COM:33133/Khj4...jftFo3oGUr

is sent to a PC in the living room and traffic sent to:

https://DYNDNS.DOMAINNAME.COM:33133/avjU...hhXsfBubzh

goes to a different install of Kodi on a laptop.

In order for this to work in the skill you need to change some bits in kodi.py, I wont go through setting up all the different bits that will let users set these details in the .env file. That will be in the main repo soon enough.

As a super hacky hack you can comment out the bit that concats the url and hardcode it in as a quick fix

Code:
# url = "%s://%s:%s/jsonrpc" % (SCHEME, KODI, PORT)

url = "https://mydynamicdns:33333/kodi1/jsonrpc"

If you used the port 33333 at shown in the example above then open the port and forward it to the box running the Nginx server.

Code:
    # Kodi 1 on a PC in the living room
    location /kodi1/ {
        proxy_pass http://192.168.0.152:9797/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    # Kodi 2 on a laptop
    location /kodi2/ {
        proxy_pass http://192.168.0.142:9797/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

Good luck,
Reply
(2016-10-19, 16:27)jonjon Wrote:
(2016-10-19, 09:50)rlg6767 Wrote: Can you share the nginx configuration for the Kodi location please? The following doesn't work as the kodi webserver root is "" I believe, and this is trying to access http://serveraddress/kodi. But If I remove "kodi" from the location it complains that I have set two roots.... I'm so close yet still quite far away.....

I feel your pain, I wanted to wait till the pull requests were done but as you appear to know what you are doing, the following might help


Because you can control traffic based on the "subfolder" of the url used. Use this to add another security step. It can also be used to control multiple Kodi installs.

The two locations below mean that traffic to:

https://DYNDNS.DOMAINNAME.COM:33133/Khj4...jftFo3oGUr

is sent to a PC in the living room and traffic sent to:

https://DYNDNS.DOMAINNAME.COM:33133/avjU...hhXsfBubzh

goes to a different install of Kodi on a laptop.

In order for this to work in the skill you need to change some bits in kodi.py, I wont go through setting up all the different bits that will let users set these details in the .env file. That will be in the main repo soon enough.

As a super hacky hack you can comment out the bit that concats the url and hardcode it in as a quick fix

Code:
# url = "%s://%s:%s/jsonrpc" % (SCHEME, KODI, PORT)

url = "https://mydynamicdns:33333/kodi1/jsonrpc"

If you used the port 33333 at shown in the example above then open the port and forward it to the box running the Nginx server.

Code:
    # Kodi 1 on a PC in the living room
    location /kodi1/ {
        proxy_pass http://192.168.0.152:9797/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    # Kodi 2 on a laptop
    location /kodi2/ {
        proxy_pass http://192.168.0.142:9797/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

Good luck,

So I can browse to https://mydynamicdns:33113/kodi and it is proxying to the webserver.

But when I try and test the skill I can see the service request go out but the service response is: "There was an error calling the remote endpoint, which returned HTTP 500 : Internal Server Error"

The Heroku log shows the following:

2016-10-19T16:22:58.365301+00:00 app[web.1]: Trying to play a random movie
2016-10-19T16:22:58.365433+00:00 app[web.1]: mydynamicdns/kodi
2016-10-19T16:22:58.365271+00:00 app[web.1]: Requested intent: PlayRandomMovie
2016-10-19T16:23:28.364968+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=POST path="/" host=myheroapp.herokuapp.com request_id=eda773dd-7440-4cb6-9a50-c01baa50fa97 fwd="72.21.217.173" dyno=web.1 connect=0ms service=30001ms status=503 bytes=0
2016-10-19T16:23:28.801968+00:00 app[web.1]: [2016-10-19 16:23:28 +0000] [3] [CRITICAL] WORKER TIMEOUT (pid:9)
2016-10-19T16:23:28.829737+00:00 app[web.1]: [2016-10-19 16:23:28 +0000] [15] [INFO] Booting worker with pid: 15
2016-10-19T16:23:28.803522+00:00 app[web.1]: [2016-10-19 16:23:28 +0000] [9] [INFO] Worker exiting (pid: 9)
Kodi 16.1 on main HTPC Win 7 64-bit, 8 GB RAM, Quad Core 2.4 Ghz
3 x Pi2 running Kodi 16.1 (OSMC)
TVHeadend PVR server providing Freeview HD and Freesat HD
Reply
(2016-10-19, 18:05)rlg6767 Wrote: So I can browse to https://mydynamicdns:33113/kodi and it is proxying to the webserver.

But when I try and test the skill I can see the service request go out but the service response is: "There was an error calling the remote endpoint, which returned HTTP 500 : Internal Server Error"

When you said it was proxying to the webserver when using https://mydynamicdns:33113/kodi did you mean the Kodi one or Nginx?

If the proxy and dyndns is setup correctly when you access https://mydynamicdns:33113/kodi from a browser you should get a the htaccess login pop up asking for your kodi username and password. Once you log in you should have access to the Kodi web interface.

Ignoring the Skill, does yours work as described above?
Reply
(2016-10-20, 14:24)jonjon Wrote: When you said it was proxying to the webserver when using https://mydynamicdns:33113/kodi did you mean the Kodi one or Nginx?

If the proxy and dyndns is setup correctly when you access https://mydynamicdns:33113/kodi from a browser you should get a the htaccess login pop up asking for your kodi username and password. Once you log in you should have access to the Kodi web interface.

Ignoring the Skill, does yours work as described above?

Yep. that's exactly how it's working from the browser. It's Proxy-ing me through to the Kodi web interface via "https://mydynamicdns:33113/kodi" and I can successfully browse movies etc.
Kodi 16.1 on main HTPC Win 7 64-bit, 8 GB RAM, Quad Core 2.4 Ghz
3 x Pi2 running Kodi 16.1 (OSMC)
TVHeadend PVR server providing Freeview HD and Freesat HD
Reply
Make certain that these environment variables are set correctly:

Code:
KODI_ADDRESS
KODI_PORT
KODI_USERNAME
KODI_PASSWORD

Also, make sure you're not blocking connections from Heroku servers inadvertently.

The skill is timing out trying to connect to Kodi, so one of the above things is likely the issue.
Reply
(2016-10-20, 18:30)jingai Wrote: Make certain that these environment variables are set correctly:

Code:
KODI_ADDRESS
KODI_PORT
KODI_USERNAME
KODI_PASSWORD

Also, make sure you're not blocking connections from Heroku servers inadvertently.

The skill is timing out trying to connect to Kodi, so one of the above things is likely the issue.

I'm sure the variables are set correctly. I'm now getting the following error in the Heroku log:
http://pastebin.com/7zwZ7fF2

I can see in the NGINX log that the request is coming through:
http://pastebin.com/Sb2KTzxT

Any ideas please?
Kodi 16.1 on main HTPC Win 7 64-bit, 8 GB RAM, Quad Core 2.4 Ghz
3 x Pi2 running Kodi 16.1 (OSMC)
TVHeadend PVR server providing Freeview HD and Freesat HD
Reply
(2016-10-21, 10:02)rlg6767 Wrote: I can see in the NGINX log that the request is coming through:
http://pastebin.com/Sb2KTzxT

It doesn't look like it's forwarding the actual command:

Code:
54.227.97.6 - mykodiusername [21/Oct/2016:07:52:54 +0000] "POST /jsonrpc HTTP/1.1" 400 264 "-" "python-requests/2.11.1"

Notice the 400 HTTP error code. That is a malformed request response (Bad Request).

"POST /jsonrpc HTTP/1.1" in this instance should be "POST /jsonrpc?Player.GetActivePlayers HTTP/1.1"
Reply
(2016-10-21, 13:30)jingai Wrote:
(2016-10-21, 10:02)rlg6767 Wrote: I can see in the NGINX log that the request is coming through:
http://pastebin.com/Sb2KTzxT

It doesn't look like it's forwarding the actual command:

Code:
54.227.97.6 - mykodiusername [21/Oct/2016:07:52:54 +0000] "POST /jsonrpc HTTP/1.1" 400 264 "-" "python-requests/2.11.1"

Notice the 400 HTTP error code. That is a malformed request response (Bad Request).

"POST /jsonrpc HTTP/1.1" in this instance should be "POST /jsonrpc?Player.GetActivePlayers HTTP/1.1"

Just ran it again and it is posting a different log:

192.168.1.1 - kodilivingroom [21/Oct/2016:11:19:26 +0000] "POST /kodi/jsonrpc?Player.GetActivePlayers HTTP/2.0" 200 302 "https://mydynamicdns:33113/kodi/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Appl$
192.168.1.1 - kodilivingroom [21/Oct/2016:11:19:27 +0000] "POST /kodi/jsonrpc?Player.GetActivePlayers HTTP/2.0" 200 302 "https://mydynamicdns:33113/kodi/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Appl$
192.168.1.1 - kodilivingroom [21/Oct/2016:11:19:28 +0000] "POST /kodi/jsonrpc?Player.GetActivePlayers HTTP/2.0" 200 302 "https://mydynamicdns:33113/kodi/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Appl$
192.168.1.1 - kodilivingroom [21/Oct/2016:11:19:29 +0000] "POST /kodi/jsonrpc?Profiles.GetCurrentProfile HTTP/2.0" 200 336 "https://mydynamicdns:33113/kodi/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) A$
192.168.1.1 - kodilivingroom [21/Oct/2016:11:19:29 +0000] "POST /kodi/jsonrpc?Profiles.GetProfiles HTTP/2.0" 200 393 "https://mydynamicdns:33113/kodi/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWe$
192.168.1.1 - kodilivingroom [21/Oct/2016:11:19:29 +0000] "POST /kodi/jsonrpc?Player.GetActivePlayers HTTP/2.0" 200 302 "https://mydynamicdns:33113/kodi/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Appl$
192.168.1.1 - kodilivingroom [21/Oct/2016:11:19:30 +0000] "POST /kodi/jsonrpc?Player.GetActivePlayers HTTP/2.0" 499 0 "https://mydynamicdns:33133/kodi/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleW$
Kodi 16.1 on main HTPC Win 7 64-bit, 8 GB RAM, Quad Core 2.4 Ghz
3 x Pi2 running Kodi 16.1 (OSMC)
TVHeadend PVR server providing Freeview HD and Freesat HD
Reply
192.168.1.1 is what? Your router?
Reply
(2016-10-21, 14:02)jingai Wrote: 192.168.1.1 is what? Your router?

Correct. Def gw.
Kodi 16.1 on main HTPC Win 7 64-bit, 8 GB RAM, Quad Core 2.4 Ghz
3 x Pi2 running Kodi 16.1 (OSMC)
TVHeadend PVR server providing Freeview HD and Freesat HD
Reply
  • 1
  • 12
  • 13
  • 14(current)
  • 15
  • 16
  • 176

Logout Mark Read Team Forum Stats Members Help
Kanzi: Amazon Alexa skill for Kodi15