Stamp on last API bug (also present in previous wikimedia codebase): there is an (undocumented) maximum length to wikimedia API URLs which can be exceeded when we have a collection of very long (usually unicode) titles. This was causing hundreds of files to be missed. Here we make a guess as to the maximum URL length, given the urlencoded titles, and make sure we process the batch of files when the URL risks becoming too long.
Correct simple typo which was accidentally sending the encoding types as the user agent string.
Be polite to commons - give a sensible user-agent string (see https://meta.wikimedia.org/wiki/User-Agent_policy and https://en.wikipedia.org/wiki/User_agent#Format_for_automated_agents_.28bots.29)