.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.engines.imdb Namespace Reference

Functions

 request (query, params)
 
 response (resp)
 

Variables

dict about
 
list categories = ["movies"]
 
bool paging = False
 
str suggestion_url = "https://v2.sg.media-imdb.com/suggestion/{letter}/{query}.json"
 
str href_base = 'https://imdb.com/{category}/{entry_id}'
 
dict search_categories = {"nm": "name", "tt": "title", "kw": "keyword", "co": "company", "ep": "episode"}
 

Detailed Description

IMDB - Internet Movie Database

Retrieves results from a basic search.  Advanced search options are not
supported.  IMDB's API is undocumented, here are some posts about:

- https://stackoverflow.com/questions/1966503/does-imdb-provide-an-api
- https://rapidapi.com/blog/how-to-use-imdb-api/

An alternative that needs IMDPro_ is `IMDb and Box Office Mojo
<https://developer.imdb.com/documentation>`_

.. __IMDPro: https://pro.imdb.com/login

Function Documentation

◆ request()

searx.engines.imdb.request ( query,
params )

Definition at line 39 of file imdb.py.

39def request(query, params):
40
41 query = query.replace(" ", "_").lower()
42 params['url'] = suggestion_url.format(letter=query[0], query=query)
43
44 return params
45
46

◆ response()

searx.engines.imdb.response ( resp)

Definition at line 47 of file imdb.py.

47def response(resp):
48
49 suggestions = json.loads(resp.text)
50 results = []
51
52 for entry in suggestions.get('d', []):
53
54 # https://developer.imdb.com/documentation/key-concepts#imdb-ids
55 entry_id = entry['id']
56 categ = search_categories.get(entry_id[:2])
57 if categ is None:
58 logger.error('skip unknown category tag %s in %s', entry_id[:2], entry_id)
59 continue
60
61 title = entry['l']
62 if 'q' in entry:
63 title += " (%s)" % entry['q']
64
65 content = ''
66 if 'rank' in entry:
67 content += "(%s) " % entry['rank']
68 if 'y' in entry:
69 content += str(entry['y']) + " - "
70 if 's' in entry:
71 content += entry['s']
72
73 # imageUrl is the image itself, it is not a thumb!
74 image_url = entry.get('i', {}).get('imageUrl')
75 if image_url:
76 # get thumbnail
77 image_url_name, image_url_prefix = image_url.rsplit('.', 1)
78 # recipe to get the magic value:
79 # * search on imdb.com, look at the URL of the thumbnail on the right side of the screen
80 # * search using the imdb engine, compare the imageUrl and thumbnail URL
81 # QL75 : JPEG quality (?)
82 # UX280 : resize to width 320
83 # 280,414 : size of the image (add white border)
84 magic = 'QL75_UX280_CR0,0,280,414_'
85 if not image_url_name.endswith('_V1_'):
86 magic = '_V1_' + magic
87 image_url = image_url_name + magic + '.' + image_url_prefix
88 results.append(
89 {
90 "title": title,
91 "url": href_base.format(category=categ, entry_id=entry_id),
92 "content": content,
93 "thumbnail": image_url,
94 }
95 )
96
97 return results

Variable Documentation

◆ about

dict searx.engines.imdb.about
Initial value:
1= {
2 "website": 'https://imdb.com/',
3 "wikidata_id": 'Q37312',
4 "official_api_documentation": None,
5 "use_official_api": False,
6 "require_api_key": False,
7 "results": 'HTML',
8}

Definition at line 19 of file imdb.py.

◆ categories

list searx.engines.imdb.categories = ["movies"]

Definition at line 28 of file imdb.py.

◆ href_base

str searx.engines.imdb.href_base = 'https://imdb.com/{category}/{entry_id}'

Definition at line 34 of file imdb.py.

◆ paging

bool searx.engines.imdb.paging = False

Definition at line 29 of file imdb.py.

◆ search_categories

dict searx.engines.imdb.search_categories = {"nm": "name", "tt": "title", "kw": "keyword", "co": "company", "ep": "episode"}

Definition at line 36 of file imdb.py.

◆ suggestion_url

str searx.engines.imdb.suggestion_url = "https://v2.sg.media-imdb.com/suggestion/{letter}/{query}.json"

Definition at line 32 of file imdb.py.