fix bugs in marmiton and 750g
This commit is contained in:
parent
93c5935972
commit
c4fc3df50a
6 changed files with 23 additions and 15 deletions
|
|
@ -17,7 +17,7 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from weboob.browser.exceptions import BrowserHTTPNotFound
|
||||||
from weboob.browser import PagesBrowser, URL
|
from weboob.browser import PagesBrowser, URL
|
||||||
from .pages import RecipePage, ResultsPage
|
from .pages import RecipePage, ResultsPage
|
||||||
|
|
||||||
|
|
@ -35,8 +35,11 @@ class SevenFiftyGramsBrowser(PagesBrowser):
|
||||||
return self.search.go(pattern=pattern.replace(' ', '_')).iter_recipes()
|
return self.search.go(pattern=pattern.replace(' ', '_')).iter_recipes()
|
||||||
|
|
||||||
def get_recipe(self, id, recipe=None):
|
def get_recipe(self, id, recipe=None):
|
||||||
recipe = self.recipe.go(id=id).get_recipe(obj=recipe)
|
try:
|
||||||
comments = list(self.page.get_comments())
|
recipe = self.recipe.go(id=id).get_recipe(obj=recipe)
|
||||||
if comments:
|
comments = list(self.page.get_comments())
|
||||||
recipe.comments = comments
|
if comments:
|
||||||
return recipe
|
recipe.comments = comments
|
||||||
|
return recipe
|
||||||
|
except BrowserHTTPNotFound:
|
||||||
|
return
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
from weboob.tools.test import BackendTest
|
from weboob.tools.test import BackendTest
|
||||||
import itertools
|
import itertools
|
||||||
|
|
||||||
|
|
||||||
class SevenFiftyGramsTest(BackendTest):
|
class SevenFiftyGramsTest(BackendTest):
|
||||||
MODULE = '750g'
|
MODULE = '750g'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from weboob.browser.exceptions import BrowserHTTPNotFound
|
||||||
from weboob.browser import PagesBrowser, URL
|
from weboob.browser import PagesBrowser, URL
|
||||||
|
|
||||||
from .pages import RecipePage, ResultsPage
|
from .pages import RecipePage, ResultsPage
|
||||||
|
|
@ -35,8 +35,11 @@ class MarmitonBrowser(PagesBrowser):
|
||||||
return self.search.go(pattern=pattern).iter_recipes()
|
return self.search.go(pattern=pattern).iter_recipes()
|
||||||
|
|
||||||
def get_recipe(self, id, recipe=None):
|
def get_recipe(self, id, recipe=None):
|
||||||
recipe = self.recipe.go(id=id).get_recipe(obj=recipe)
|
try:
|
||||||
comments = list(self.page.get_comments())
|
recipe = self.recipe.go(id=id).get_recipe(obj=recipe)
|
||||||
if comments:
|
comments = list(self.page.get_comments())
|
||||||
recipe.comments = comments
|
if comments:
|
||||||
return recipe
|
recipe.comments = comments
|
||||||
|
return recipe
|
||||||
|
except BrowserHTTPNotFound:
|
||||||
|
return
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ class MarmitonModule(Module, CapRecipe):
|
||||||
return self.browser.iter_recipes(quote_plus(pattern.encode('utf-8')))
|
return self.browser.iter_recipes(quote_plus(pattern.encode('utf-8')))
|
||||||
|
|
||||||
def fill_recipe(self, recipe, fields):
|
def fill_recipe(self, recipe, fields):
|
||||||
if 'nb_person' in fields or 'instructions' in fields:
|
if 'nb_person' in fields or 'instructions' in fields or 'thumbnail_url' in fields:
|
||||||
recipe = self.browser.get_recipe(recipe.id, recipe)
|
recipe = self.browser.get_recipe(recipe.id, recipe)
|
||||||
return recipe
|
return recipe
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,6 @@ class ResultsPage(HTMLPage):
|
||||||
obj_id = Regexp(CleanText('./div/div[@class="m_titre_resultat"]/a/@href'),
|
obj_id = Regexp(CleanText('./div/div[@class="m_titre_resultat"]/a/@href'),
|
||||||
'/recettes/recette_(.*).aspx')
|
'/recettes/recette_(.*).aspx')
|
||||||
obj_title = CleanText('./div/div[@class="m_titre_resultat"]/a')
|
obj_title = CleanText('./div/div[@class="m_titre_resultat"]/a')
|
||||||
obj_thumbnail_url = CleanText('./a[@class="m_resultat_lien_image"]', default='')
|
|
||||||
obj_short_description = Format('%s. %s',
|
obj_short_description = Format('%s. %s',
|
||||||
CleanText('./div/div[@class="m_detail_recette"]'),
|
CleanText('./div/div[@class="m_detail_recette"]'),
|
||||||
CleanText('./div/div[@class="m_texte_resultat"]'))
|
CleanText('./div/div[@class="m_texte_resultat"]'))
|
||||||
|
|
@ -71,7 +70,8 @@ class RecipePage(HTMLPage):
|
||||||
return ingredients[1:]
|
return ingredients[1:]
|
||||||
|
|
||||||
obj_instructions = CleanHTML('//div[@class="m_content_recette_todo"]')
|
obj_instructions = CleanHTML('//div[@class="m_content_recette_todo"]')
|
||||||
obj_picture_url = CleanText('//a[@class="m_content_recette_illu"]/@href', default=NotAvailable)
|
obj_thumbnail_url = CleanText('//a[@class="m_content_recette_illu"]/img/@src', default=NotAvailable)
|
||||||
|
obj_picture_url = CleanText('//a[@class="m_content_recette_illu"]/img/@src', default=NotAvailable)
|
||||||
|
|
||||||
@method
|
@method
|
||||||
class get_comments(ListElement):
|
class get_comments(ListElement):
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
from weboob.tools.test import BackendTest
|
from weboob.tools.test import BackendTest
|
||||||
import itertools
|
import itertools
|
||||||
|
|
||||||
|
|
||||||
class MarmitonTest(BackendTest):
|
class MarmitonTest(BackendTest):
|
||||||
MODULE = 'marmiton'
|
MODULE = 'marmiton'
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue