Skip to content

Commit

Permalink
display code if error
Browse files Browse the repository at this point in the history
  • Loading branch information
BlaxPanther committed Jul 30, 2022
1 parent 9f2c578 commit 9ac9fba
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions imdb-api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,23 +397,23 @@ def getDetails(self, imdb_id, details = None, source = None):
if source is None:
source = IMDb.getPage(IMDb.getURL(imdb_id))
if source != "":
# try:
details1 = source.find("script",type="application/ld+json")
details1 = re.sub(r'<.*?{', '{',str(details1) )
details1 = re.sub(r'</.*','',details1)
details1 = IMDb.delDoubleQuotes(details1)
details_json1 = json.loads(details1)
details2 = source.find("script",type="application/json")
details2 = re.sub(r'<.*?{', '{',str(details2) )
details2 = re.sub(r'</.*','',details2)
details_json2 = json.loads(details2)
details_json = {}
details_json.update(details_json1)
details_json.update(details_json2)
return details_json
# except:
# print("An error occured. Please report this issue (error_code=2) or wait for the next update.")
# return ""
try:
details1 = source.find("script",type="application/ld+json")
details1 = re.sub(r'<.*?{', '{',str(details1) )
details1 = re.sub(r'</.*','',details1)
details1 = IMDb.delDoubleQuotes(details1)
details_json1 = json.loads(details1)
details2 = source.find("script",type="application/json")
details2 = re.sub(r'<.*?{', '{',str(details2) )
details2 = re.sub(r'</.*','',details2)
details_json2 = json.loads(details2)
details_json = {}
details_json.update(details_json1)
details_json.update(details_json2)
return details_json
except:
print("An error occured. Please report this issue (error_code=2) or wait for the next update.")
return ""
else:
return ""

Expand Down Expand Up @@ -454,6 +454,4 @@ def getPage(url):
except:
print("A network error occured. Please, check your internet connection.")
return ""



0 comments on commit 9ac9fba

Please sign in to comment.