@@ -54,8 +54,41 @@ var onDeckIntent = function(request, response) {
5454 . card ( "TV Shows Ready to Watch" , "On Deck in your TV library: \n\n" + showListCard )
5555 . send ( ) ;
5656 } ) . catch ( function ( err ) {
57- app . skill . error ( err , request , response ) ;
58- } ) ;
57+ app . skill . error ( err , request , response ) ;
58+ } ) ;
59+
60+ return false ;
61+ } ;
62+
63+ var recentlyAddedIntent = function ( request , response ) {
64+ var app = request . data . _plex_app ;
65+ var libraryType = request . slot ( 'libraryType' , null ) ;
66+ var library ;
67+
68+ if ( libraryType === 'tv shows' || libraryType === 'shows' ) {
69+ library = app . user . TVLibrary ;
70+ } else if ( libraryType === 'movies' || libraryType === 'films' ) {
71+ library = app . user . MovieLibrary ;
72+ }
73+
74+ plexutils . getRecentlyAdded ( app , library )
75+ . then ( plexutils . getShowNamesFromList )
76+ . then ( function ( mediaList ) {
77+ if ( mediaList . length === 0 ) {
78+ return response . say ( "You have not added any media recently!" ) . send ( ) ;
79+ }
80+
81+ var showListCard = mediaList . join ( '\n' ) ;
82+ var showSpokenListHyphenated = utils . buildNaturalLangList ( mediaList , 'and' , true ) ;
83+ var libraryTypeTitle = ( "Recently Added " + ( utils . toTitleCase ( libraryType ) || '' ) ) . trim ( ) ;
84+
85+ return response . say ( libraryTypeTitle + ": " + showSpokenListHyphenated + '.' )
86+ . card ( libraryTypeTitle , showListCard )
87+ . send ( ) ;
88+ } )
89+ . catch ( function ( err ) {
90+ app . skill . error ( err , request , response ) ;
91+ } ) ;
5992
6093 return false ;
6194} ;
@@ -220,6 +253,7 @@ var noIntent = function(request,response) {
220253module . exports = {
221254 intents : {
222255 'OnDeckIntent' : onDeckIntent ,
256+ 'RecentlyAddedIntent' : recentlyAddedIntent ,
223257 'StartShowIntent' : startShowIntent ,
224258 'StartRandomShowIntent' : startRandomShowIntent ,
225259 'StartSpecificEpisodeIntent' : startSpecificEpisodeIntent ,
0 commit comments