Created
July 27, 2017 14:53
-
-
Save jazzyjackson/f56cee93bbee1632d042c66ede22484b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
concept: ~genre [ "acoustic" "afrobeat" "alt-rock" "alternative" "ambient" "anime" "black-metal" "bluegrass" "blues" "bossanova" "brazil" "breakbeat" "british" "cantopop" "chicago-house" "children" "chill" "classical" "club" "comedy" "country" "dance" "dancehall" "death-metal" "deep-house" "detroit-techno" "disco" "disney" "drum-and-bass" "dub" "dubstep" "edm" "electro" "electronic" "emo" "folk" "forro" "french" "funk" "garage" "german" "gospel" "goth" "grindcore" "groove" "grunge" "guitar" "happy" "hard-rock" "hardcore" "hardstyle" "heavy-metal" "hip-hop" "holidays" "honky-tonk" "house" "idm" "indian" "indie" "indie-pop" "industrial" "iranian" "j-dance" "j-idol" "j-pop" "j-rock" "jazz" "k-pop" "kids" "latin" "latino" "malay" "mandopop" "metal" "metal-misc" "metalcore" "minimal-techno" "movies" "mpb" "new-age" "new-release" "opera" "pagode" "party" "philippines-opm" "piano" "pop" "pop-film" "post-dubstep" "power-pop" "progressive-house" "psych-rock" "punk" "punk-rock" "r-n-b" "rainy-day" "reggae" "reggaeton" "road-trip" "rock" "rock-n-roll" "rockabilly" "romance" "sad" "salsa" "samba" "sertanejo" "show-tunes" "singer-songwriter" "ska" "sleep" "songwriter" "soul" "soundtracks" "spanish" "study" "summer" "swedish" "synth-pop" "tango" "techno" "trance" "trip-hop" "turkish" "work-out" "world-music" ] | |
topic: ~spotify keep repeat stay [play pause music song next previous ~genre] | |
u: (%length=1 _[play pause next previous]) | |
$$tmp = ^jsonopen(GET ^"\"http://localhost:3000/spotifycontrol?control=_0\"" "") | |
if( $$tmp.error ){ | |
I was unable to control Spotify. | |
} else if(_0=next){ | |
^sleep(500) # Wait a half second before checking the current song. Seems to be a race, current song sometimes returned previous song | |
$$currentSong = ^jsonopen(GET ^"\"http://localhost:3000/spotifycontrol?current=current\"" "") | |
if( $$currentSong.error ){ | |
Couldn't connect to Spotify. Maybe nothing is playing. | |
} else { | |
Now playing \" $$currentSong.track \" by $$currentSong.artist | |
} | |
} else { | |
Spotify replied 'OK' | |
} | |
u: (play * _~genre) | |
$$tmp = ^jsonopen(GET ^"\"http://localhost:3000/spotifycontrol?genre=_0\"" "") | |
if( !$$tmp.track ){ | |
I was unable to control Spotify. | |
} else { | |
You asked for _0, I found \" $$tmp.track \" by $$tmp.artist | |
} | |
u: (play * [something music song] * by _* ) | |
$$artist = substitute(character ^original(_0) " " + ) # replace space with plus | |
$$tmp = ^jsonopen(GET ^"\"http://localhost:3000/spotifycontrol?artist=$$artist\"" "") | |
if( !$$tmp.track ){ | |
I couldn't find results for ^original(_0) | |
} else { | |
Here's \" $$tmp.track \" by $$tmp.artist | |
} | |
u: (play _* by _*) | |
$$track = substitute(character ^original(_0) " " + ) # replace space with plus | |
$$artist = substitute(character ^original(_1) " " + ) | |
$$tmp = ^jsonopen(GET ^"\"http://localhost:3000/spotifycontrol?track=$$track&artist=$$artist\"" "") | |
if( !$$tmp.track ){ | |
I couldn't find any results for $$track by $$artist | |
} else { | |
Hopefully now I'm playing \" $$tmp.track \" by $$tmp.artist | |
} | |
u: (~qwords * [play song]) | |
$$tmp = ^jsonopen(GET ^"\"http://localhost:3000/spotifycontrol?current=current\"" "") | |
if( $$tmp.error ){ | |
Couldn't connect to Spotify. Maybe nothing is playing. | |
} else { | |
\" $$tmp.track \" by $$tmp.artist | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment