prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Flickr engine is broken
  The html seems to have changed, but it's seems there is [REST API](https://api.flickr.com/services/rest?sort=relevance&parse_tags=1&content_type=7&extras=can_comment%2Ccount_comments%2Ccount_faves%2Cisfavorite%2Clicense%2Cmedia%2Cneeds_interstitial%2Cowner_name%2Cpath_alias%2Crealname%2Crotation%2Curl_c%2Curl_l%2Curl_m%2Curl_n%2Curl_q%2Curl_s%2Curl_sq%2Curl_t%2Curl_z&per_page=25&page=1&lang=en-US&rb=1&text=proxy&viewerNSID=&method=flickr.photos.search&csrf=&api_key=3e5918155f464baad83cce2efcf8b57e&format=json&hermes=1&hermesClient=1&reqId=rgb38n1&nojsoncallback=1)
  
  In all parameters there is an api_key : I don't know how long it is valid, in which condition.
  The call to this URL is trigger inside another minified javascript.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `searx/engines/flickr_noapi.py`
  Content:
  ```
  1 #!/usr/bin/env python
  2 
  3 """
  4   Flickr (Images)
  5 
  6  @website     https://www.flickr.com
  7  @provide-api yes (https://secure.flickr.com/services/api/flickr.photos.search.html)
  8 
  9  @using-api   no
  10  @results     HTML
  11  @stable      no
  12  @parse       url, title, thumbnail, img_src
  13 """
  14 
  15 from urllib import urlencode
  16 from json import loads
  17 import re
  18 from searx.engines import logger
  19 
  20 
  21 logger = logger.getChild('flickr-noapi')
  22 
  23 categories = ['images']
  24 
  25 url = 'https://www.flickr.com/'
  26 search_url = url + 'search?{query}&page={page}'
  27 photo_url = 'https://www.flickr.com/photos/{userid}/{photoid}'
  28 regex = re.compile(r"\"search-photos-models\",\"photos\":(.*}),\"totalItems\":", re.DOTALL)
  29 image_sizes = ('o', 'k', 'h', 'b', 'c', 'z', 'n', 'm', 't', 'q', 's')
  30 
  31 paging = True
  32 
  33 
  34 def build_flickr_url(user_id, photo_id):
  35     return photo_url.format(userid=user_id, photoid=photo_id)
  36 
  37 
  38 def request(query, params):
  39     params['url'] = search_url.format(query=urlencode({'text': query}),
  40                                       page=params['pageno'])
  41     return params
  42 
  43 
  44 def response(resp):
  45     results = []
  46 
  47     matches = regex.search(resp.text)
  48 
  49     if matches is None:
  50         return results
  51 
  52     match = matches.group(1)
  53     search_results = loads(match)
  54 
  55     if '_data' not in search_results:
  56         return []
  57 
  58     photos = search_results['_data']
  59 
  60     for photo in photos:
  61 
  62         # In paged configuration, the first pages' photos
  63         # are represented by a None object
  64         if photo is None:
  65             continue
  66 
  67         img_src = None
  68         # From the biggest to the lowest format
  69         for image_size in image_sizes:
  70             if image_size in photo['sizes']:
  71                 img_src = photo['sizes'][image_size]['url']
  72                 break
  73 
  74         if not img_src:
  75             logger.debug('cannot find valid image size: {0}'.format(repr(photo)))
  76             continue
  77 
  78         if 'id' not in photo['owner']:
  79             continue
  80 
  81 # For a bigger thumbnail, keep only the url_z, not the url_n
  82         if 'n' in photo['sizes']:
  83             thumbnail_src = photo['sizes']['n']['url']
  84         elif 'z' in photo['sizes']:
  85             thumbnail_src = photo['sizes']['z']['url']
  86         else:
  87             thumbnail_src = img_src
  88 
  89         url = build_flickr_url(photo['owner']['id'], photo['id'])
  90 
  91         title = photo.get('title', '')
  92 
  93         content = '<span class="photo-author">' +\
  94                   photo['owner']['username'] +\
  95                   '</span><br />'
  96 
  97         if 'description' in photo:
  98             content = content +\
  99                 '<span class="description">' +\
  100                 photo['description'] +\
  101                 '</span>'
  102 
  103         # append result
  104         results.append({'url': url,
  105                         'title': title,
  106                         'img_src': img_src,
  107                         'thumbnail_src': thumbnail_src,
  108                         'content': content,
  109                         'template': 'images.html'})
  110 
  111     return results
  112
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/searx/engines/flickr_noapi.py b/searx/engines/flickr_noapi.py
  --- a/searx/engines/flickr_noapi.py
  +++ b/searx/engines/flickr_noapi.py
  @@ -25,7 +25,7 @@
   url = 'https://www.flickr.com/'
   search_url = url + 'search?{query}&page={page}'
   photo_url = 'https://www.flickr.com/photos/{userid}/{photoid}'
  -regex = re.compile(r"\"search-photos-models\",\"photos\":(.*}),\"totalItems\":", re.DOTALL)
  +regex = re.compile(r"\"search-photos-lite-models\",\"photos\":(.*}),\"totalItems\":", re.DOTALL)
   image_sizes = ('o', 'k', 'h', 'b', 'c', 'z', 'n', 'm', 't', 'q', 's')
   
   paging = True
  @@ -38,6 +38,7 @@
   def request(query, params):
       params['url'] = search_url.format(query=urlencode({'text': query}),
                                         page=params['pageno'])
  +
       return params
   
   
  @@ -75,10 +76,10 @@
               logger.debug('cannot find valid image size: {0}'.format(repr(photo)))
               continue
   
  -        if 'id' not in photo['owner']:
  +        if 'ownerNsid' not in photo:
               continue
   
  -# For a bigger thumbnail, keep only the url_z, not the url_n
  +        # For a bigger thumbnail, keep only the url_z, not the url_n
           if 'n' in photo['sizes']:
               thumbnail_src = photo['sizes']['n']['url']
           elif 'z' in photo['sizes']:
  @@ -86,20 +87,14 @@
           else:
               thumbnail_src = img_src
   
  -        url = build_flickr_url(photo['owner']['id'], photo['id'])
  +        url = build_flickr_url(photo['ownerNsid'], photo['id'])
   
           title = photo.get('title', '')
   
           content = '<span class="photo-author">' +\
  -                  photo['owner']['username'] +\
  +                  photo['username'] +\
                     '</span><br />'
   
  -        if 'description' in photo:
  -            content = content +\
  -                '<span class="description">' +\
  -                photo['description'] +\
  -                '</span>'
  -
           # append result
           results.append({'url': url,
                           'title': title,
  
verification_info: {"golden_diff": "diff --git a/searx/engines/flickr_noapi.py b/searx/engines/flickr_noapi.py\n--- a/searx/engines/flickr_noapi.py\n+++ b/searx/engines/flickr_noapi.py\n@@ -25,7 +25,7 @@\n url = 'https://www.flickr.com/'\n search_url = url + 'search?{query}&page={page}'\n photo_url = 'https://www.flickr.com/photos/{userid}/{photoid}'\n-regex = re.compile(r\"\\\"search-photos-models\\\",\\\"photos\\\":(.*}),\\\"totalItems\\\":\", re.DOTALL)\n+regex = re.compile(r\"\\\"search-photos-lite-models\\\",\\\"photos\\\":(.*}),\\\"totalItems\\\":\", re.DOTALL)\n image_sizes = ('o', 'k', 'h', 'b', 'c', 'z', 'n', 'm', 't', 'q', 's')\n \n paging = True\n@@ -38,6 +38,7 @@\n def request(query, params):\n     params['url'] = search_url.format(query=urlencode({'text': query}),\n                                       page=params['pageno'])\n+\n     return params\n \n \n@@ -75,10 +76,10 @@\n             logger.debug('cannot find valid image size: {0}'.format(repr(photo)))\n             continue\n \n-        if 'id' not in photo['owner']:\n+        if 'ownerNsid' not in photo:\n             continue\n \n-# For a bigger thumbnail, keep only the url_z, not the url_n\n+        # For a bigger thumbnail, keep only the url_z, not the url_n\n         if 'n' in photo['sizes']:\n             thumbnail_src = photo['sizes']['n']['url']\n         elif 'z' in photo['sizes']:\n@@ -86,20 +87,14 @@\n         else:\n             thumbnail_src = img_src\n \n-        url = build_flickr_url(photo['owner']['id'], photo['id'])\n+        url = build_flickr_url(photo['ownerNsid'], photo['id'])\n \n         title = photo.get('title', '')\n \n         content = '<span class=\"photo-author\">' +\\\n-                  photo['owner']['username'] +\\\n+                  photo['username'] +\\\n                   '</span><br />'\n \n-        if 'description' in photo:\n-            content = content +\\\n-                '<span class=\"description\">' +\\\n-                photo['description'] +\\\n-                '</span>'\n-\n         # append result\n         results.append({'url': url,\n                         'title': title,\n", "issue": "Flickr engine is broken\nThe html seems to have changed, but it's seems there is [REST API](https://api.flickr.com/services/rest?sort=relevance&parse_tags=1&content_type=7&extras=can_comment%2Ccount_comments%2Ccount_faves%2Cisfavorite%2Clicense%2Cmedia%2Cneeds_interstitial%2Cowner_name%2Cpath_alias%2Crealname%2Crotation%2Curl_c%2Curl_l%2Curl_m%2Curl_n%2Curl_q%2Curl_s%2Curl_sq%2Curl_t%2Curl_z&per_page=25&page=1&lang=en-US&rb=1&text=proxy&viewerNSID=&method=flickr.photos.search&csrf=&api_key=3e5918155f464baad83cce2efcf8b57e&format=json&hermes=1&hermesClient=1&reqId=rgb38n1&nojsoncallback=1)\n\nIn all parameters there is an api_key : I don't know how long it is valid, in which condition.\nThe call to this URL is trigger inside another minified javascript.\n\n", "before_files": [{"content": "#!/usr/bin/env python\n\n\"\"\"\n  Flickr (Images)\n\n @website     https://www.flickr.com\n @provide-api yes (https://secure.flickr.com/services/api/flickr.photos.search.html)\n\n @using-api   no\n @results     HTML\n @stable      no\n @parse       url, title, thumbnail, img_src\n\"\"\"\n\nfrom urllib import urlencode\nfrom json import loads\nimport re\nfrom searx.engines import logger\n\n\nlogger = logger.getChild('flickr-noapi')\n\ncategories = ['images']\n\nurl = 'https://www.flickr.com/'\nsearch_url = url + 'search?{query}&page={page}'\nphoto_url = 'https://www.flickr.com/photos/{userid}/{photoid}'\nregex = re.compile(r\"\\\"search-photos-models\\\",\\\"photos\\\":(.*}),\\\"totalItems\\\":\", re.DOTALL)\nimage_sizes = ('o', 'k', 'h', 'b', 'c', 'z', 'n', 'm', 't', 'q', 's')\n\npaging = True\n\n\ndef build_flickr_url(user_id, photo_id):\n    return photo_url.format(userid=user_id, photoid=photo_id)\n\n\ndef request(query, params):\n    params['url'] = search_url.format(query=urlencode({'text': query}),\n                                      page=params['pageno'])\n    return params\n\n\ndef response(resp):\n    results = []\n\n    matches = regex.search(resp.text)\n\n    if matches is None:\n        return results\n\n    match = matches.group(1)\n    search_results = loads(match)\n\n    if '_data' not in search_results:\n        return []\n\n    photos = search_results['_data']\n\n    for photo in photos:\n\n        # In paged configuration, the first pages' photos\n        # are represented by a None object\n        if photo is None:\n            continue\n\n        img_src = None\n        # From the biggest to the lowest format\n        for image_size in image_sizes:\n            if image_size in photo['sizes']:\n                img_src = photo['sizes'][image_size]['url']\n                break\n\n        if not img_src:\n            logger.debug('cannot find valid image size: {0}'.format(repr(photo)))\n            continue\n\n        if 'id' not in photo['owner']:\n            continue\n\n# For a bigger thumbnail, keep only the url_z, not the url_n\n        if 'n' in photo['sizes']:\n            thumbnail_src = photo['sizes']['n']['url']\n        elif 'z' in photo['sizes']:\n            thumbnail_src = photo['sizes']['z']['url']\n        else:\n            thumbnail_src = img_src\n\n        url = build_flickr_url(photo['owner']['id'], photo['id'])\n\n        title = photo.get('title', '')\n\n        content = '<span class=\"photo-author\">' +\\\n                  photo['owner']['username'] +\\\n                  '</span><br />'\n\n        if 'description' in photo:\n            content = content +\\\n                '<span class=\"description\">' +\\\n                photo['description'] +\\\n                '</span>'\n\n        # append result\n        results.append({'url': url,\n                        'title': title,\n                        'img_src': img_src,\n                        'thumbnail_src': thumbnail_src,\n                        'content': content,\n                        'template': 'images.html'})\n\n    return results\n", "path": "searx/engines/flickr_noapi.py"}], "after_files": [{"content": "#!/usr/bin/env python\n\n\"\"\"\n  Flickr (Images)\n\n @website     https://www.flickr.com\n @provide-api yes (https://secure.flickr.com/services/api/flickr.photos.search.html)\n\n @using-api   no\n @results     HTML\n @stable      no\n @parse       url, title, thumbnail, img_src\n\"\"\"\n\nfrom urllib import urlencode\nfrom json import loads\nimport re\nfrom searx.engines import logger\n\n\nlogger = logger.getChild('flickr-noapi')\n\ncategories = ['images']\n\nurl = 'https://www.flickr.com/'\nsearch_url = url + 'search?{query}&page={page}'\nphoto_url = 'https://www.flickr.com/photos/{userid}/{photoid}'\nregex = re.compile(r\"\\\"search-photos-lite-models\\\",\\\"photos\\\":(.*}),\\\"totalItems\\\":\", re.DOTALL)\nimage_sizes = ('o', 'k', 'h', 'b', 'c', 'z', 'n', 'm', 't', 'q', 's')\n\npaging = True\n\n\ndef build_flickr_url(user_id, photo_id):\n    return photo_url.format(userid=user_id, photoid=photo_id)\n\n\ndef request(query, params):\n    params['url'] = search_url.format(query=urlencode({'text': query}),\n                                      page=params['pageno'])\n\n    return params\n\n\ndef response(resp):\n    results = []\n\n    matches = regex.search(resp.text)\n\n    if matches is None:\n        return results\n\n    match = matches.group(1)\n    search_results = loads(match)\n\n    if '_data' not in search_results:\n        return []\n\n    photos = search_results['_data']\n\n    for photo in photos:\n\n        # In paged configuration, the first pages' photos\n        # are represented by a None object\n        if photo is None:\n            continue\n\n        img_src = None\n        # From the biggest to the lowest format\n        for image_size in image_sizes:\n            if image_size in photo['sizes']:\n                img_src = photo['sizes'][image_size]['url']\n                break\n\n        if not img_src:\n            logger.debug('cannot find valid image size: {0}'.format(repr(photo)))\n            continue\n\n        if 'ownerNsid' not in photo:\n            continue\n\n        # For a bigger thumbnail, keep only the url_z, not the url_n\n        if 'n' in photo['sizes']:\n            thumbnail_src = photo['sizes']['n']['url']\n        elif 'z' in photo['sizes']:\n            thumbnail_src = photo['sizes']['z']['url']\n        else:\n            thumbnail_src = img_src\n\n        url = build_flickr_url(photo['ownerNsid'], photo['id'])\n\n        title = photo.get('title', '')\n\n        content = '<span class=\"photo-author\">' +\\\n                  photo['username'] +\\\n                  '</span><br />'\n\n        # append result\n        results.append({'url': url,\n                        'title': title,\n                        'img_src': img_src,\n                        'thumbnail_src': thumbnail_src,\n                        'content': content,\n                        'template': 'images.html'})\n\n    return results\n", "path": "searx/engines/flickr_noapi.py"}]}