Exemple #1
0
def moviedata():
    imdb = Imdb()
    pop_items = imdb.get_popular_movies()
    dict = pop_items['ranks']
    d = []
    r = []
    moviedetails = []
    n_list = []
    for i in range(0, 12):
        tempdict = {}
        movie_id = dict[i]['id']
        ls = movie_id.split('/')
        rating = imdb.get_title_ratings(ls[2])
        url = dict[i]['image']['url']
        tempdict[ls[2]] = dict[i]['title']
        d.append(url)
        d.append(tempdict)
        t = str(dict[i]['year'])
        d.append(dict[i]['title'] + ("(" + t + ")"))

        # r.append("(" + t + ")")

        # rg=int(rating['rating']) / 2

        try:
            rg = rating['rating'] / 2
            d.append(rg)
        # print(rating['rating'])
        except:
            d.append(0)

        n_list.append(d)
        # print(r)
        # moviedetails.append(r)
        d = []
        # r = []
    #print(n_list)
    return (n_list)
Exemple #2
0
def get_title_ratings(imdb_id):
    global imdb
    if imdb is None:
        imdb=Imdb()

    return imdb.get_title_ratings(imdb_id)
Exemple #3
0
    # need to find the value of the 3rd item in each of the dictionaries in the list

print(movienumbers)
# Save data to a file (will be part of your data fetching script)

with open('movienumbers.pickle','wb') as f:
    pickle.dump(movienumbers,f)

print('movienumbers has been saved.')

# create a dictionary of scores, a list or dictionary that
# includes viewers' review and one for metacritic (the professionals)
ratings = {}

for title in movienumbers:
    rat = imdb.get_title_ratings(title)
    # skip movies that don't have ratings
    if 'rating' in rat:
        ratings[title] = rat['rating']

print(ratings)

with open('ratings.pickle','wb') as f:
    pickle.dump(ratings,f)

print('ratings has been saved.')

# create a dictionary that has a list of reviews for each of the titles that have reviews.

userratings = {}