Skip to content

Commit

Permalink
Add thisdelicioushouse.com, fixes jpbulman#42
Browse files Browse the repository at this point in the history
  • Loading branch information
Eldemarkki committed Apr 4, 2022
1 parent 240b16f commit 6e994be
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
37 changes: 37 additions & 0 deletions lib/domain/annoyingDomains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,42 @@ const getChefkochData = (html: string): RecipeMetadata => {
}
}

const getThisDeliciousHouseData = (html: string): RecipeMetadata => {
const $ = cheerio.load(html);
const title = $('h1.entry-title').text().trim();

const ingredients: IngredientsSection[] = $('.wprm-recipe-ingredient-group')
.toArray()
.map(group => {
const g = $(group);
const groupName = g.find('h4').text().trim();
const rows = g.find("li.wprm-recipe-ingredient").toArray().map(row => {
const r = $(row)
const amount = r.find('span.wprm-recipe-ingredient-amount').text().trim();
const unit = r.find('span.wprm-recipe-ingredient-unit').text().trim();
const name = r.find('span.wprm-recipe-ingredient-name').text().trim();
const note = r.find('span.wprm-recipe-ingredient-notes').text().trim();
return note ?
`${amount} ${unit} ${name} ${note}`.trim() :
`${amount} ${unit} ${name}`.trim();
});

return {
sectionName: groupName,
ingredients: rows
}
});

const directions = $('div.wprm-recipe-instruction-text').toArray().map(element => $(element).text().trim());

return {
title,
ingredients,
directions,
domainIsSupported: true,
};
}

type annoyingDomainToSelectionFunction = {
[key in typeof annoyingToParseDomains[number]]: (html: string) => RecipeMetadata
}
Expand All @@ -238,4 +274,5 @@ export const selectionFunctionPerAnnoyingDomain : annoyingDomainToSelectionFunct
'cooking.nytimes.com' : getNYTCookingData,
'tasty.co' : getTastyCoData,
'chefkoch.de' : getChefkochData,
'thisdelicioushouse.com' : getThisDeliciousHouseData
}
2 changes: 2 additions & 0 deletions lib/domain/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const supportedDomains = [
'thefoodietakesflight.com',
'thepioneerwoman.com',
'thestayathomechef.com',
'thisdelicioushouse.com',
'valio.fi',
'whatsgabycooking.com',
'yhteishyva.fi'
Expand All @@ -54,6 +55,7 @@ export const annoyingToParseDomains = [
'cooking.nytimes.com',
'tasty.co',
'chefkoch.de',
'thisdelicioushouse.com',
] as const;

export const domainIsAnnoyingToParse = (domain: string): boolean => {
Expand Down

0 comments on commit 6e994be

Please sign in to comment.