pax_global_header 0000666 0000000 0000000 00000000064 13434601454 0014516 g ustar 00root root 0000000 0000000 52 comment=d0a72914b1b13c7766ca764ce93a9d23b473bfe7
woob-d0a72914b1b13c7766ca764ce93a9d23b473bfe7-modules-allrecipes/ 0000775 0000000 0000000 00000000000 13434601454 0023256 5 ustar 00root root 0000000 0000000 woob-d0a72914b1b13c7766ca764ce93a9d23b473bfe7-modules-allrecipes/modules/ 0000775 0000000 0000000 00000000000 13434601454 0024726 5 ustar 00root root 0000000 0000000 woob-d0a72914b1b13c7766ca764ce93a9d23b473bfe7-modules-allrecipes/modules/allrecipes/ 0000775 0000000 0000000 00000000000 13434601454 0027051 5 ustar 00root root 0000000 0000000 woob-d0a72914b1b13c7766ca764ce93a9d23b473bfe7-modules-allrecipes/modules/allrecipes/__init__.py 0000664 0000000 0000000 00000001516 13434601454 0031165 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2013 Julien Veyssier
#
# This file is part of a weboob module.
#
# This weboob module is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This weboob module is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this weboob module. If not, see .
from .module import AllrecipesModule
__all__ = ['AllrecipesModule']
woob-d0a72914b1b13c7766ca764ce93a9d23b473bfe7-modules-allrecipes/modules/allrecipes/browser.py 0000664 0000000 0000000 00000004012 13434601454 0031103 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2013 Julien Veyssier
#
# This file is part of a weboob module.
#
# This weboob module is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This weboob module is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this weboob module. If not, see .
from weboob.browser import PagesBrowser, URL
from .pages import ResultsPage, RecipePage, HomePage
from weboob.tools.compat import urlencode
__all__ = ['AllrecipesBrowser']
class AllrecipesBrowser(PagesBrowser):
BASEURL = 'https://apps.allrecipes.com'
results = URL('/v1/recipes\?(?P.*)', ResultsPage)
recipe = URL('/v1/recipes/(?P<_id>.*)/', RecipePage)
home = URL('http://allrecipes.com', HomePage)
TOKEN = None
def fill_token(self):
self.home.open()
self.TOKEN = 'Bearer %s' % self.session.cookies.get('ARToken')
self.session.headers['X-Requested-With'] = 'XMLHttpRequest'
self.session.headers['Authorization'] = self.TOKEN
def iter_recipes(self, pattern):
query = {'query': pattern,
'page': 1,
'pagesize': 20,
'sort': 're'}
if not self.TOKEN:
self.fill_token()
return self.results.go(query=urlencode(query)).iter_recipes()
def get_recipe(self, _id, obj=None):
if not self.TOKEN:
self.fill_token()
recipe = self.recipe.go(_id=_id).get_recipe(obj=obj)
comments = list(self.page.get_comments())
if comments:
recipe.comments = comments
return recipe
woob-d0a72914b1b13c7766ca764ce93a9d23b473bfe7-modules-allrecipes/modules/allrecipes/favicon.png 0000664 0000000 0000000 00000002462 13434601454 0031210 0 ustar 00root root 0000000 0000000 PNG
IHDR @ @ iq sRGB bKGD pHYs tIME0* IDATxhU??ZVQihfT0)
4(9Ċ"%+Dd߃n2aiia4ÌHj.y}ny{`9{g(-BΨ4ϔ |sib(=F i@( D " @HS*)gPt2FJ\Yn!_z@'o@ D " e-#u`Ψ@30+#j&=h.[:#xS^/L\'zw["u!B`1[i ^~>ׄeKk<
xU[[[ pF]<
ꁯ%(=? 8M(`z?劒 x!/K[,_
+
Dٿ
pp,x,am}:W[g`^Z˖-"p>߿]`;%x4W'J
j;[bj3bRt{I\6$''{@S4L?m@+V̽%uv$dr3Xj@I.l(¹"io8 ҤoHӖhIlV/dX lV
ΨJ~piw $W[cJZ!^?Iş_Vm?Ψ3,;,yzt8^`U@GPjw;Kђv OrE Ru`ll:{JcJVL 9W2, >}uR/T gԄ$!8wj[#zmyI ,uxF[:Ȇ'ͦC ^_Oo
G^[FSD x20I~g4>q-u[
JAI{Qى\&41߳U匪qFMJ`wcQŶ>h9]\3X j h;,66~GNA;o~SXC9fѷ(+'b>/fAB7_+&ߏ B Q%{$|ʵ+uygT3jW9r0%J5@ IENDB` woob-d0a72914b1b13c7766ca764ce93a9d23b473bfe7-modules-allrecipes/modules/allrecipes/module.py 0000664 0000000 0000000 00000003252 13434601454 0030712 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2013 Julien Veyssier
#
# This file is part of a weboob module.
#
# This weboob module is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This weboob module is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this weboob module. If not, see .
from weboob.capabilities.recipe import CapRecipe, Recipe
from weboob.tools.backend import Module
from weboob.tools.compat import quote_plus
from .browser import AllrecipesBrowser
__all__ = ['AllrecipesModule']
class AllrecipesModule(Module, CapRecipe):
NAME = 'allrecipes'
MAINTAINER = u'Julien Veyssier'
EMAIL = 'julien.veyssier@aiur.fr'
VERSION = '1.5'
DESCRIPTION = u'Allrecipes English recipe website'
LICENSE = 'AGPLv3+'
BROWSER = AllrecipesBrowser
def get_recipe(self, id):
return self.browser.get_recipe(id)
def iter_recipes(self, pattern):
return self.browser.iter_recipes(quote_plus(pattern.encode('utf-8')))
def fill_recipe(self, recipe, fields):
if 'nb_person' in fields or 'instructions' in fields or 'picture' in fields:
recipe = self.browser.get_recipe(recipe.id, recipe)
return recipe
OBJECTS = {Recipe: fill_recipe}
woob-d0a72914b1b13c7766ca764ce93a9d23b473bfe7-modules-allrecipes/modules/allrecipes/pages.py 0000664 0000000 0000000 00000006065 13434601454 0030531 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2013 Julien Veyssier
#
# This file is part of a weboob module.
#
# This weboob module is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This weboob module is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this weboob module. If not, see .
from weboob.browser.pages import HTMLPage, JsonPage, pagination
from weboob.browser.elements import ItemElement, DictElement, method
from weboob.capabilities.recipe import Recipe, Comment
from weboob.capabilities.base import NotAvailable
from weboob.capabilities.image import BaseImage, Thumbnail
from weboob.browser.filters.standard import Env, Format, Join, Eval
from weboob.browser.filters.json import Dict
class HomePage(HTMLPage):
pass
class ResultsPage(JsonPage):
@pagination
@method
class iter_recipes(DictElement):
item_xpath = 'recipes'
def next_page(self):
return Dict('links/next/href', default=None)(self.page.doc)
class item(ItemElement):
klass = Recipe
obj_id = Dict('recipeID')
obj_title = Dict('title')
obj_short_description = Dict('description')
class RecipePage(JsonPage):
@method
class get_recipe(ItemElement):
klass = Recipe
obj_id = Env('_id')
obj_title = Dict('title')
obj_short_description = Dict('description')
obj_preparation_time = Dict('prepMinutes')
obj_cooking_time = Dict('cookMinutes')
def obj_nb_person(self):
nb_pers = u'%s' % Dict('servings', default='')(self)
return [nb_pers] if nb_pers else NotAvailable
def obj_ingredients(self):
ingredients = []
for el in Dict('ingredients')(self):
ing = Format('%s (%s gramm)',
Dict('displayValue'),
Dict('grams'))(el)
ingredients.append(ing)
return ingredients
def obj_instructions(self):
ins = [Dict('displayValue')(el) for el in Dict('directions')(self)]
return Join('\n * ', ins, addBefore=' * ', addAfter='\n')(self)
class obj_picture(ItemElement):
klass = BaseImage
obj_url = Dict('photo/photoDetailUrl')
obj_thumbnail = Eval(Thumbnail, obj_url)
@method
class get_comments(DictElement):
item_xpath = 'topReviews'
class item(ItemElement):
klass = Comment
obj_author = Dict('submitter/name')
obj_rate = Dict('rating')
obj_text = Dict('text')
obj_id = Dict('reviewID')
woob-d0a72914b1b13c7766ca764ce93a9d23b473bfe7-modules-allrecipes/modules/allrecipes/test.py 0000664 0000000 0000000 00000002304 13434601454 0030401 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2013 Julien Veyssier
#
# This file is part of a weboob module.
#
# This weboob module is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This weboob module is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this weboob module. If not, see .
from weboob.tools.test import BackendTest
import itertools
class AllrecipesTest(BackendTest):
MODULE = 'allrecipes'
def test_recipe(self):
recipes = list(itertools.islice(self.backend.iter_recipes('french fries'), 0, 20))
assert len(recipes)
full_recipe = self.backend.get_recipe(recipes[0].id)
assert full_recipe.instructions
assert full_recipe.ingredients
assert full_recipe.title