ifl0w / RandomWallpaperGnome3

Random Wallpapers for Gnome 3
MIT License
176 stars 41 forks source link

Change default User-Agent to `RandomWallpaperGnome3/3.0` #186

Closed Lucki closed 8 months ago

Lucki commented 8 months ago

While testing my various configured sources for the initial genericjson improvements again, I stumbled upon a source which doesn't work for the default Mozilla/5.0 User-Agent. The site is protected by Cloudflare and I assume that the User-Agent Mozilla/5.0 lets Cloudflare believe that JavaScript should be available and tries to test it with an anti bot challenge. Using a different string as the User-Agent goes around this test - I only tested this with RandomWallpaperGnome3/3.0.

Failing:
$ http "https://danbooru.donmai.us/posts.json?tags=rating:general" User-Agent:Mozilla/5.0

Working:
$ http "https://danbooru.donmai.us/posts.json?tags=rating:general" User-Agent:RandomWallpaperGnome3/3.0

As a first thought I added a simple input to the configuration which lets the user override the User-Agent if necessary and falls back to the default if not set.

Reference: https://github.com/ifl0w/RandomWallpaperGnome3/pull/174#discussion_r1355676741

ifl0w commented 8 months ago

Hmm, to be honest, I now think that it is probably a better idea to just use a custom user agent as you suggested in the first place. That would be a simpler change and would keep the same download logic for all adapters.

If it causes issues down the road we will probably have to find a proper solution that works for all adapters.

Lucki commented 8 months ago

Sure! Is RandomWallpaperGnome3/3.0 fine as the string? Want me to change this PR or do it yourself?

ifl0w commented 8 months ago

Thanks!