本文整理汇总了Python中models.Movie.actors方法的典型用法代码示例。如果您正苦于以下问题:Python Movie.actors方法的具体用法?Python Movie.actors怎么用?Python Movie.actors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Movie
的用法示例。
在下文中一共展示了Movie.actors方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fetchDetailsRottenTomatoes
# 需要导入模块: from models import Movie [as 别名]
# 或者: from models.Movie import actors [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
示例2: fetchDetailsTheMovieDB
# 需要导入模块: from models import Movie [as 别名]
# 或者: from models.Movie import actors [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
示例3: aggregateMovies
# 需要导入模块: from models import Movie [as 别名]
# 或者: from models.Movie import actors [as 别名]
def aggregateMovies(first,second):
commonIndexes=[]
finalMovies=[]
for firstMovie in first:
finalMovie=Movie()
finalMovie.title=firstMovie.title
finalMovie.year=firstMovie.year
for index,secondMovie in enumerate(second):
if secondMovie.title==firstMovie.title and secondMovie.year==firstMovie.year:
finalMovie.numReviews=secondMovie.numReviews+firstMovie.numReviews
finalMovie.description=max([secondMovie.description,firstMovie.description], key=len)
actorsList=set(firstMovie.actors.split(actorsDelimiter) + secondMovie.actors.split(actorsDelimiter))
actorsList = list(firstMovie.actors.split(actorsDelimiter))
actorsList.extend(x for x in secondMovie.actors.split(actorsDelimiter) if x not in actorsList)
for actor in actorsList:
if actor !=actorsList[-1]:
finalMovie.actors+=actor + actorsDelimiter
else:
finalMovie.actors+=actor
commonIndexes.append(index)
break
elif secondMovie==second[-1]:
finalMovie.numReviews=firstMovie.numReviews
finalMovie.description=firstMovie.description
finalMovie.actors=firstMovie.actors
finalMovies.append(finalMovie)
for index,secondMovie in enumerate(second):
if index not in commonIndexes:
finalMovie=Movie()
finalMovie.title=secondMovie.title
finalMovie.year=secondMovie.year
finalMovie.numReviews=secondMovie.numReviews
finalMovie.description=secondMovie.description
finalMovie.actors=secondMovie.actors
finalMovies.append(finalMovie)
return finalMovies