File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -781,32 +781,12 @@ def get_item_list(item_name: str,
781781 :param instance_id: Instance ID
782782 :return: Set of items
783783 """
784- pywikibot .debug (f'Search label: { item_name .encode ("utf-8" )} ' )
785- # TODO: try to use search_entities instead?
786- params = {
787- 'action' : 'wbsearchentities' ,
788- 'format' : 'json' ,
789- 'type' : 'item' ,
790- # All languages are searched, but labels are in native language
791- 'strictlanguage' : False ,
792- 'language' : mainlang ,
793- 'uselang' : mainlang , # (primary) Search language
794- 'search' : item_name , # Get item list from label
795- 'limit' : 20 , # Should be reasonable value
796- }
797- request = api .Request (site = repo , parameters = params )
798- result = request .submit ()
799- pywikibot .debug (result )
800-
801- if 'search' not in result :
802- return set ()
803-
804784 # Ignore accents and case
805785 item_name_canon = unidecode (item_name ).casefold ()
806786
807787 item_list = set ()
808- # Loop though items
809- for res in result [ 'search' ] :
788+ # Loop though items, total should be reasonable value
789+ for res in repo . search_entities ( item_name , mainlang , total = 20 ) :
810790 item = get_item_page (res ['id' ])
811791
812792 # Matching instance
You can’t perform that action at this time.
0 commit comments