From 7292fb734493420c29c70b0d17ca313aeb3a2731 Mon Sep 17 00:00:00 2001 From: Hayden Date: Fri, 8 Jan 2021 17:38:53 -0900 Subject: [PATCH] improve image return speed --- mealie/data/debug/last_recipe.json | 154 ++++++++++++++--------------- mealie/services/image_services.py | 9 +- 2 files changed, 81 insertions(+), 82 deletions(-) diff --git a/mealie/data/debug/last_recipe.json b/mealie/data/debug/last_recipe.json index 7f93d399..fff1da02 100644 --- a/mealie/data/debug/last_recipe.json +++ b/mealie/data/debug/last_recipe.json @@ -1,98 +1,94 @@ { - "@context": "http://schema.org", + "@context": "https://schema.org/", "@type": "Recipe", - "articleBody": "\u201cAfter a draining day juggling work, homeschooling, and urging children to stop using their masks as slingshots, the ideal food for me isn\u2019t perfectly prepared food that\u2019s been tweezered into position, but a meal that\u2019s simply comforting,\u201d writes the Smitten Kitchen\u2019s Deb Perelman. Right now, it\u2019s this deeply cozy pot of tender chicken thighs, jammy leeks, and broth-soaked rice.", - "alternativeHeadline": "This one-skillet dinner gets deep oniony flavor from lots of leeks cooked down to jammy tenderness.", - "dateModified": "2021-01-06 17:07:07.791000", - "datePublished": "2020-08-18 04:00:00", - "keywords": [ - "recipes", - "chicken recipes", - "kosher salt", - "black pepper", - "butter", - "leek", - "lemon zest", - "rice", - "chicken broth", - "anchovy", - "garlic", - "capers", - "herb", - "olive oil", - "healthyish", - "web" - ], - "thumbnailUrl": "https://assets.bonappetit.com/photos/5f29796456f43685a49327fb/1:1/w_1125,h_1125,c_limit/Chicken-and-Rice-With-Leeks-Salsa-Verde-01.jpg", - "publisher": { - "@context": "https://schema.org", - "@type": "Organization", - "name": "Bon App\u00e9tit", - "logo": { - "@type": "ImageObject", - "url": "https://www.bonappetit.com/verso/static/bon-appetit/assets/logo-seo.328de564b950e3d5d1fbe3e42f065290ca1d3844.png", - "width": "479px", - "height": "100px" - }, - "url": "https://www.bonappetit.com" + "name": "Pressure Cooker Chicken Tortilla Soup", + "description": "", + "author": { + "@type": "Person", + "name": "Kitschen Cat" }, - "isPartOf": { - "@type": [ - "CreativeWork", - "Product" - ], - "name": "Bon App\u00e9tit" - }, - "isAccessibleForFree": true, - "author": [ - { - "@type": "Person", - "name": "Deb Perelman", - "sameAs": "https://bon-appetit.com/contributor/deb-perelman/" - } - ], - "aggregateRating": { - "@type": "AggregateRating", - "ratingValue": 4, - "ratingCount": 47 - }, - "description": "This one-skillet dinner gets deep oniony flavor from lots of leeks cooked down to jammy tenderness.", - "image": "chicken-and-rice-with-leeks-and-salsa-verde.jpg", - "headline": "Chicken and Rice With Leeks and Salsa Verde", - "name": "Chicken and Rice With Leeks and Salsa Verde", + "image": null, + "url": "https://www.kitschencat.com/pressure-cooker-chicken-tortilla-soup/", "recipeIngredient": [ - "1\u00bd lb. skinless, boneless chicken thighs (4\u20138 depending on size)", - "Kosher salt, freshly ground pepper", - "3 Tbsp. unsalted butter, divided", - "2 large or 3 medium leeks, white and pale green parts only, halved lengthwise, thinly sliced", - "Zest and juice of 1 lemon, divided", - "1\u00bd cups long-grain white rice, rinsed until water runs clear", - "2\u00be cups low-sodium chicken broth", - "1 oil-packed anchovy fillet", - "2 garlic cloves", - "1 Tbsp. drained capers", - "Crushed red pepper flakes", - "1 cup tender herb leaves (such as parsley, cilantro, and/or mint)", - "4\u20135 Tbsp. extra-virgin olive oil" + "2 Large Chicken Breasts", + "12 oz your favorite salsa", + "6 Cups Chicken Broth", + "1 onion, chopped", + "1 red bell pepper, diced", + "2 teaspoons cumin", + "1 tablespoon chili powder", + "2 teaspoons salt", + "1/2 teaspoon black pepper", + "1/8 teaspoon cayenne pepper", + "4 ounces tomato paste", + "1 15oz can black beans, drained and rinsed", + "2 cups frozen corn", + "limes, sour cream or greek yogurt, cilantro, green onion, avocado, tortilla chips" ], "recipeInstructions": [ { "@type": "HowToStep", - "text": "Season chicken with salt and pepper. Melt 2 Tbsp. butter in a large high-sided skillet over medium-high heat. Add leeks and half of lemon zest, season with salt and pepper, and mix to coat leeks in butter. Reduce heat to medium-low, cover, and cook, stirring occasionally, until leeks are somewhat tender, about 5 minutes. Remove lid, increase heat to medium-high, and cook, stirring occasionally, until tender and just starting to take on color, about 3 minutes. Add rice and cook, stirring often, 3 minutes, then add broth, scraping up any browned bits. Tuck short sides of each chicken thigh underneath so they are touching and nestle seam side down into rice mixture. Bring to a simmer. Cover, reduce heat to medium-low, and cook until rice is tender and chicken is cooked through, about 20 minutes. Remove from heat. Cut remaining 1 Tbsp. butter into small pieces and scatter over mixture. Re-cover and let sit 10 minutes." + "text": "In pressure cooking pot, add chicken, salsa, chicken broth, onion, bell pepper, cumin, chili powder, salt, black pepper, cayenne pepper, and tomato paste. Stir together.", + "url": "https://www.kitschencat.com/pressure-cooker-chicken-tortilla-soup/#instruction-step-1" }, { "@type": "HowToStep", - "text": "Meanwhile, pulse anchovy, garlic, capers, a few pinches of red pepper flakes, and remaining lemon zest in a food processor until finely chopped. Add herbs; process until a paste forms. With motor running, gradually stream in oil until loosened to a thick sauce. Add half of lemon juice; season salsa verde with salt." + "text": "Lock lid and set to high pressure for 10 minutes.", + "url": "https://www.kitschencat.com/pressure-cooker-chicken-tortilla-soup/#instruction-step-2" }, { "@type": "HowToStep", - "text": "Drizzle remaining lemon juice over chicken and rice. Serve with salsa verde." + "text": "When time is up, allow pressure to naturally release for 10 minutes and then use a quick release to get all the remaining pressure out.", + "url": "https://www.kitschencat.com/pressure-cooker-chicken-tortilla-soup/#instruction-step-3" + }, + { + "@type": "HowToStep", + "text": "Remove lid and shred chicken using two forks.", + "url": "https://www.kitschencat.com/pressure-cooker-chicken-tortilla-soup/#instruction-step-4" + }, + { + "@type": "HowToStep", + "text": "Set pressure cooker to “simmer” setting and add black beans and corn. Stir until corn is heated through.", + "url": "https://www.kitschencat.com/pressure-cooker-chicken-tortilla-soup/#instruction-step-5" + }, + { + "@type": "HowToStep", + "text": "Ladle into bowls and top with a squeeze of lime juice, a dollop of sour cream or greek yogurt, a few sprigs of cilantro, chopped green onion, chopped avocado, and crushed tortilla chips.", + "url": "https://www.kitschencat.com/pressure-cooker-chicken-tortilla-soup/#instruction-step-6" } ], - "recipeYield": "4 Servings", - "url": "https://www.bonappetit.com/recipe/chicken-and-rice-with-leeks-and-salsa-verde", - "slug": "chicken-and-rice-with-leeks-and-salsa-verde", - "orgURL": "https://www.bonappetit.com/recipe/chicken-and-rice-with-leeks-and-salsa-verde", + "prepTime": "0:10:00", + "cookTime": "0:10:00", + "totalTime": "0:20:00", + "recipeYield": "8", + "aggregateRating": { + "@type": "AggregateRating", + "reviewCount": "1", + "ratingValue": "5" + }, + "review": [ + { + "@type": "Review", + "reviewRating": { + "@type": "Rating", + "ratingValue": "5" + }, + "author": { + "@type": "Person", + "name": "Alison" + }, + "datePublished": "2017-05-08", + "reviewBody": "Simple and delicious, even my kids loved it!" + } + ], + "datePublished": "2017-01-18", + "@id": "https://www.kitschencat.com/pressure-cooker-chicken-tortilla-soup/#recipe", + "isPartOf": { + "@id": "https://www.kitschencat.com/pressure-cooker-chicken-tortilla-soup/#webpage" + }, + "mainEntityOfPage": "https://www.kitschencat.com/pressure-cooker-chicken-tortilla-soup/#webpage", + "slug": "pressure-cooker-chicken-tortilla-soup", + "orgURL": "https://www.kitschencat.com/pressure-cooker-chicken-tortilla-soup/", "categories": [], "tags": [], "dateAdded": null, diff --git a/mealie/services/image_services.py b/mealie/services/image_services.py index a9c4e04f..4011c7bd 100644 --- a/mealie/services/image_services.py +++ b/mealie/services/image_services.py @@ -9,9 +9,12 @@ IMG_DIR = CWD.parent.joinpath("data", "img") def read_image(recipe_slug: str) -> FileResponse: - recipe_slug = recipe_slug.split(".")[0] - for file in IMG_DIR.glob(f"{recipe_slug}*"): - return file + if IMG_DIR.joinpath(recipe_slug).is_file(): + return IMG_DIR.joinpath(recipe_slug) + else: + recipe_slug = recipe_slug.split(".")[0] + for file in IMG_DIR.glob(f"{recipe_slug}*"): + return file def write_image(recipe_slug: str, file_data: bytes, extension: str) -> Path.name: