当前位置: 首页>>代码示例>>Python>>正文


Python Movie.from_tmdb方法代码示例

本文整理汇总了Python中models.Movie.from_tmdb方法的典型用法代码示例。如果您正苦于以下问题:Python Movie.from_tmdb方法的具体用法?Python Movie.from_tmdb怎么用?Python Movie.from_tmdb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Movie的用法示例。


在下文中一共展示了Movie.from_tmdb方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: insert_movie

# 需要导入模块: from models import Movie [as 别名]
# 或者: from models.Movie import from_tmdb [as 别名]
def insert_movie(the_movie):
    movie = Movie.from_tmdb(the_movie, True)
    db_session.add(movie)
    try:
        db_session.commit()
        return movie.movieid
    except:
        db_session.rollback()
        raise
开发者ID:pulmro,项目名称:moviecase,代码行数:11,代码来源:db_methods.py

示例2: update_database

# 需要导入模块: from models import Movie [as 别名]
# 或者: from models.Movie import from_tmdb [as 别名]
 def update_database(self):
     """Download again info from TMDB for the movies in the db."""
     tmdb_ID_list = [movie.tmdbID for movie in db_session.query(Movie).all() if movie.tmdbID > 0]
     for tmdb_ID in tmdb_ID_list:
         try:
             the_movie = tmdb3.Movie(tmdb_ID)
             movie = Movie.from_tmdb(the_movie, download_poster=False)
             db_methods.update_movie(tmdb_ID, movie)
         except tmdb3.tmdb_exceptions.TMDBHTTPError as e:
             logging.error("Movie not updated.")
             logging.error("HTTP error({0}): {1}".format(e.httperrno, e.response))
         except:
             logging.error("Unexpected error: %s", sys.exc_info()[0])
             raise
     try:
         db_session.commit()
     except:
         db_session.rollback()
         logging.error('Error updating movies in the database.')
         raise
开发者ID:pulmro,项目名称:moviecase,代码行数:22,代码来源:moviedb.py

示例3: insert_movie_file

# 需要导入模块: from models import Movie [as 别名]
# 或者: from models.Movie import from_tmdb [as 别名]
def insert_movie_file(the_movie, path, movie_name):
    """
    Checks if movie and file are already in the database and updates relationship, else it adds new ones.
    """
    try:
        movie = db_session.query(Movie).filter(Movie.tmdbID == the_movie.id).one()
    except NoResultFound:
        movie = Movie.from_tmdb(the_movie)
        db_session.add(movie)
        db_session.commit()
    try:
        file = db_session.query(File).filter(File.filepath == path).one()
    except NoResultFound:
        file = File(filepath=path, name=movie_name, movieid=movie.movieid)
        db_session.add(file)
    else:
        file.movieid = movie.movieid
    try:
        db_session.commit()
        return movie.movieid
    except:
        db_session.rollback()
    return None
开发者ID:pulmro,项目名称:moviecase,代码行数:25,代码来源:db_methods.py


注:本文中的models.Movie.from_tmdb方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。