hsmusic / bc-art

Bandcamp art downloader CLI
2 stars 0 forks source link

MIME-based extension guessing #2

Closed towerofnix closed 9 months ago

towerofnix commented 9 months ago

This fork is a few commits behind @GiovanH's upstream repo. Even if we don't intend on merging into there, we should take a look at the upstream changes and try bringing what's relevant over.

Turns out that's mostly just MIME-based extension guessing! This could speed up dry runs by not downloading the whole dang image! We don't need the huge _data.py file's mime2ext dict, as far as I'm aware Bandcamp only serves png and jpeg images (under _0). Maaaybe gifs too.

towerofnix commented 9 months ago

I'm not sure this is actually better than parsing the first some-odd bytes in memory, which we're doing now (5c6083d). It's still a bit slower than just reading the headers (the first chunk off Bandcamp appears to be 128 bytes), but it seems plausibly more reliable than reading MIME, which trusts Bandcamp to cooperate instead of analyzing the contents ourselves.