Skip to content

Commit

Permalink
[downloader:http] add MIME type and signature for .ico files
Browse files Browse the repository at this point in the history
(closes #1211)
  • Loading branch information
mikf committed Jan 1, 2021
1 parent b0beed7 commit 0594821
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions gallery_dl/downloader/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,10 @@ def _adjust_extension(pathfmt, file_header):
"image/x-ms-bmp": "bmp",
"image/webp" : "webp",
"image/svg+xml" : "svg",

"image/ico" : "ico",
"image/icon" : "ico",
"image/x-icon" : "ico",
"image/vnd.microsoft.icon" : "ico",
"image/x-photoshop" : "psd",
"application/x-photoshop" : "psd",
"image/vnd.adobe.photoshop": "psd",
Expand Down Expand Up @@ -314,14 +317,16 @@ def _adjust_extension(pathfmt, file_header):
"application/octet-stream": "bin",
}

# taken from https://en.wikipedia.org/wiki/List_of_file_signatures
# https://en.wikipedia.org/wiki/List_of_file_signatures
FILE_SIGNATURES = {
"jpg" : b"\xFF\xD8\xFF",
"png" : b"\x89PNG\r\n\x1A\n",
"gif" : (b"GIF87a", b"GIF89a"),
"bmp" : b"BM",
"webp": b"RIFF",
"svg" : b"<?xml",
"ico" : b"\x00\x00\x01\x00",
"cur" : b"\x00\x00\x02\x00",
"psd" : b"8BPS",
"webm": b"\x1A\x45\xDF\xA3",
"ogg" : b"OggS",
Expand All @@ -333,8 +338,7 @@ def _adjust_extension(pathfmt, file_header):
"pdf" : b"%PDF-",
"swf" : (b"CWS", b"FWS"),
# check 'bin' files against all other file signatures
"bin" : b"\x00\x00\x00\x00",
"bin" : b"\x00\x00\x00\x00\x00\x00\x00\x00",
}


__downloader__ = HttpDownloader

0 comments on commit 0594821

Please sign in to comment.