regosen / get_cover_art

Batch cover art downloader and embedder for audio files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HTTP 403 Forbidden

dmumford opened this issue · comments

When trying to download and embed album art for a directory with many files, the script fails to retrieve artwork from itunes (HTTP 403 Forbidden).

I assume itunes doesn't allow a lot of requests in a short amount of time from the same client.

I suggest that you add a list of album art providers, and try requesting album art from them when itunes fails.

Does this happen to all your files, or does it start to happen after hundreds/thousands of successful queries?

I'm wondering if you can try the following:

https://itunes.apple.com/search?term=Chumbawumba&media=music&entity=album

and see if the file it downloads contains the 403 error (as opposed to a bunch of text starting with "resultCount":2")

As for your suggestion, feel free to open an issue suggesting a particular provider. This tool is built to be extended to multiple providers, but it only has one for iTunes so far.

Ok, sounds like you're right- iTunes may be blocking repeated requests within a specified window of time.

I don't foresee an additional provider being supported anytime soon, so I would suggest two options:

A. The script should be skipping iTunes for art you already successfully embedded (unless you're using the --force option), so you could just keep running it until it gets all the way through your library.

B. I could add support for a "throttle" option to this script, such that adding "--throttle=2" would make it wait 2 seconds between queries. You might need to fiddle with that number if your requests still get blocked.

Ok, I just updated this script. If you try the latest version (1.3.11 in pip), you should be able to add --throttle=2 to the options.

Let me know if this helps! (As stated before, you might need to fiddle with that number if your requests still get blocked.)

I just found this, after (I believe) Apple removed all/most of the album art from inside my media files, and was so excited to try it to get the artwork back. It began running, and sending output to the console window, and after maybe a minute it started reporting those 403 errors. :-( Super bummed. Someone here, 4 years ago, heard from Apple that the limit was 20/minute, so I'm going to have to use a 3 second throttle, I guess. Very painful for a 14,000+ track library.

Also unclear how long the (hopefully temporary) "ban" lasts. Been a few minutes, but still giving me that status. Sigh...

After a few hours, I tried this again with a throttle of 3, and left it overnight and it finished, apparently without error, though it's hard to know for sure. Anyway, thank you @regosen for making this available.