Add release date support (#14)
Closes #11 Adds a couple of new utterances so you can limit your movie results by the release date. You can now add a movie by saying: > Add The Godfather released in 1972 > Add The Godfather from 1972 > Add The Godfather that came out in 1972 > Add The Godfather released in March 1972 If you've used previous versions of the Intent Schema and Sample Utterances, make sure to copy and paste the new ones in.
This commit is contained in:
parent
e31ac662a6
commit
e63769c379
@ -9,6 +9,19 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"intent": "AddMovieDate",
|
||||||
|
"slots": [
|
||||||
|
{
|
||||||
|
"name": "movieName",
|
||||||
|
"type": "AMAZON.LITERAL"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "releaseDate",
|
||||||
|
"type": "AMAZON.DATE"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"intent": "FindMovie",
|
"intent": "FindMovie",
|
||||||
"slots": [
|
"slots": [
|
||||||
|
@ -5,6 +5,27 @@ AddMovie add {The Avengers|movieName}
|
|||||||
AddMovie add {The Dark Knight|movieName}
|
AddMovie add {The Dark Knight|movieName}
|
||||||
AddMovie add {Live or Let Die|movieName}
|
AddMovie add {Live or Let Die|movieName}
|
||||||
|
|
||||||
|
AddMovieDate add {The Godfather|movieName} came out in {releaseDate}
|
||||||
|
AddMovieDate add {Star Wars|movieName} came out in {releaseDate}
|
||||||
|
AddMovieDate add {Star Wars Episode Four A New Hope|movieName} came out in {releaseDate}
|
||||||
|
AddMovieDate add {The Avengers|movieName} came out in {releaseDate}
|
||||||
|
AddMovieDate add {The Dark Knight|movieName} came out in {releaseDate}
|
||||||
|
AddMovieDate add {Live or Let Die|movieName} came out in {releaseDate}
|
||||||
|
|
||||||
|
AddMovieDate add {The Godfather|movieName} from {releaseDate}
|
||||||
|
AddMovieDate add {Star Wars|movieName} from {releaseDate}
|
||||||
|
AddMovieDate add {Star Wars Episode Four A New Hope|movieName} from {releaseDate}
|
||||||
|
AddMovieDate add {The Avengers|movieName} from {releaseDate}
|
||||||
|
AddMovieDate add {The Dark Knight|movieName} from {releaseDate}
|
||||||
|
AddMovieDate add {Live or Let Die|movieName} from {releaseDate}
|
||||||
|
|
||||||
|
AddMovieDate add {The Godfather|movieName} released in {releaseDate}
|
||||||
|
AddMovieDate add {Star Wars|movieName} released in {releaseDate}
|
||||||
|
AddMovieDate add {Star Wars Episode Four A New Hope|movieName} released in {releaseDate}
|
||||||
|
AddMovieDate add {The Avengers|movieName} released in {releaseDate}
|
||||||
|
AddMovieDate add {The Dark Knight|movieName} released in {releaseDate}
|
||||||
|
AddMovieDate add {Live or Let Die|movieName} released in {releaseDate}
|
||||||
|
|
||||||
FindMovie is {The Godfather|movieName} on the list
|
FindMovie is {The Godfather|movieName} on the list
|
||||||
FindMovie is {Star Wars|movieName} on the list
|
FindMovie is {Star Wars|movieName} on the list
|
||||||
FindMovie is {Star Wars Episode Four A New Hope|movieName} on the list
|
FindMovie is {Star Wars Episode Four A New Hope|movieName} on the list
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "alexa-couchpotato",
|
"name": "alexa-couchpotato",
|
||||||
"version": "1.0.4",
|
"version": "1.1.0",
|
||||||
"description": "A skill to ask Alexa about your Couch Potato queue.",
|
"description": "A skill to ask Alexa about your Couch Potato queue.",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -14,6 +14,8 @@ import {
|
|||||||
CANCEL_RESPONSE
|
CANCEL_RESPONSE
|
||||||
} from './responses.js';
|
} from './responses.js';
|
||||||
|
|
||||||
|
const NUM_RESULTS = 5;
|
||||||
|
|
||||||
const config = require('dotenv').config();
|
const config = require('dotenv').config();
|
||||||
const cp = new CouchPotato({
|
const cp = new CouchPotato({
|
||||||
url: config.CP_URL,
|
url: config.CP_URL,
|
||||||
@ -31,7 +33,7 @@ export default function handleLaunchIntent(req, resp) {
|
|||||||
export function handleFindMovieIntent(req, resp) {
|
export function handleFindMovieIntent(req, resp) {
|
||||||
const movieName = req.slot('movieName');
|
const movieName = req.slot('movieName');
|
||||||
|
|
||||||
cp.movie.list({search: movieName, limit_offset: 5}).then(function (searchResp) {
|
cp.movie.list({search: movieName, limit_offset: NUM_RESULTS}).then(function (searchResp) {
|
||||||
const movies = searchResp.movies;
|
const movies = searchResp.movies;
|
||||||
|
|
||||||
if (!movies || !movies.length) {
|
if (!movies || !movies.length) {
|
||||||
@ -56,7 +58,7 @@ export function handleFindMovieIntent(req, resp) {
|
|||||||
export function handleAddMovieIntent(req, resp) {
|
export function handleAddMovieIntent(req, resp) {
|
||||||
const movieName = req.slot('movieName');
|
const movieName = req.slot('movieName');
|
||||||
|
|
||||||
cp.movie.search(movieName, 5).then(function (movies) {
|
cp.movie.search(movieName, NUM_RESULTS).then(function (movies) {
|
||||||
movies = formatSearchResults(movies);
|
movies = formatSearchResults(movies);
|
||||||
sendSearchResponse(movies, movieName, resp);
|
sendSearchResponse(movies, movieName, resp);
|
||||||
});
|
});
|
||||||
@ -65,6 +67,20 @@ export function handleAddMovieIntent(req, resp) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function handleAddMovieDateIntent(req, resp) {
|
||||||
|
const movieName = req.slot('movieName');
|
||||||
|
const releaseDate = new Date(req.slot('releaseDate')).getUTCFullYear();
|
||||||
|
|
||||||
|
// Grab more results since we'll end up filtering by date
|
||||||
|
cp.movie.search(movieName, NUM_RESULTS * 2).then(function (movies) {
|
||||||
|
movies = formatSearchResults(movies).filter((movie) => movie.year == releaseDate);
|
||||||
|
sendSearchResponse(movies, movieName, resp);
|
||||||
|
});
|
||||||
|
|
||||||
|
//Async response
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
export function handleYesIntent(req, resp) {
|
export function handleYesIntent(req, resp) {
|
||||||
const promptData = req.session('promptData');
|
const promptData = req.session('promptData');
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import Alexa from 'alexa-app';
|
|||||||
import handleLaunchIntent, {
|
import handleLaunchIntent, {
|
||||||
handleFindMovieIntent,
|
handleFindMovieIntent,
|
||||||
handleAddMovieIntent,
|
handleAddMovieIntent,
|
||||||
|
handleAddMovieDateIntent,
|
||||||
handleYesIntent,
|
handleYesIntent,
|
||||||
handleNoIntent,
|
handleNoIntent,
|
||||||
handleCancelIntent,
|
handleCancelIntent,
|
||||||
@ -16,6 +17,7 @@ const app = new Alexa.app('couchPotato');
|
|||||||
app.launch(handleLaunchIntent);
|
app.launch(handleLaunchIntent);
|
||||||
app.intent('FindMovie', handleFindMovieIntent);
|
app.intent('FindMovie', handleFindMovieIntent);
|
||||||
app.intent('AddMovie', handleAddMovieIntent);
|
app.intent('AddMovie', handleAddMovieIntent);
|
||||||
|
app.intent('AddMovieDate', handleAddMovieDateIntent);
|
||||||
app.intent('AMAZON.YesIntent', handleYesIntent);
|
app.intent('AMAZON.YesIntent', handleYesIntent);
|
||||||
app.intent('AMAZON.NoIntent', handleNoIntent);
|
app.intent('AMAZON.NoIntent', handleNoIntent);
|
||||||
app.intent('AMAZON.CancelIntent', handleCancelIntent);
|
app.intent('AMAZON.CancelIntent', handleCancelIntent);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user