-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 34bcd35
Showing
4 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
settings.json | ||
__pycache__ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
## Cocktail | ||
Cocktail recipies using thecocktaildb | ||
|
||
## Description | ||
Lets mycroft read drink and cocktail recipies. | ||
|
||
For devices with screen support, conditions are briefly shown. | ||
|
||
## Examples | ||
* "How do I make a moscow mule" | ||
* "How do I mix a gin and tonic" | ||
|
||
## Credits | ||
Åke Forslund |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from mycroft import MycroftSkill, intent_file_handler | ||
from mycroft.util.log import LOG | ||
import requests | ||
import time | ||
|
||
|
||
API_KEY = '1' | ||
API_URL = 'https://www.thecocktaildb.com/api/json/v1/{}/'.format(API_KEY) | ||
SEARCH = API_URL + 'search.php' | ||
|
||
|
||
def search_cocktail(name): | ||
r = requests.get(SEARCH, params={'s': name}) | ||
if 200 <= r.status_code < 300: | ||
return r.json()['drinks'][0] | ||
else: | ||
return None | ||
|
||
|
||
def ingredients(drink): | ||
ingredients = [] | ||
for i in range(1, 15): | ||
if not drink['strIngredient' + str(i)]: | ||
break | ||
ingredients.append(' '.join((drink['strMeasure' + str(i)], | ||
drink['strIngredient' + str(i)]))) | ||
return ingredients | ||
|
||
|
||
class CocktailSkill(MycroftSkill): | ||
@intent_file_handler('Recipie.intent') | ||
def get_recipie(self, message): | ||
LOG.info('!!!!!!!!!!!') | ||
LOG.info(message.data['recepie']) | ||
cocktail = search_cocktail(message.data['recepie']) | ||
if cocktail: | ||
ingredient_speech = 'You\'ll need ' | ||
for i in ingredients(cocktail)[:-1]: | ||
print(i) | ||
ingredient_speech += ', ' + i | ||
ingredient_speech += ' and ' | ||
ingredient_speech += ingredients(cocktail)[-1] | ||
self.speak(ingredient_speech) | ||
time.sleep(1) | ||
self.speak(cocktail['strInstructions']) | ||
|
||
|
||
def create_skill(): | ||
return CocktailSkill() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
how do i make (a|an) {recepie} | ||
how do i mix (a|an) {recepie} | ||
tell me how to mix (a|an) {recepie} | ||
give me instructions for (a|an) {recepie} |