Class Definition

class @com.spotify extends @org.thingpedia.media-player, @org.thingpedia.media-source #_[thingpedia_name="Spotify"] #_[thingpedia_description="Play music on Spotify"] #_[canonical="spotify"] #_[name="Spotify Account of ${display_name}"] #_[description="This is your Spotify Account"] #[license="BSD-3-Clause"] #[license_gplcompatible=true] #[subcategory=enum media] #[version=157] #[package_version=157] { import loader from @org.thingpedia.v2(); import config from @org.thingpedia.config.oauth2(client_id="<hidden>", client_secret="<hidden>", use_pkce=true, authorize="https://accounts.spotify.com/authorize"^^tt:url, get_access_token="https://accounts.spotify.com/api/token"^^tt:url, scope=["streaming", "playlist-read-collaborative", "playlist-modify-private", "playlist-read-private", "playlist-modify-public", "user-read-email", "user-read-private", "user-read-playback-state", "user-read-currently-playing", "user-modify-playback-state", "user-read-recently-played", "user-top-read", "user-follow-read", "user-follow-modify", "user-library-read", "user-library-modify"], get_profile="https://api.spotify.com/v1/me"^^tt:url, profile=["id", "display_name", "product"]); monitorable list query get_user_top_tracks(out song : Entity(org.thingpedia.media-source:song) #_[canonical="song"] #[string_values="tt:song_name"]) #_[canonical="spotify top tracks"] #_[confirmation="my top tracks in Spotify"] #_[on_error={ rate_limit_error=["spotify is temporarily unavailable"] }] #[poll_interval=3600000ms] #[doc="get user's top tracks in the last 4 weeks"] #[minimal_projection=[]] #[confirm=false]; action add_song_to_playlist(in req song : Entity(org.thingpedia.media-source:song) #_[prompt=["what song do you want to add"]] #_[canonical={ default="base", base=["song name name"], property=["song name #", "song title #"] }] #[string_values="tt:song_name"], in req playlist : String #_[prompt=["what playlist do you want to add to"]] #_[canonical={ default="base", base=["name"], preposition=["named #", "called #", "titled #"], property=["name #", "title #"] }] #[string_values="com.spotify:playlist"] #[raw_mode=true]) #_[canonical="add a song to a playlist"] #_[confirmation="add the song $song to the playlist $playlist"] #_[on_error={ disallowed_action=["you cannot add songs to this playlist"], no_playlist=["could not find this playlist"], rate_limit_error=["spotify is temporarily unavailable"] }] #[confirm=enum auto] #[minimal_projection=[]]; action create_playlist(in req name : String #_[prompt=["what do you want to name your playlist"]] #_[canonical={ default="base", base=["name"], preposition=["named #", "called #", "titled #"], property=["name #", "title #"] }] #[string_values="com.spotify:playlist"] #[raw_mode=true]) #_[canonical="create a new playlist"] #_[confirmation="create a playlist named $playlistName"] #_[on_error={ disallowed_action=["failed to create a playlist"], rate_limit_error=["spotify is temporarily unavailable"] }] #[confirm=enum auto] #[minimal_projection=[]]; action add_item_to_library(in req playable : Entity(org.thingpedia.media-source:playable) #_[prompt=["what item do you want to add to your favorite"]] #_[canonical={ default="base", base=["name"], preposition=["named #", "called #", "titled #"], property=["name #", "title #"] }] #[string_values="tt:song_name"]) #_[canonical="add a song to my favorites"] #_[confirmation="add $playable to your library"] #_[on_error={ no_item_to_add=["there is no item to be added to your library"], unsupported_item=["adding this item to your library is currently unsupported"], disallowed_action=["you cannot add items to your library"], rate_limit_error=["spotify is temporarily unavailable"] }] #[confirm=enum auto] #[minimal_projection=[]]; action add_artist_to_library(in req artist : Entity(org.thingpedia.media-source:artist) #_[prompt=["which artist do you want to fol"]] #_[canonical={ default="base", base=["name"], preposition=["named #", "called #", "titled #"], property=["name #", "title #"] }] #[string_values="tt:song_artist"]) #_[canonical="add an artist to my favorites"] #_[confirmation="add $artist to your library"] #_[on_error={ no_item_to_add=["there is no artist to be added to your library"], unsupported_item=["adding this item to your library is currently unsupported"], disallowed_action=["you cannot add items to your library"], rate_limit_error=["spotify is temporarily unavailable"] }] #[confirm=enum auto] #[minimal_projection=[]]; }

Dataset

dataset @com.spotify #[language="en"] { stream = monitor(@com.spotify.get_user_top_tracks()) #_[utterances=["when my top tracks changes", "when I have new favorite songs"]] #[id=62939478] #[name="MonitorGetUserTopTracks"]; query (p_song : String, p_artist : Entity(org.thingpedia.media-source:artist)) = @org.thingpedia.media-source.playable() filter contains(artists, p_artist) && id =~ p_song #_[utterances=["${p_song:no-undefined} by ${p_artist}", "${p_song:no-undefined} from ${p_artist}"]] #[id=63226439] #[name="PlayableByArtistsAndById"]; stream (p_artist : Entity(org.thingpedia.media-source:artist)) = monitor(id of @org.thingpedia.media-source.playable() filter contains(artists, p_artist)) #_[utterances=["when ${p_artist} releases new music", "when ${p_artist} releases something new"]] #[id=63226441] #[name="MonitorPlayableByArtists"]; stream (p_artist : Entity(org.thingpedia.media-source:artist)) = monitor(id of @org.thingpedia.media-source.album() filter contains(artists, p_artist)) #_[utterances=["when ${p_artist} releases a new album"]] #[id=63226443] #[name="MonitorAlbumByArtists"]; query (p_artist : Entity(org.thingpedia.media-source:artist)) = sort(popularity desc of @org.thingpedia.media-source.playable() filter contains(artists, p_artist)) #_[utterances=["popular music by ${p_artist:no-undefined}"]] #[id=63226444] #[name="SortPopularityDescPlayableByArtists"]; query (p_artist : Entity(org.thingpedia.media-source:artist)) = sort(release_date desc of @org.thingpedia.media-source.playable() filter contains(artists, p_artist)) #_[utterances=["new ${p_artist:no-undefined}", "new music from ${p_artist:no-undefined}", "${p_artist:no-undefined} by the new first"]] #[id=63226445] #[name="SortReleaseDateDescPlayableByArtists"]; program = @org.thingpedia.media-source.get_currently_playing() #_[utterances=["what song is playing?", "what music is playing?", "what is playing?", "what song is currently on?"]] #[id=63226448] #[name="GetCurrentlyPlaying"]; action = @org.thingpedia.media-player.player_shuffle(shuffle=enum on) #_[utterances=["start shuffle", "turn shuffle on"]] #[id=63226482] #[name="PlayerShuffleWithShuffleOn"]; action (p_state : Enum(on, off)) = @org.thingpedia.media-player.player_shuffle(shuffle=p_state) #_[utterances=["turn shuffle ${p_state}", "turn ${p_state} shuffle"]] #[id=63226484] #[name="PlayerShuffleWithShuffle"]; action = @org.thingpedia.media-player.player_repeat(repeat=enum track) #_[utterances=["repeat this song", "turn on repeat"]] #[id=63226486] #[name="PlayerRepeatWithRepeatTrack"]; action = @org.thingpedia.media-player.player_repeat(repeat=enum off) #_[utterances=["turn off repeat"]] #[id=63226488] #[name="PlayerRepeatWithRepeatOff"]; program = @org.thingpedia.media-player.play() #_[utterances=["play some music on spotify", "open spotify and play some music", "use spotify to play some music"]] #[id=63226489] #[name="Play"]; action (p_song : Entity(org.thingpedia.media-source:playable)) = @org.thingpedia.media-player.play(playable=p_song) #_[utterances=["play ${p_song:no-undefined} on spotify", "play ${p_song:no-undefined}"]] #[id=63226492] #[name="PlayWithPlayable"]; program (p_song : String) = @org.thingpedia.media-source.playable() filter id =~ p_song => @org.thingpedia.media-player.play(playable=id) #_[utterances=["i would like to hear ${p_song:const}", "i would like to listen to ${p_song:const}", "play ${p_song:const} on spotify", "on spotify play ${p_song:const}", "play ${p_song:const}"]] #[id=63226494] #[name="PlayableByIdAndPlayWithPlayable"]; program (p_genre : String) = @org.thingpedia.media-source.playable() filter contains~(genres, p_genre) => @org.thingpedia.media-player.play(playable=id) #_[utterances=["i would like to hear some ${p_genre:const}", "i would like to listen to ${p_genre:const} music", "play ${p_genre:const} on spotify", "on spotify play ${p_genre:const} music", "play ${p_genre:const} music"]] #[id=63226499] #[name="PlayableByGenresAndPlayWithPlayable"]; program (p_artist : Entity(org.thingpedia.media-source:artist)) = @org.thingpedia.media-source.playable() filter contains(artists, p_artist) => @org.thingpedia.media-player.play(playable=id) #_[utterances=["play ${p_artist:no-undefined}", "play some ${p_artist:no-undefined}", "play the artist ${p_artist:no-undefined}", "i would like to hear ${p_artist:no-undefined}", "i would like to listen to ${p_artist:no-undefined}", "i would like to listen to the artist ${p_artist:no-undefined}"]] #[id=63226504] #[name="PlayableByArtistsAndPlayWithPlayable"]; program (p_album : String, p_artist : Entity(org.thingpedia.media-source:artist)) = @org.thingpedia.media-source.album() filter contains(artists, p_artist) && id =~ p_album => @org.thingpedia.media-player.play(playable=id) #_[utterances=["play the album ${p_album:no-undefined} by ${p_artist:no-undefined}", "i would like to listen to the album ${p_album:no-undefined} by ${p_artist:no-undefined}", "i would like to listen to the album ${p_album:no-undefined} from ${p_artist:no-undefined}"]] #[id=63226510] #[name="AlbumByArtistsAndByIdAndPlayWithPlayable"]; program (p_show : String) = @org.thingpedia.media-source.show() filter id =~ p_show => @org.thingpedia.media-player.play(playable=id) #_[utterances=["play the podcast ${p_show:no-undefined}", "play the show ${p_show:no-undefined}", "i would like to listen to the show ${p_show:no-undefined}", "i would like to listen to the podcast ${p_show:no-undefined}"]] #[id=63226513] #[name="ShowByIdAndPlayWithPlayable"]; program (p_song : String, p_playlist : String) = @org.thingpedia.media-source.song() filter id =~ p_song => @com.spotify.add_song_to_playlist(playlist=p_playlist, song=id) #_[utterances=["add ${p_song:no-undefined} to ${p_playlist}", "put ${p_song:no-undefined} in ${p_playlist}"]] #[id=63228034] #[name="SongByIdAndAddSongToPlaylistWithPlaylistWithSong"]; program (p_song : Entity(org.thingpedia.media-source:song), p_playlist : String) = @com.spotify.add_song_to_playlist(playlist=p_playlist, song=p_song) #_[utterances=["add ${p_song} to ${p_playlist}", "put ${p_song} in ${p_playlist}"]] #[id=63228036] #[name="AddSongToPlaylistWithPlaylistWithSong"]; program (p_playlist : String) = @org.thingpedia.media-source.get_currently_playing() => @com.spotify.add_song_to_playlist(playlist=p_playlist, song=id) #_[utterances=["add this song to ${p_playlist}", "add song to ${p_playlist}", "put song in ${p_playlist}", "put this song in ${p_playlist}"]] #[id=63228038] #[name="GetCurrentlyPlayingAndAddSongToPlaylistWithPlaylistWithSong"]; action (p_playable : Entity(org.thingpedia.media-source:playable)) = @com.spotify.add_item_to_library(playable=p_playable) #_[utterances=["add ${p_playable} to my favorite", "put ${p_playable} in my favorite", "save ${p_playable} to my favorite", "add ${p_playable} to my library", "put ${p_playable} in my library", "save ${p_playable} to my library", "like ${p_playable:no-undefined}", "favorite ${p_playable:no-undefined}", "save ${p_playable:no-undefined}", "keep ${p_playable:no-undefined}", "love ${p_playable:no-undefined}", "remember ${p_playable:no-undefined}"]] #[id=63228043] #[name="AddItemToLibraryWithPlayable"]; action (p_artist : Entity(org.thingpedia.media-source:artist)) = @com.spotify.add_artist_to_library(artist=p_artist) #_[utterances=["add artist ${p_artist} to my favorite", "put artist ${p_artist} in my favorite", "save artist ${p_artist} to my favorite", "add artist ${p_artist} to my library", "put artist ${p_artist} in my library", "save artist ${p_artist} to my library"]] #[id=63228055] #[name="AddArtistToLibraryWithArtist"]; action = @org.thingpedia.media-source.get_currently_playing() => @com.spotify.add_item_to_library(playable=id) #_[utterances=["add this to my favorite", "put this in my favorite", "save this to my favorite", "add this to my library", "put this in my library", "save this to my library", "like this", "favorite this", "save this", "keep this", "love this", "remember this"]] #[id=63228061] #[name="GetCurrentlyPlayingAndAddItemToLibraryWithPlayable"]; }