Browse Source

[Search] Fix metmuseum search

master
octogene 3 years ago
parent
commit
3cb803a16e
4 changed files with 20 additions and 8 deletions
  1. +14
    -3
      hadaly/app.py
  2. +3
    -2
      hadaly/data/search_engines.json
  3. +1
    -1
      hadaly/editor.kv
  4. +2
    -2
      hadaly/viewer.py

+ 14
- 3
hadaly/app.py View File

@ -422,9 +422,20 @@ class HadalyApp(App):
def search_term(self, term, engine, page):
params = urllib.parse.urlencode({self.engines[engine]['params']['term']: term,
self.engines[engine]['params']['rpp']: self.config.get('search', 'search_rpp'),
self.engines[engine]['params']['page']: page})
if engine == "www.metmuseum.org":
offset = (page - 1) * int(self.config.get('search', 'search_rpp'))
params = urllib.parse.urlencode(
{self.engines[engine]['params']['term']: term,
self.engines[engine]['params']['rpp']: self.config.get(
'search', 'search_rpp'),
self.engines[engine]['params']['offset']: offset})
else:
params = urllib.parse.urlencode(
{self.engines[engine]['params']['term']: term,
self.engines[engine]['params']['rpp']: self.config.get(
'search', 'search_rpp'),
self.engines[engine]['params']['page']: page})
url = ''.join((self.engines[engine]['base_url'], params))


+ 3
- 2
hadaly/data/search_engines.json View File

@ -1,6 +1,6 @@
{
"www.metmuseum.org": {
"base_url": "http://www.metmuseum.org/api/collection/collectionlisting?showOnly=withImage&",
"base_url": "https://www.metmuseum.org/api/collection/collectionlisting?showOnly=withImage&",
"params": {
"rpp": "perPage",
"artist": "artist",
@ -13,7 +13,8 @@
"order": "sortOrder",
"orderings": {
"asc": "asc"
}
},
"offset": "offset"
},
"results": {
"format": "json",


+ 1
- 1
hadaly/editor.kv View File

@ -93,7 +93,7 @@
Rectangle:
pos: self.pos
size: self.size
Image:
AsyncImage:
id: _image
source: root.thumb_src
keep_ratio: True


+ 2
- 2
hadaly/viewer.py View File

@ -3,7 +3,7 @@
from kivy.uix.screenmanager import Screen
from kivy.uix.scatter import Matrix
from kivy.uix.scatterlayout import ScatterLayout
from kivy.uix.image import Image
from kivy.uix.image import Image, AsyncImage
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.stencilview import StencilView
from kivy.uix.popup import Popup
@ -174,7 +174,7 @@ class SlideViewer(ScatterLayout):
if all(child.id != 'img_zoom' for child in self.parent.children):
# TODO: Change thumbnail position and size based on config.
thumb = Image(source=self.image.source,
thumb = AsyncImage(source=self.image.source,
id='img_zoom',
size_hint=(None, None),
keep_ratio=True,


Loading…
Cancel
Save