本文整理汇总了Python中models.Movie.source方法的典型用法代码示例。如果您正苦于以下问题:Python Movie.source方法的具体用法?Python Movie.source怎么用?Python Movie.source使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Movie
的用法示例。
在下文中一共展示了Movie.source方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fetchDetailsTheMovieDB
# 需要导入模块: from models import Movie [as 别名]
# 或者: from models.Movie import source [as 别名]
def fetchDetailsTheMovieDB(identifiers):
movie=Movie()
movie.sourceID=identifiers.sourceID
movie.source=identifiers.source
url=theMovieDBUrl + '/movie/' + str(identifiers.sourceID) + '?api_key=' + movieDBKey
data=safeRequestJSON(url)
reviewsUrl=theMovieDBUrl + '/movie/' + str(identifiers.sourceID) + '/reviews?api_key=' + movieDBKey
try:
movie.year = data['release_date'][:4]
except:
movie.year =''
try:
movie.title = data['title']
except:
movie.title =''
try:
movie.numReviews=safeRequestJSON(reviewsUrl)['total_results']
except:
movie.numReviews=0
try:
movie.description=data['overview'] if data['overview'] else ''
except:
movie.description=''
actorsUrl=theMovieDBUrl + '/movie/' + str(identifiers.sourceID) + '/credits?api_key=' + movieDBKey
try:
actors=safeRequestJSON(actorsUrl)['cast']
movie.actors=''
for actor in actors[:numOfStarringActorsDB]:
if actor !=actors[numOfStarringActorsDB-1]:
movie.actors+=actor['name'] + actorsDelimiter
else:
movie.actors+=actor['name']
except:
movie.actors=''
return movie
示例2: fetchDetailsRottenTomatoes
# 需要导入模块: from models import Movie [as 别名]
# 或者: from models.Movie import source [as 别名]
def fetchDetailsRottenTomatoes(identifiers):
movie=Movie()
movie.sourceID=identifiers.sourceID
movie.source=identifiers.source
url=rottenTomatoesUrl +'/movies/' + str(identifiers.sourceID) + '.json?apikey=' + rottenKey
data=safeRequestJSON(url)
reviewsUrl=rottenTomatoesUrl +'/movies/' + str(identifiers.sourceID) + '/reviews.json?apikey=' + rottenKey
try:
movie.year = str(data['year'])
except:
movie.year =''
try:
movie.title = data['title']
except:
movie.title =''
try:
movie.numReviews=safeRequestJSON(reviewsUrl)['total']
except:
movie.numReviews=0
try:
movie.description=data['synopsis'] if data['synopsis'] else ''
except:
movie.description=''
try:
movie.actors=''
for actor in data['abridged_cast']:
if actor !=data['abridged_cast'][-1]:
movie.actors+=actor['name'] + actorsDelimiter
else:
movie.actors+=actor['name']
except:
movie.actors=''
return movie