Release Kanzi: Amazon Alexa skill for Kodi - Printable Version +- Kodi Community Forum (https://forum.kodi.tv) +-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33) +--- Forum: Supplementary Tools for Kodi (https://forum.kodi.tv/forumdisplay.php?fid=116) +--- Thread: Release Kanzi: Amazon Alexa skill for Kodi (/showthread.php?tid=254502) Pages:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
RE: Amazon Echo skill for Kodi - TearDrop1319 - 2016-12-06 @ Jingai, thanks for the clarification! Makes sense, and again thank you for your work on this project. Its a lot of fun to play with and I can see the potential! Cheers! RE: Amazon Echo skill for Kodi - digiltd - 2016-12-07 @russco 1. You didn't mention the language setting found in the Alexa app (Setting > Device > Language (under wake word)). Is that set to English (US)? That is the thing that needs to match the language setting on the Skill in the dev console. I don't think the "device location" setting has any effect. 2. cool 3. one Skill with the invocation name Kodi that is in the My Skills section of the Alexa app and no Smart Devices also called Kodi for some reason? (sorry if I am going over stuff, I just want to check and double check) You mentioned in your comment to TearDrop1319 that the name of the Skill is "kodi", the name isn't what Alexa will listen for, it is the invocation name. Or is that what you mean when you say "name"? In the dev console the invocation name doesn't matter as you are sending commands directly into the Skill, but it will when used on your Echo. Quote:The full command I'm saying is "Alexa, tell kodi to play" and all I get is an error message. Does Alexa hear and understand (convert to text in your history) the command exactly as you say it? I don't know if you have an accent or how much that would effect things, have you had trouble with other Skills? Because playback control words like "play", "stop", "pause" etc are words Alexa uses for native stuff, for now when testing please use the phrase "Alexa, ask kodi to play a random movie". I remember when setting up the Skill the first time. I created the US one and added the UK language to it as an addition language and deleted the US English version. I am not 100% sure of the details but I was having loads of problems (though I think that was more to do with the Skill talking to my Kodi box). When I recreated the Skill setting English UK from the start then I was getting somewhere. Though that might have just been a coincidence. Here are the settings as I have them in my Amazon Dev console. Also be sure the AWS Lambda region is set correctly (either Ireland for EU or Virginia for US) Good luck I don't use Kodi for music but you have to throw something in there RE: Amazon Echo skill for Kodi - russco - 2016-12-07 Jonjon, I admire your perseverance. It really is appreciated! Quote:You didn't mention the language setting found in the Alexa app (Setting > Device > Language (under wake word)). Is that set to English (US)? That is the thing that needs to match the language setting on the Skill in the dev console. I don't think the "device location" setting has any effect. It is already set to English US, yes. Quote:3. one Skill with the invocation name Kodi that is in the My Skills section of the Alexa app and no Smart Devices also called Kodi for some reason? Definitely. One skill called kodi, with the invocation name kodi, that is in the My Skills section of the Alexa app, and no Smart Devices called kodi anywhere. Quote:Does Alexa hear and understand (convert to text in your history) the command exactly as you say it? I don't know if you have an accent or how much that would effect things, have you had trouble with other Skills? Yes. Some of the commands featured in my history read: tell kodi to play a random movie (doesn't work) turn the lights on (this works) is it gonna snow in oslo norway today (this works) tell kodi to play (doesn't work) But the kodi command has worked. This is the thing, there've been a couple of times where it's worked for a couple hours, and then it just completely stops working the next day. I don't have an accent particularly. Thanks for going to the effort of screengrabbing your setup. Mine looks pretty much identical, except for the fact that I'm using US servers. I have had one thought about what it might be though. When I first got my dot, I did some stuff with the API to try to change the timezone, and the location, to Norway. Changing the timezone is possible, location not so much. So maybe I need to undo anything I did there? A factory reset perhaps, if such a thing is possible? Will that restore the API back to its default state? RE: Amazon Echo skill for Kodi - russco - 2016-12-07 Okay, I just did a full factory reset, and I still get exactly the same problem. It's a UK dot though, so maybe it needs to be linked to a UK amazon account? RE: Amazon Echo skill for Kodi - jingai - 2016-12-07 @russco, my gut is telling me that it does have something to do with the region settings. I don't know what though, so you'll just need to play around. Try using the EU server to start. And for the record, it won't prevent it from working if the invocation name is 'kodi' nor if you have a smart home device with the same name. For the former, that's how I have it set here and it's fine after she 'learns' a bit. For the latter, you will encounter her mixing the two up from time-to-time, so.. I don't suggest it, but.. it won't cause outright failure. RE: Amazon Echo skill for Kodi - russco - 2016-12-07 I'm switching completely over to my UK amazon account, just to see how it goes. Bit of a pain having to set up everything all over again, but it's worth a shot. RE: Amazon Echo skill for Kodi - russco - 2016-12-07 Okay. I switched absolutely everything over to EU, switched to my UK Amazon account, set up everything totally from scratch, and it's worked!! For now at least. Thanks everyone so much for all your patience, it's really, really appreciated! RE: Amazon Echo skill for Kodi - invader_dag - 2016-12-07 I'm trying to set this up using a local server but keep running into (seemingly) the same problem. I follow the steps that edru outlined in the post, but I get a HTTP ERROR 502. I tried on another system and I get the same error, but refreshing a few times causes it to come up with ERR_SSL_PROTOCOL_ERROR. There is nothing in the apache error logs except the following: [wsgi:warn] [pid 614:tid 3069960720] mod_wsgi: Compiled for Python/2.7.8. [wsgi:warn] [pid 614:tid 3069960720] mod_wsgi: Runtime using Python/2.7.9. [mpm_event:notice] [pid 614:tid 3069960720] AH00489: Apache/2.4.10 (Raspbian) OpenSSL/1.0.1t mod_wsgi/4.3.0 Python/2.7.9 configured -- resuming normal operations [core:notice] [pid 614:tid 3069960720] AH00094: Command line: '/usr/sbin/apache2' [wsgi:error] [pid 617:tid 3044013104] /usr/local/lib/python2.7/dist-packages/fuzzywuzzy/fuzz.py:35: UserWarning: Using slow pure-python SequenceMatcher. Install python-Levenshtein to remove this warning [wsgi:error] [pid 617:tid 3044013104] warnings.warn('Using slow pure-python SequenceMatcher. Install python-Levenshtein to remove this warning') I should be getting at least a blank page when I browse to that location, right? Any help would be greatly appreciated!! RE: Amazon Echo skill for Kodi - jingai - 2016-12-08 Just a heads up before I get complaints if I don't get this finished tonight: I added support for specifying a song to play, but as a consequence of this, all requests currently need the media type to be specified in the request. For example, "Alexa, ask Kodi to play Stone Temple Pilots" will no longer work. I am working on making the play/shuffle/watch/listen commands work without specifying the media type, but until I'm finished with that, please specify the media type. Like so: "Alexa, ask Kodi to play the movie The Big Lebowski" "Alexa, ask Kodi to play a random episode of The Simpsons" "Alexa, ask Kodi to play the album 10,000Hz Legend" "Alexa, ask Kodi to play the album 10,000Hz Legend by AIR" "Alexa, ask Kodi to play music by Stone Temple Pilots" "Alexa, ask Kodi to play the song Laid" "Alexa, ask Kodi to play the song Laid by James" "Alexa, ask Kodi to play the music playlist My Favorite Music" etc etc.. When I do finish the generic commands, they will be slower since they will need to potentially search your entire library to figure out what you wanted. At that point, if you get timeouts or it just takes too long, specify the media type to speed it up. RE: Amazon Echo skill for Kodi - jingai - 2016-12-08 (2016-12-07, 23:51)invader_dag Wrote: I should be getting at least a blank page when I browse to that location, right? Any help would be greatly appreciated!! Yes, a blank page and HTTP 502 error response. RE: Amazon Echo skill for Kodi - invader_dag - 2016-12-08 (2016-12-08, 01:30)jingai Wrote: Yes, a blank page and HTTP 502 error response. Wow, I spent all that time troubleshooting, expecting to get something different. Thanks for the quick reply! Now I just have to figure out why it gets no response when setting up the skill. Thanks again! RE: Amazon Echo skill for Kodi - Gibsarno - 2016-12-09 (2016-12-07, 20:33)russco Wrote: Okay. I switched absolutely everything over to EU, switched to my UK Amazon account, set up everything totally from scratch, and it's worked!! Was wondering if you can give me the heads up on how to do this in the uk please? RE: Amazon Echo skill for Kodi - cabldawg - 2016-12-09 When running the command lamda-deploy.exe deploy I get an error at the end that states File "c:\python27\lib\site-packages\botocore\regions.py" , line 135, in _endpoint_for_partition raise NoRegionError<> botocore.exceptions.NoRegionError: You must specify a region. RE: Amazon Echo skill for Kodi - jingai - 2016-12-09 Eh, that one is pretty clear... you must specify a region... RE: Amazon Echo skill for Kodi - cabldawg - 2016-12-09 Where? I'm not a coder by any means. I played with this for a few hours last night and am stuck. # Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"). You # may not use this file except in compliance with the License. A copy of # the License is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" file accompanying this file. This file is # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF # ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. """Resolves regions and endpoints. This module implements endpoint resolution, including resolving endpoints for a given service and region and resolving the available endpoints for a service in a specific AWS partition. """ import logging import re from botocore.exceptions import NoRegionError LOG = logging.getLogger(__name__) DEFAULT_URI_TEMPLATE = '{service}.{region}.{dnsSuffix}' DEFAULT_SERVICE_DATA = {'endpoints': {}} class BaseEndpointResolver(object): """Resolves regions and endpoints. Must be subclassed.""" def construct_endpoint(self, service_name, region_name=None): """Resolves an endpoint for a service and region combination. :type service_name: string :param service_name: Name of the service to resolve an endpoint for (e.g., s3) :type region_name: string :param region_name: Region/endpoint name to resolve (e.g., us-east-1) if no region is provided, the first found partition-wide endpoint will be used if available. :rtype: dict :return: Returns a dict containing the following keys: - partition: (string, required) Resolved partition name - endpointName: (string, required) Resolved endpoint name - hostname: (string, required) Hostname to use for this endpoint - sslCommonName: (string) sslCommonName to use for this endpoint. - credentialScope: (dict) Signature version 4 credential scope - region: (string) region name override when signing. - service: (string) service name override when signing. - signatureVersions: (list<string>) A list of possible signature versions, including s3, v4, v2, and s3v4 - protocols: (list<string>) A list of supported protocols (e.g., http, https) - ...: Other keys may be included as well based on the metadata """ raise NotImplementedError def get_available_partitions(self): """Lists the partitions available to the endpoint resolver. :return: Returns a list of partition names (e.g., ["aws", "aws-cn"]). """ raise NotImplementedError def get_available_endpoints(self, service_name, partition_name='aws', allow_non_regional=False): """Lists the endpoint names of a particular partition. :type service_name: string :param service_name: Name of a service to list endpoint for (e.g., s3) :type partition_name: string :param partition_name: Name of the partition to limit endpoints to. (e.g., aws for the public AWS endpoints, aws-cn for AWS China endpoints, aws-us-gov for AWS GovCloud (US) Endpoints, etc. :type allow_non_regional: bool :param allow_non_regional: Set to True to include endpoints that are not regional endpoints (e.g., s3-external-1, fips-us-gov-west-1, etc). :return: Returns a list of endpoint names (e.g., ["us-east-1"]). """ raise NotImplementedError class EndpointResolver(BaseEndpointResolver): """Resolves endpoints based on partition endpoint metadata""" def __init__(self, endpoint_data): """ :param endpoint_data: A dict of partition data. """ if 'partitions' not in endpoint_data: raise ValueError('Missing "partitions" in endpoint data') self._endpoint_data = endpoint_data def get_available_partitions(self): result = [] for partition in self._endpoint_data['partitions']: result.append(partition['partition']) return result def get_available_endpoints(self, service_name, partition_name='aws', allow_non_regional=False): result = [] for partition in self._endpoint_data['partitions']: if partition['partition'] != partition_name: continue services = partition['services'] if service_name not in services: continue for endpoint_name in services[service_name]['endpoints']: if allow_non_regional or endpoint_name in partition['regions']: result.append(endpoint_name) return result def construct_endpoint(self, service_name, region_name=None): # Iterate over each partition until a match is found. for partition in self._endpoint_data['partitions']: result = self._endpoint_for_partition( partition, service_name, region_name) if result: return result def _endpoint_for_partition(self, partition, service_name, region_name): # Get the service from the partition, or an empty template. service_data = partition['services'].get( service_name, DEFAULT_SERVICE_DATA) # Use the partition endpoint if no region is supplied. if region_name is None: if 'partitionEndpoint' in service_data: region_name = service_data['partitionEndpoint'] else: raise NoRegionError() # Attempt to resolve the exact region for this partition. if region_name in service_data['endpoints']: return self._resolve( partition, service_name, service_data, region_name) # Check to see if the endpoint provided is valid for the partition. if self._region_match(partition, region_name): # Use the partition endpoint if set and not regionalized. partition_endpoint = service_data.get('partitionEndpoint') is_regionalized = service_data.get('isRegionalized', True) if partition_endpoint and not is_regionalized: LOG.debug('Using partition endpoint for %s, %s: %s', service_name, region_name, partition_endpoint) return self._resolve( partition, service_name, service_data, partition_endpoint) LOG.debug('Creating a regex based endpoint for %s, %s', service_name, region_name) return self._resolve( partition, service_name, service_data, region_name) def _region_match(self, partition, region_name): if region_name in partition['regions']: return True if 'regionRegex' in partition: return re.compile(partition['regionRegex']).match(region_name) return False def _resolve(self, partition, service_name, service_data, endpoint_name): result = service_data['endpoints'].get(endpoint_name, {}) result['partition'] = partition['partition'] result['endpointName'] = endpoint_name # Merge in the service defaults then the partition defaults. self._merge_keys(service_data.get('defaults', {}), result) self._merge_keys(partition.get('defaults', {}), result) hostname = result.get('hostname', DEFAULT_URI_TEMPLATE) result['hostname'] = self._expand_template( partition, result['hostname'], service_name, endpoint_name) if 'sslCommonName' in result: result['sslCommonName'] = self._expand_template( partition, result['sslCommonName'], service_name, endpoint_name) result['dnsSuffix'] = partition['dnsSuffix'] return result def _merge_keys(self, from_data, result): for key in from_data: if key not in result: result[key] = from_data[key] def _expand_template(self, partition, template, service_name, endpoint_name): return template.format( service=service_name, region=endpoint_name, dnsSuffix=partition['dnsSuffix']) |