Ejemplo n.º 1
0
    def setUpClass(cls):
        config_file = os.path.join(HERE, 'config.json')

        with open(config_file) as fileobj:
            config = json.load(fileobj)

        cls.yummly = yummly.Client(api_id=config['api_id'],
                                   api_key=config['api_key'])

        cls.sample_recipe_id = 'Hot-Turkey-Salad-Sandwiches-Allrecipes'
Ejemplo n.º 2
0
def recipe():
    restricted_ingredients = request.form.get('search_terms')
    dietary_choice = request.form.get('dietary_choice')

    print restricted_ingredients
    print dietary_choice

    search_terms = 'tomato'

    try:

        # Yummly API info - see https://github.com/dgilland/yummly.py

        client = yummly.Client(api_id=API_ID,
                               api_key=API_KEY,
                               timeout=TIMEOUT,
                               retries=RETRIES)
        search = client.search(search_terms)

        # params = dict()
        #
        # params['q'] = search_terms
        # params['start'] = 0
        # params['maxResult'] = 10
        # params['requirePicutres'] = True
        # params['allowedIngredient[]'] = ['salt']
        # params['excludedIngredient[]'] = ['']
        # params['maxTotalTimeInSeconds'] = 3600
        # params['facetField[]'] = ['ingredient', 'diet']
        # params['flavor.meaty.min'] = 0.5
        # params['flavor.meaty.max'] = 1
        # params['flavor.sweet.min'] = 0
        # params['flavor.sweet.max'] = 0.5
        # params['nutrition.FAT.min'] = 0
        # params['nutrition.FAT.max'] = 15
        #
        # search = client.search(**params)

        match = search.matches[0]
        recipe = client.recipe(match.id)

    except:
        return render_template('error_recipe.html')

    return render_template('display_recipe.html',
                           recipe_name=recipe.name,
                           recipe_id=recipe.id,
                           recipe_rating=recipe.rating,
                           ingred_list=recipe.ingredientLines)
Ejemplo n.º 3
0
import yummly

# default option values
TIMEOUT = 15.0
RETRIES = 2

# Yummly mjboothaus Account: Hackathon Plan - Access granted 24 July 2017

API_ID = 'b4f167ed'
API_KEY = 'f69184af19beb4b76e7b7b1984046581'

client = yummly.Client(api_id=API_ID,
                       api_key=API_KEY,
                       timeout=TIMEOUT,
                       retries=RETRIES)

search = client.search('green eggs and ham')
match = search.matches[0]

match.id

recipe = client.recipe(match.id)

print recipe
Ejemplo n.º 4
0
__author__ = 'brandonkelly'

import yummly
import numpy as np
import time
import os
import cPickle
import pandas as pd

base_dir = os.environ['HOME'] + '/Projects/Insight/'
data_dir = base_dir + 'data/yummly/'

api_id = '50fd16ec'
api_key = '4f425532cc37ac4ef290004ceb2e6cb3'

client = yummly.Client(api_id=api_id, api_key=api_key, timeout=30.0, retries=0)

search = client.search('pulled pork', maxResult=500)

cPickle.dump(open(search, data_dir + 'pulled_pork_search.pickle', 'wb'))

recipes = []
print 'Fetching recipe'
for i, match in enumerate(search.matches):
    print i, '...'
    recipes.append(client.recipe(match.id))
    time.sleep(5)  # don't make too many calls to the API in rapid succession

cPickle.dump(open(recipes, data_dir + 'pulled_pork_recipes.pickle', 'wb'))