Release - Amazon Echo skill for Kodi

  Thread Rating:
  • 10 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
m0ngr31 Offline
Senior Member
Posts: 124
Joined: Sep 2011
Reputation: 10
Post: #46
No, they should work still. I haven't removed any of the code. I'll play around with it a little and see what happens.
find quote
geman220 Offline
Junior Member
Posts: 12
Joined: Feb 2016
Reputation: 0
Post: #47
(2016-02-10 20:28)m0ngr31 Wrote:  No, they should work still. I haven't removed any of the code. I'll play around with it a little and see what happens.

Yea from looking around in the code I didn't see any reason the old utterances wouldn't work. I'm not nearly as competent as you are with the programming, but everything appears to be correct. I compared your kodi.py and wsgi.py with the original files and I could only find a few differences, that to me don't appear to be the problem.

I appreciate any help you can give, my gf being able to ask "Alexa ask kodi if there are any new shows" or something similar will help me out a lot =)
find quote
geman220 Offline
Junior Member
Posts: 12
Joined: Feb 2016
Reputation: 0
Post: #48
I've tried solving this but I have a very limited skill base on this. I am fairly certain the code causing issues is here:

Code:
def GetUnwatchedEpisodes(max=90):
    data = SendCommand(RPCString("VideoLibrary.GetEpisodes", {"limits":{"end":max}, "filter":{"field":"playcount", "operator":"lessthan", "value":"1"}, "sort":{"method":"dateadded", "order":"descending"}, "properties":["title", "playcount", "showtitle", "tvshowid", "dateadded" ]}))
    answer = []
    shows = set([d['tvshowid'] for d in data['result']['episodes']])
    show_info = {}
    for show in shows:
        show_info[show] = GetShowDetails(show=show)
    for d in data['result']['episodes']:
        showinfo = show_info[d['tvshowid']]
        banner = ''
        if 'banner' in showinfo['art']:
            banner = "http://%s:%s/image/%s" % (urllib.quote(showinfo['art']['banner']))
        answer.append({'title':d['title'], 'episodeid':d['episodeid'], 'show':d['showtitle'], 'label':d['label'], 'banner':banner, 'dateadded':datetime.datetime.strptime(d['dateadded'], "%Y-%m-%d %H:%M:%S")})
    return answer

I noticed the following error: TypeError: Not enough arguments for format string . But I don't see a TypeError here, I'm assuming it's referencing banner = "http://%s:%s/image/%s" % (urllib.quote(showinfo['art']['banner'])) but that seems like the correct syntax.

I'm probably way off base here though. Whenever you get time and figure it out if you wouldn't mind explaining how you solved it I would appreciate it a lot. I'm trying to get better at python and this seems like a good learning opportunity.
find quote
geman220 Offline
Junior Member
Posts: 12
Joined: Feb 2016
Reputation: 0
Post: #49
Well progress?

Changing

if 'banner' in showinfo['art']:
banner = "http://%s:%s/image/%s" % (urllib.quote(showinfo['art']['banner']))
to

if 'banner' in showinfo['art']:
banner = "http://%s:%s/image/%s", (urllib.quote(showinfo['art']['banner']))

No longer reports errors. I still get "The remote endpoint could not be called, or the response it returned was invalid." but I don't see python errors in the log.
find quote
m0ngr31 Offline
Senior Member
Posts: 124
Joined: Sep 2011
Reputation: 10
Post: #50
I'll take a look at it this weekend. I have another update to push out as well.
find quote
geman220 Offline
Junior Member
Posts: 12
Joined: Feb 2016
Reputation: 0
Post: #51
Sounds good, just trying to learn a bit for the future.
find quote
geman220 Offline
Junior Member
Posts: 12
Joined: Feb 2016
Reputation: 0
Post: #52
Well I can at least get something working.

Code:
def GetUnwatchedEpisodes(max=90):
    data = SendCommand(RPCString("VideoLibrary.GetRecentlyAddedEpisodes", {"limits":{"end":max}, "sort":{"method":"dateadded", "order":"descending"}, "properties":["title", "showtitle", "tvshowid", "dateadded" ]}))
    answer = []
    shows = set([d['tvshowid'] for d in data['result']['episodes']])
    show_info = {}
    for show in shows:
        show_info[show] = GetShowDetails(show=show)
    for d in data['result']['episodes']:
        showinfo = show_info[d['tvshowid']]
        banner = ''
        if 'banner' in showinfo['art']:
            banner = "http://%s:%s/image/%s", (urllib.quote(showinfo['art']['banner']))
        answer.append({'title':d['title'], 'episodeid':d['episodeid'], 'show':d['showtitle'], 'label':d['label'], 'banner':banner, 'dateadded':datetime.datetime.strptime(d['dateadded'], "%Y-%m-%d %H:%M:%S")})
    return answer

The code breaks when I add
Code:
"filter":{"field":"playcount", "operator":"lessthan", "value":"1"},
Sending the JSON as a URL works fine though. I'm also unable to use
Code:
VideoLibrary.GetEpisodes
only
Code:
VideoLibrary.GetRecentlyAddedEpisodes

I think I'm going to give up and just wait until you have time to resolve it.
(This post was last modified: 2016-02-12 11:46 by geman220.)
find quote
m0ngr31 Offline
Senior Member
Posts: 124
Joined: Sep 2011
Reputation: 10
Post: #53
I updated the repo. I just ended up pulling out the banner stuff since art doesn't really do anything when it's all voice driven.
find quote
geman220 Offline
Junior Member
Posts: 12
Joined: Feb 2016
Reputation: 0
Post: #54
(2016-02-16 01:00)m0ngr31 Wrote:  I updated the repo. I just ended up pulling out the banner stuff since art doesn't really do anything when it's all voice driven.

Unfortunately it's not working for me with the modified code.

If I ask Alexa if there are any new shows I get
Code:
The remote endpoint could not be called, or the response it returned was invalid.
and my log file shows
Code:
2016-02-15T23:14:10.670727+00:00 heroku[router]: at=info method=POST path="/" host=kodihatt.herokuapp.com request_id=5810fcfb-6af2-445e-a8e7-06fe0d4073ea fwd="72.21.217.175" dyno=web.1 connect=1ms service=18293ms status=200 bytes=333

I was getting this before, the code is passing through the script fine but it's not getting a response from Kodi.

This JSON works if I just put it in a browser:

{ "jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "filter":{"field":"playcount", "operator":"lessthan", "value":"1"}, "sort":{"method":"dateadded", "order":"descending"}, "params":{"properties": ["title", "playcount", "showtitle", "tvshowid", "dateadded"] }, "id": 1 }

http://KODIPUBLICADDRESS/jsonrpc?request={%20%22jsonrpc%22:%20%222.0%22,%20%22method%22:%20%22VideoLibrar​y.GetEpisodes%22,%20%22filter%22:{%22field%22:%22playcount%22,%20%22operator%22:​%22lessthan%22,%20%22value%22:%221%22},%20%22sort%22:{%22method%22:%22dateadded%​22,%20%22order%22:%22descending%22},%20%22params%22:{%22properties%22:%20[%22title%22,%20%22playcount%22,%20%22showtitle%22,%20%22tvshowid%22,%20%22datead​ded%22]%20},%20%22id%22:%201%20}

It just doesn't seem to work when the python script runs.
(This post was last modified: 2016-02-16 01:23 by geman220.)
find quote
Timmons Offline
Junior Member
Posts: 13
Joined: Feb 2012
Reputation: 0
Post: #55
This setup is a no go for me too. I've tried two different platforms in windows with git/ruby and synology ds using openshift.

Both of them returned a http instead of https that dev kit in amazon is asking for.

Getting the same error "The remote endpoint could not be called, or the response it returned was invalid."

Is there a step by step to try the other Heroku site.. or a step by step using an internal server? I have python installed on both my windows pc and synology.

It's a shame because this looks really neat.
find quote
geman220 Offline
Junior Member
Posts: 12
Joined: Feb 2016
Reputation: 0
Post: #56
Well I have an update. Originally I couldn't get this working at all on OpenShift so I used Heroku and everything worked (except the new shows). I decided to give OpenShift another shot and now it works on OpenShift. Also new shows works. I have the exact same code on Heroku and OpenShift but on Heroku I get "The remote endpoint could not be called, or the response it returned was invalid.", while on OpenShift I get the correct response. My only thought is Heroku seems to have quite a bit of latency compared to OpenShift. I think Heroku is timing out with more complex commands where it needs to query the Kodi database and get a response.
find quote
Timmons Offline
Junior Member
Posts: 13
Joined: Feb 2012
Reputation: 0
Post: #57
(2016-02-18 18:22)geman220 Wrote:  Well I have an update. Originally I couldn't get this working at all on OpenShift so I used Heroku and everything worked (except the new shows). I decided to give OpenShift another shot and now it works on OpenShift. Also new shows works. I have the exact same code on Heroku and OpenShift but on Heroku I get "The remote endpoint could not be called, or the response it returned was invalid.", while on OpenShift I get the correct response. My only thought is Heroku seems to have quite a bit of latency compared to OpenShift. I think Heroku is timing out with more complex commands where it needs to query the Kodi database and get a response.

Nice. I'm still getting that message. After redoing everything again with openshift.

The kodi directory.. when it says to move the files is that on the SSH on openshift or locally? Can't think of anything else.
find quote
Timmons Offline
Junior Member
Posts: 13
Joined: Feb 2012
Reputation: 0
Post: #58
So i'm using the rhc tail -o "-n 20" -a kodi command and have both prompts open to synology ds & windows pc. they are both responding to it with

172.21.217.99 - - [19/Feb/2016:08:31:35 -0500] "POST / HTTP/1.1" 200 39607 "-" "Apache-HttpClient/UNAVAILABLE (Java/1.8.0_66)"

When i try to test a command via amazon dev kit.

Complete posting below

RSA 1024 bit CA certificates are loaded due to old openssl compatibility
172.16.10.92 - - [19/Feb/2016:02:10:23 -0500] "HEAD / HTTP/1.1" 200 - "-" "Ruby"

172.16.10.92 - - [19/Feb/2016:03:10:25 -0500] "HEAD / HTTP/1.1" 200 - "-" "Ruby"

172.16.10.92 - - [19/Feb/2016:03:10:26 -0500] "HEAD / HTTP/1.1" 200 - "-" "Ruby"

172.16.10.92 - - [19/Feb/2016:04:10:17 -0500] "HEAD / HTTP/1.1" 200 - "-" "Ruby"

172.16.10.92 - - [19/Feb/2016:04:10:17 -0500] "HEAD / HTTP/1.1" 200 - "-" "Ruby"

172.16.10.92 - - [19/Feb/2016:05:10:33 -0500] "HEAD / HTTP/1.1" 200 - "-" "Ruby"

172.16.10.92 - - [19/Feb/2016:05:10:33 -0500] "HEAD / HTTP/1.1" 200 - "-" "Ruby"

172.16.10.92 - - [19/Feb/2016:06:10:24 -0500] "HEAD / HTTP/1.1" 200 - "-" "Ruby"

172.16.10.92 - - [19/Feb/2016:06:10:24 -0500] "HEAD / HTTP/1.1" 200 - "-" "Ruby"

172.16.10.92 - - [19/Feb/2016:07:10:23 -0500] "HEAD / HTTP/1.1" 200 - "-" "Ruby"

172.16.10.92 - - [19/Feb/2016:07:10:23 -0500] "HEAD / HTTP/1.1" 200 - "-" "Ruby"

172.16.10.92 - - [19/Feb/2016:08:10:22 -0500] "HEAD / HTTP/1.1" 200 - "-" "Ruby"

172.16.10.92 - - [19/Feb/2016:08:10:22 -0500] "HEAD / HTTP/1.1" 200 - "-" "Ruby"

72.21.217.156 - - [19/Feb/2016:08:25:55 -0500] "POST / HTTP/1.1" 200 39607 "-" "
Apache-HttpClient/UNAVAILABLE (Java/1.8.0_66)"
72.21.217.117 - - [19/Feb/2016:08:30:32 -0500] "POST / HTTP/1.1" 200 39607 "-" "
Apache-HttpClient/UNAVAILABLE (Java/1.8.0_66)"
72.21.217.168 - - [19/Feb/2016:08:30:39 -0500] "POST / HTTP/1.1" 200 39607 "-" "
Apache-HttpClient/UNAVAILABLE (Java/1.8.0_66)"
72.21.217.99 - - [19/Feb/2016:08:31:35 -0500] "POST / HTTP/1.1" 200 39607 "-" "A
pache-HttpClient/UNAVAILABLE (Java/1.8.0_66)"
72.21.217.67 - - [19/Feb/2016:08:39:42 -0500] "POST / HTTP/1.1" 200 39607 "-" "A
pache-HttpClient/UNAVAILABLE (Java/1.8.0_66)"
72.21.217.117 - - [19/Feb/2016:08:41:42 -0500] "POST / HTTP/1.1" 200 39607 "-" "
Apache-HttpClient/UNAVAILABLE (Java/1.8.0_66)"
72.21.217.168 - - [19/Feb/2016:08:47:40 -0500] "POST / HTTP/1.1" 200 39607 "-" "
Apache-HttpClient/UNAVAILABLE (Java/1.8.0_66)"
(This post was last modified: 2016-02-19 15:49 by Timmons.)
find quote
m0ngr31 Offline
Senior Member
Posts: 124
Joined: Sep 2011
Reputation: 10
Post: #59
Is it still having issues for you Timmons?
find quote
Timmons Offline
Junior Member
Posts: 13
Joined: Feb 2012
Reputation: 0
Post: #60
Hello,

Yes I still am.

Getting the following running rhc tail -o "-n 20" -a kodi
172.16.4.201 - - [05/Mar/2016:19:10:19 -0500] "HEAD / HTTP/1.1" 200 - "-" "Ruby"
172.16.4.201 - - [05/Mar/2016:20:10:44 -0500] "HEAD / HTTP/1.1" 200 - "-" "Ruby"
172.16.4.201 - - [05/Mar/2016:20:10:44 -0500] "HEAD / HTTP/1.1" 200 - "-" "Ruby"
- - - [05/Mar/2016:20:50:41 -0500] "OPTIONS * HTTP/1.0" 200 - "-" "Apache/2.2.15 (Red Hat) (internal dummy connection)"
[Sat Mar 05 20:50:41 2016] [notice] caught SIGWINCH, shutting down gracefully
[Mon Mar 07 08:06:29 2016] [notice] SELinux policy enabled; httpd running as context unconfined_u:system_r:openshift_tConfused0:c3,c344
[Mon Mar 07 08:06:29 2016] [notice] Digest: generating secret for digest authentication ...
[Mon Mar 07 08:06:29 2016] [notice] Digest: done
[Mon Mar 07 08:06:29 2016] [notice] Apache/2.2.15 (Unix) mod_wsgi/3.4 Python/2.7.8 configured -- resuming normal operations
100.33.77.145 - - [07/Mar/2016:08:06:44 -0500] "GET / HTTP/1.1" 200 39607 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36"
100.33.77.145 - - [07/Mar/2016:08:06:44 -0500] "GET /favicon.ico HTTP/1.1" 200 39607 "http://kodi-timmons.rhcloud.com/" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36"
72.21.217.155 - - [07/Mar/2016:08:08:20 -0500] "POST / HTTP/1.1" 200 39607 "-" "Apache-HttpClient/UNAVAILABLE (Java/1.8.0_72)"
172.16.4.201 - - [07/Mar/2016:08:10:23 -0500] "HEAD / HTTP/1.1" 200 - "-" "Ruby"
172.16.4.201 - - [07/Mar/2016:08:10:23 -0500] "HEAD / HTTP/1.1" 200 - "-" "Ruby"


Doing rhc setup.

You can add more servers later using 'rhc server'.

Using an existing token for [email protected] to login to
openshift.redhat.com
RSA 1024 bit CA certificates are loaded due to old openssl compatibility

Saving configuration to /root/.openshift/express.conf ... done

Checking for git ... found git version 2.5.0

Checking common problems .. done

Checking for a domain ... timmons

Checking for applications ... found 1

kodi http://kodi-timmons.rhcloud.com/ <not https in the skill i changed this to https as it wouldn't accept this.

You are using 1 of 3 total gears
The following gear sizes are available to you: small

Your client tools are now configured.
find quote
Post Reply