本文整理汇总了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
示例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
示例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