Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
logs/
.vscode/
*.pyc
__pycache__/
18 changes: 14 additions & 4 deletions PyMovieDb/imdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,23 @@ class IMDB:
#8. popular_tv(genre=None, start_id=1, sort_by=None)
-- to get IMDB popular Tv-Series
"""
def __init__(self):
def __init__(self, lang=None):
self.session = HTMLSession()
self.headers = {
self.lang = lang
if self.lang:
self.headers = {
"Accept": "application/json, text/plain, */*",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36",
"Referer": "https://www.imdb.com/"
"Referer": "https://www.imdb.com/",
"Accept-Language": lang
}
else:
self.headers = {
"Accept": "application/json, text/plain, */*",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36",
"Referer": "https://www.imdb.com/"
}

self.baseURL = "https://www.imdb.com"
self.search_results = {'result_count': 0, 'results': []}
self.NA = json.dumps({"status": 404, "message": "No Result Found!", 'result_count': 0, 'results': []})
Expand Down Expand Up @@ -142,10 +152,10 @@ def get(self, url):
except json.decoder.JSONDecodeError as e:
# invalid char(s) is/are not in description/trailer/reviewBody schema
return self.NA

output = {
"type": result.get('@type'),
"name": result.get('name'),
"alternateName": result.get('alternateName'),
"url": self.baseURL + result.get('url'),
"poster": result.get('image'),
"description": result.get('description'),
Expand Down