Browse Source

Merge pull request #1810 from return42/fix-1809

[fix] springer: unsupported operand type(s) for +: 'NoneType' and 'str'
Alexandre Flament 2 years ago
parent
commit
0e00af9c26
1 changed files with 12 additions and 9 deletions
  1. 12 9
      searx/engines/springer.py

+ 12 - 9
searx/engines/springer.py

@@ -41,7 +41,6 @@ def response(resp):
     json_data = loads(resp.text)
 
     for record in json_data['records']:
-        content = record['abstract']
         published = datetime.strptime(record['publicationDate'], '%Y-%m-%d')
         authors = [" ".join(author['creator'].split(', ')[::-1]) for author in record['creators']]
         tags = record.get('genre')
@@ -50,20 +49,24 @@ def response(resp):
         results.append(
             {
                 'template': 'paper.html',
-                'title': record['title'],
                 'url': record['url'][0]['value'].replace('http://', 'https://', 1),
-                'type': record.get('contentType'),
-                'content': content,
+                'title': record['title'],
+                'content': record['abstract'],
+                'comments': record['publicationName'],
+                'tags': tags,
                 'publishedDate': published,
+                'type': record.get('contentType'),
                 'authors': authors,
-                'doi': record.get('doi'),
+                # 'editor': '',
+                'publisher': record.get('publisher'),
                 'journal': record.get('publicationName'),
-                'pages': record.get('start_page') + '-' + record.get('end_page'),
-                'tags': tags,
-                'issn': [record.get('issn')],
-                'isbn': [record.get('isbn')],
                 'volume': record.get('volume') or None,
+                'pages': '-'.join([x for x in [record.get('startingPage'), record.get('endingPage')] if x]),
                 'number': record.get('number') or None,
+                'doi': record.get('doi'),
+                'issn': [x for x in [record.get('issn')] if x],
+                'isbn': [x for x in [record.get('isbn')] if x],
+                # 'pdf_url' : ''
             }
         )
     return results