Add Baidu Images as an image source
Bug #1349741 reported by
Peter Levi
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Variety |
New
|
Wishlist
|
Unassigned |
Bug Description
I received a patch to add Baidu as an image source. Patch works fairly well, but needs some more work and discussion before it can be included. We'll carry on the discussion here.
Changed in variety: | |
importance: | Undecided → Wishlist |
To post a comment you must log in.
Several comments and questions about the patch:
1. The first and most important thing is - does Baidu's policy permit this type of usage?
I see that this is a call to some json API, so I suppose it should be OK to use it, but have they described their policy somewhere, are there any requirements, API call limits or restrictions we need to adhere to?
The site is in Chinese, so I am somewhat lost there.
2. This is currently a hardcoded search that returns "totalNum": 117 images.
This is way too few for an image source that cannot be removed - these are supposed to be practically "unlimited", for example the Desktoppr Random source has a much bigger "pool" to draw images from.
I see some tags in Chinese there. What do they mean? Can we relax them to match more images?
3. Also, the resolution is hardcoded to 1920x1080 - does the API support asking for images "bigger than" rather than "having exactly this resolution"? Is there a page documenting this API, where did you read from while developing?
Resolution filtering usually takes into account the user's settings for "Color and size". To see how this is done, see the calls to self.parent. size_ok( ) in the other downloaders - basically we ask for images with any resolution, and filter out those that are too small, or are not landscape, etc.
4. Ideally, if there are really enough wallpaper-quality pictures on Baidu, we should be able to provide an image source with configurable search terms, like the Flickr source for example and set up just a couple of default well-configured searches. This will require a GUI for entering the search criteria, I can give you instructions how this is done.
Or, if it is going to stay a non-configurable image source, it should have at least several thousand images in it.
5. Do not make a new API call for getting just one image. Ask for more links at once (e.g. "rn=100") and keep them in a queue in memory. Otherwise we're storming the server with too many unneeded requests. See the fill_queue approach in the other downloaders, e.g. WallpapersNetDo wnloader.
Again - thanks a lot for the effort, I believe with some more work on it, Baidu can be a valuable image source for Variety - the quality of the images returned by the current API call is pretty high.