deedy5 / duckduckgo_search

Search for words, documents, images, videos, news, maps and text translation using the DuckDuckGo.com search engine. Downloading files and images to a local hard drive.
MIT License
937 stars 117 forks source link

ddg_image() sometimes not creative file name #28

Closed RaSan147 closed 1 year ago

RaSan147 commented 1 year ago

Screenshot_2022-11-08-00-05-01-58_846b44643ec609f507828878741e1f9a

Suggestions: Check if filename provided by api, then content-disposition filename, as last resort check file-type for extension and use that with image.{ext} And finally just image.jpg (image viewer will detect)

deedy5 commented 1 year ago

This happens, but rather rarely, and in general does not greatly affect the result. Determining the type of file that does not have an extension is not an easy task. There are libraries for this, such as python-magic. But it makes sense to have as few dependencies as possible. I know that it is possible to determine the extension by checking the magic numbers signature, and maybe add this feature without using third party libraries later.