def createProperMovieDictionary(raw_dict):
    """
    Takes the dictionary provided by the request (full of strings)
    and formats it where some variables need to have other types (e.g int, float)
    also escapes all the single quotes characters in strings

    :param raw_dict: the raw dictionary with the movie information provided by the api
    :return proper_dict: a dictionary with the proper types to input in the database
                         containing id, title, year, length, rating and the cast
                         (a dictionary of actors in movies)
    """

    try:
        year = int(raw_dict['year'])
    except ValueError:
        year = 0

    try:
        rating = float(raw_dict['rating'])
    except ValueError:
        rating = 0.0

    proper_dict = {
        'id': raw_dict['id'],
        'title': raw_dict['title'].replace(u'\xa0', u'').replace("'", "''"),
        'year': year,
        'length': raw_dict['length'],
        'rating': rating,
        'cast': raw_dict['cast']
    }

    for actor in proper_dict['cast']:
        actor['actor'] = actor['actor'].replace("'", "''")
        actor['character'] = actor['character'].replace("'", "''")

    return proper_dict