mealie-recipes / mealie

Mealie is a self hosted recipe manager and meal planner with a RestAPI backend and a reactive frontend application built in Vue for a pleasant user experience for the whole family. Easily add recipes into your database by providing the url and mealie will automatically import the relevant data or add a family recipe with the UI editor
https://docs.mealie.io
GNU Affero General Public License v3.0
5.61k stars 611 forks source link

[BUG] - Scraper and image URL getter can't identify .jpeg #3714

Open xtraorange opened 3 weeks ago

xtraorange commented 3 weeks ago

First Check

What is the issue you are experiencing?

When either using the scraper or using the get image by URL dialogue, Mealie is unable to identify a .jpeg. Produces a "Url is not an image" error when using the get image by URL dialogue. Interestingly, uploading from a computer works fine.

Steps to Reproduce

  1. Click Create.
  2. Click Import.
  3. Provide a URL that has a feature image with an extension of .jpeg. (example: https://emeals.com/recipes/recipe-47273-303002-Shrimp-and-Sausage-Jambalaya)
  4. Click Create.
  5. Note that no image is detected in the resulting recipe. (using the same website for pages that use an image with .jpg has no issues).

OR

  1. Edit an existing recipe
  2. Click Image.
  3. Provide the URL to an image with a .jpeg extension. (example: https://emeals-menubuilder.s3.amazonaws.com/v1/recipes/766433/pictures/large_shrimp-and-sausage-jambalaya.jpeg)
  4. Click Get.
  5. Note the error.

Please provide relevant logs

INFO 2024-06-07T13:41:45 - Image URL: https://emeals-menubuilder.s3.amazonaws.com/v1/recipes/766433/pictures/large_shrimp-and-sausage-jambalaya.jpeg INFO 2024-06-07T13:41:45 - HTTP Request: GET https://emeals-menubuilder.s3.amazonaws.com/v1/recipes/766433/pictures/large_shrimp-and-sausage-jambalaya.jpeg "HTTP/1.1 200 OK" ERROR 2024-06-07T13:41:46 - Content-Type: binary/octet-stream is not an image ERROR 2024-06-07T13:41:46 - Content-Type: binary/octet-stream is not an image

Mealie Version

v1.8.0 - 583bd742fb7bbeee0191a6e6601677df57d86a11

Deployment

Docker (Linux)

Additional Deployment Details

No response

boc-the-git commented 3 weeks ago

I can upload a .jpeg just fine. Created one in MS Paint and uploaded: https://demo.mealie.io/g/home/r/pannkakor

I expect there's something wrong with the images on that website. Here's the check it's failing: https://github.com/mealie-recipes/mealie/blob/f53cae7c7b099f4489ecc0391ef62927631d7a77/mealie/services/recipe/recipe_data_service.py#L154-L158

xtraorange commented 2 weeks ago

I can upload a .jpeg just fine. Created one in MS Paint and uploaded: https://demo.mealie.io/g/home/r/pannkakor

I expect there's something wrong with the images on that website. Here's the check it's failing:

https://github.com/mealie-recipes/mealie/blob/f53cae7c7b099f4489ecc0391ef62927631d7a77/mealie/services/recipe/recipe_data_service.py#L154-L158

I mentioned that uploading works fine, it's only scraping or attempting to use a URL of an image with a .jpeg.

It looks like the failure is because it thinks that's not an image, which could be because it doesn't recognize .jpeg as a valid image extension.

hay-kot commented 2 weeks ago

It's the Content-Type header returned from the S3 bucket that's causing the issue. We trust the Content Type to ensure that it's actually an image, we'd either have to try to parse the contents, or determine some other way to check if it's an image

CleanShot 2024-06-10 at 21 51 56@2x

xtraorange commented 2 weeks ago

I wonder why the .jpg images on the same site work then? How strange. Well, thanks for looking into it!