Skip to content

Commit

Permalink
imghdr got removed in Python 3.13 after deprecation in 3.11
Browse files Browse the repository at this point in the history
third party library filetype is a recommended replacement

see https://docs.python.org/3/library/imghdr.html
  • Loading branch information
el-han committed Feb 17, 2025
1 parent 04cc431 commit 5d2f484
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cookbook/integration/recettetek.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import imghdr
import filetype
import json
import re
from io import BytesIO
Expand Down Expand Up @@ -128,7 +128,7 @@ def get_recipe_from_file(self, file):
url = file['originalPicture']
if validate_import_url(url):
response = requests.get(url)
if imghdr.what(BytesIO(response.content)) is not None:
if filetype.is_image(BytesIO(response.content)):
self.import_recipe_image(recipe, BytesIO(response.content), filetype=get_filetype(file['originalPicture']))
else:
raise Exception("Original image failed to download.")
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pytubefix==8.12.0
aiohttp==3.10.11
inflection==0.5.1
redis==5.2.1
filetype==1.2.0

# Development
pytest==8.0.0
Expand Down

0 comments on commit 5d2f484

Please sign in to comment.