Repository: searxng/searxng

Issue:
Bug: ccengine engine
**Version of SearXNG, commit number if you are using on master branch and stipulate if you forked SearXNG**
Repository: https://github.com/searxng/searxng
Branch: master
Commit: https://github.com/searxng/searxng/commit/df52ee711b03c964779a32d0f1753e06281cdd8e

**How did you install SearXNG?**
https://docs.searxng.org/admin/installation.html

**What happened?**
The ccengine engine is not working, because api.creativecommons.engineering cannot be parsed.

**How To Reproduce**
- Install SearXNG
- Enable ccengine
- Search ``!cce test``

**Expected behavior**
The ccengine engine working normally.

**Additional context**
ccengine was merged with WordPress and renamed to Openverse (see https://wordpress.org/news/2021/05/welcome-to-openverse/)

I have made a few changes in my [ccengine-openverse](https://github.com/tiekoetter/searxng/tree/ccengine-openverse) branch to fix this.

You can test this by trying to search ``!opv test`` on a local instance running on this branch.

Should the ccengine engine be renamed to openverse or should it remain with its current name?

**Technical report**

Error
  * Error: 2 redirects, maximum: 0
  * Percentage: 100
  * Parameters: `('200', 'OK', 'api.openverse.engineering')`
  * File name: `searx/search/processors/online.py:105`
  * Function: `_send_http_request`
  * Code: `count_error(`

Error
  * Error: json.decoder.JSONDecodeError
  * Percentage: 100
  * Parameters: `('Expecting value',)`
  * File name: `searx/engines/ccengine.py:42`
  * Function: `response`
  * Code: `json_data = loads(resp.text)`

---

Related to https://github.com/searxng/searxng/issues/616


Discussion:
>Should the ccengine engine be renamed to openverse or should it remain with its current name?

Yes I think it should be renamed.

>I have made a few changes in my ccengine-openverse branch to fix this.

Looks good but:

> 1. Add Openverse engine 
> 2. Remove CC engine
> 3. Rename CC engine to Openverse 

This would be alright if the engine changed completely but the engine only changed slightly, in which case it's better to structure the commits like:

1. [fix] CC engine (URL changed) -- where you do the minimal work to fix the engine without renaming it
2. [fix] rename CC engine to Openverse -- where you do the all the work of renaming in one commit

This way the diff is more readable since you can see all the changes at once (instead of having one diff were everything is removed and one diff where everything is added). I hope that makes sense :)

>Add openverse.py to searx/engines

And btw you don't need to describe which files you changed in your commit message ... that is already apparent from the commit. Instead you should use commit messages to add auxiliary information (e.g. link their blog post in one of the commits).

Resolving patch:
diff --git a/searx/engines/ccengine.py b/searx/engines/openverse.py
similarity index 73%
rename from searx/engines/ccengine.py
rename to searx/engines/openverse.py
--- a/searx/engines/ccengine.py
+++ b/searx/engines/openverse.py
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: AGPL-3.0-or-later
 """
 
- Creative Commons search engine (Images)
+ Openverse (formerly known as: Creative Commons search engine) [Images]
 
 """
 
@@ -10,9 +10,9 @@
 
 
 about = {
-    "website": 'https://search.creativecommons.org/',
+    "website": 'https://wordpress.org/openverse/',
     "wikidata_id": None,
-    "official_api_documentation": 'https://api.creativecommons.engineering/v1/',
+    "official_api_documentation": 'https://api.openverse.engineering/v1/',
     "use_official_api": True,
     "require_api_key": False,
     "results": 'JSON',
@@ -23,8 +23,8 @@
 paging = True
 nb_per_page = 20
 
-base_url = 'https://api.creativecommons.engineering/v1/images?'
-search_string = '&page={page}&page_size={nb_per_page}&format=json&{query}'
+base_url = 'https://api.openverse.engineering/v1/images/'
+search_string = '?page={page}&page_size={nb_per_page}&format=json&{query}'
 
 
 def request(query, params):


Test patch: