Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…
Cannot retrieve contributors at this time
executable file 70 lines (51 sloc) 2.31 KB
import urllib2
import rovi_auth
import call_twilio
import json
import simplejson
def get_relatedMovies(search,contact):
contact = contact
sig = rovi_auth.sign()
#Accessing Rovi's Metadata and Search API
url ='' % (search,sig)
rovi_json = urllib2.urlopen(url).read()
# convert to a native python object
(true,false,null) = (True,False,None)
#Parsing the json payload
rovi_data = eval(rovi_json)
#Retrieving movie from the payload
movie = rovi_data ['related']['isRelatedTo']
related_movies =''
movie_review =''
for i, m in enumerate(movie):
movie_title_original = m ['title']
movie_title = (movie_title_original.replace(" ", "+")).replace(':','')
release_year = m ['releaseYear']
#Getting movie_id from Rotten Tomatoes for each movie returned by Rovi's related API. This code must run multiple times in a loop.
rotten_get_movie_id_url ='' % (movie_title)
rotten_json = urllib2.urlopen(rotten_get_movie_id_url).read()
(true,false,null) = (True,False,None)
rotten_data = eval(rotten_json)
movie_id = rotten_data ['movies'][i]['id']
#Getting movie reviews from Rotten Tomatoes for each movie_id returned by Rotten Tomatoes' movies API. This code must run multiple times in a loop.
rotten_get_movie_review_url ='' % (movie_id)
reviews_json = urllib2.urlopen(rotten_get_movie_review_url).read()
reviews_data = simplejson.loads(reviews_json)
movie_review = reviews_data ['reviews'][i]['links']['review']
except IndexError:
# print 'Review Not available'
print ' '
except simplejson.decoder.JSONDecodeError:
# print 'Review Not available'
print ' '
related_movies = related_movies + str(i+1) + '. ' + movie_title_original + ' \r'
except urllib2.URLError, e:
print e
except KeyError, e:
print e
print "Message Sent \r"
print related_movies
Jump to Line
Something went wrong with that request. Please try again.