mirror of https://github.com/l3uddz/traktarr
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
770 B
19 lines
770 B
6 years ago
|
from misc.log import logger
|
||
|
import json
|
||
|
import requests
|
||
|
|
||
|
log = logger.get_logger(__name__)
|
||
|
def get_rating(apikey,imdbID):
|
||
|
log.debug("Requesting ratings from omdb for imdbID: %s",imdbID)
|
||
|
r = requests.get('http://www.omdbapi.com/?i=' + imdbID + '&apikey=' + apikey)
|
||
|
if(r.status_code == 200):
|
||
|
log.debug("Successfully requested ratings from OMDB")
|
||
|
for source in json.loads(r.text)["Ratings"]:
|
||
|
if(source['Source'] == 'Rotten Tomatoes'):
|
||
|
log.debug("Rotten Tomatoes shows rating: %s for imdbID: %s",source['Value'],imdbID)
|
||
|
return int(source['Value'].split('%')[0])
|
||
|
else:
|
||
|
log.error("ERROR encountered while requesting rating for imdbID: %s Status Code: %d",imdbID,r.status_code)
|
||
|
|
||
|
return -1
|