regosen / get_cover_art

Batch cover art downloader and embedder for audio files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting 403 forbidden from itunes.apple.com, requesting too fast?

codeswhite opened this issue · comments

I just might implement proxy usage...

I get this too when running on a large collection.

Have you tried the --throttle option? It specifies the number of seconds to wait between each query (i.e. each album). It defaults to 0, but if you find a good number that works, I could update the default value.

Ok, I just pushed a new version (1.5.0) that will automatically sleep for 30 minutes and retry whenever it encounters a 403 or 429.

From what I'm reading, Apple enforces a limit per hour, but I'm not sure if it's on absolute hour intervals or relative to the first request, so 30 minutes should be a good duration for this. (It will sleep again if the retry hits another 403 or 429)

I found out that the 403 is returned from the server if I have mady more than X request in the last Y seconds.
It's enough to wait just few seconds after 403.

A good throttle value i found to be around 1-2 seconds, maybe a little more on faster computers.

Anyway I have forked your code, refactored it and rebranded it to my needs...
I've stripped local cover finding and prioritizing as I don't have those, only embedded.
Added multiple download sources besides Apple, image optimization (size minification) after download, about 20 command line options, integration with youtube_dl, multithreading and more..

I will probably publish it on my profile, maybe we can merge projects

Might be worth making the wait time configurable and lowering the default: seems you can re-request much quicker than 30 minutes when you get a 403 (10 seconds?).

Good call, I just reintroduced --throttle which will default to 3 but not kick in until a 403 or 429 are encountered.

@codeswhite good call on stripping out all the "local cover finding" options, that made the instructions really complicated and I'm not sure how useful they are. (They were introduced by another user, so I know one person used them at least.)