2 Commits

Author SHA1 Message Date
Bnyro
8baefcc21e [fix] pinterest: crash when there's no link & show image resolution + uploader name (#5314)
closes #5231
2025-10-13 07:43:36 +02:00
Markus Heiser
fc7d8b8be2 [fix] !weather crashes - cls.TURN 'member_descriptor' isn't a float (#5309)
The class method ``Compass.point`` is converted into an instance method to
circumvent the problem described in [1] (without understanding the cause).

[1] https://github.com/searxng/searxng/issues/5304#issuecomment-3394140820

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2025-10-13 07:37:42 +02:00
2 changed files with 10 additions and 8 deletions

View File

@@ -55,15 +55,18 @@ def response(resp):
if result['type'] == 'story':
continue
main_image = result['images']['orig']
results.append(
{
'template': 'images.html',
'url': result['link'] or f"{base_url}/pin/{result['id']}/",
'url': result.get('link') or f"{base_url}/pin/{result['id']}/",
'title': result.get('title') or result.get('grid_title'),
'content': (result.get('rich_summary') or {}).get('display_description') or "",
'img_src': result['images']['orig']['url'],
'img_src': main_image['url'],
'thumbnail_src': result['images']['236x']['url'],
'source': (result.get('rich_summary') or {}).get('site_name'),
'resolution': f"{main_image['width']}x{main_image['height']}",
'author': f"{result['pinner'].get('full_name')} ({result['pinner']['username']})",
}
)

View File

@@ -506,15 +506,14 @@ class Compass(msgspec.Struct):
return self.val
raise ValueError(f"unknown unit: {unit}")
@classmethod
def point(cls, azimuth: float | int) -> CompassPoint:
def point(self, azimuth: float | int) -> CompassPoint:
"""Returns the compass point to an azimuth value."""
azimuth = azimuth % cls.TURN
azimuth = azimuth % self.TURN
# The angle sector of a compass point starts 1/2 sector range before
# and after compass point (example: "N" goes from -11.25° to +11.25°)
azimuth = azimuth - cls.RANGE / 2
idx = int(azimuth // cls.RANGE)
return cls.POINTS[idx]
azimuth = azimuth - self.RANGE / 2
idx = int(azimuth // self.RANGE)
return self.POINTS[idx]
def l10n(
self,