示例#1
0
def update_imdb(media_info=None, release_key=None):
    session = Session()
    try:
        if media_info.imdb_id:
            movie_info = imdb.get_movie(media_info.imdb_id)
            if movie_info:
                media_info.imdb_score = movie_info['rating']
                media_info.imdb_votes = movie_info['votes']
                media_info.cover_url = movie_info['cover_url']
                for director in movie_info.get('director', []):
                    person = get_person_imdb(session, director['person_id'], name=director['name'])
                    if not person in media_info.directors:
                        media_info.directors.append(person)
                for cast_member in movie_info.get('cast', []):
                    person = get_person_imdb(session,
                                             cast_member['person']['person_id'],
                                             name=cast_member['person']['name'])
                    if not person in media_info.cast:
                        media_info.cast.append(person)
        session.commit()
    except DBAPIError:
        session.rollback()
    except exceptions.ApiError as e:
        log.warn(e.message)
    return media_info
示例#2
0
def update_imdb(media_info=None, release_key=None):
    session = Session()
    try:
        if media_info.imdb_id:
            movie_info = imdb.get_movie(media_info.imdb_id)
            if movie_info:
                media_info.imdb_score = movie_info['rating']
                media_info.imdb_votes = movie_info['votes']
                media_info.cover_url = movie_info['cover_url']
                for director in movie_info.get('director', []):
                    person = get_person_imdb(session, director['person_id'], name=director['name'])
                    if not person in media_info.directors:
                        media_info.directors.append(person)
                for cast_member in movie_info.get('cast', []):
                    person = get_person_imdb(session,
                                             cast_member['person']['person_id'],
                                             name=cast_member['person']['name'])
                    if person not in media_info.cast:
                        media_info.cast.append(person)
        session.commit()
    except DBAPIError:
        session.rollback()
    except exceptions.ApiError as e:
        log.warn(e.message)
    return media_info
示例#3
0
 def test_get_movie(self):
     show = imdb.get_movie("tt1844624")
     print(dir(show))
     show2 = imdb.get_movie("American Horror Story")
     self.assertEqual(show['imdb_id'], show2['imdb_id'])