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


Python Movie.sourceID方法代码示例

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


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

示例1: fetchDetailsTheMovieDB

# 需要导入模块: from models import Movie [as 别名]
# 或者: from models.Movie import sourceID [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
开发者ID:ebarakos,项目名称:movie-aggregator,代码行数:37,代码来源:utils.py

示例2: fetchDetailsRottenTomatoes

# 需要导入模块: from models import Movie [as 别名]
# 或者: from models.Movie import sourceID [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	
开发者ID:ebarakos,项目名称:movie-aggregator,代码行数:35,代码来源:utils.py


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