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


Python Movie.title方法代码示例

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


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

示例1: fetchDetailsRottenTomatoes

# 需要导入模块: from models import Movie [as 别名]
# 或者: from models.Movie import title [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

示例2: fetchDetailsTheMovieDB

# 需要导入模块: from models import Movie [as 别名]
# 或者: from models.Movie import title [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

示例3: retrieve_movie_from_id

# 需要导入模块: from models import Movie [as 别名]
# 或者: from models.Movie import title [as 别名]
def retrieve_movie_from_id(movie_id):
    """
    Retrieve movie info from IMDB by movie id.
    :param movie_id: original title of the film to retrieve info
    :type movie_id: string
    :return: Movie's key
    :rtype: ndb.Key
    :raise RetrieverError: if there is an error from MYAPIFILMS
    """
    logging.info('Retrieving %s', movie_id)

    url = BASE_URL_MYAPIFILMS + 'imdb?idIMDB=' + movie_id + '&format=JSON&aka=1&business=0&seasons=0&seasonYear=0&technical=0&filter=N&exactFilter=0&limit=1&lang=en-us&actors=S&biography=0&trailer=1&uniqueName=0&filmography=0&bornDied=0&starSign=0&actorActress=0&actorTrivia=0&movieTrivia=0&awards=0&token=307cccfe-d20b-4b69-b976-d6a024538864'

    json_page = get(url).encode('utf-8')
    json_data = json.loads(json_page)

    movie = Movie(id=json_data['idIMDB'],
                  plot=json_data['plot'],
                  poster=clear_url(json_data['urlPoster']) if ('urlPoster' in json_data and json_data['urlPoster'] != "") else None,
                  rated=json_data['rated'],
                  simple_plot=json_data['simplePlot'],
                  genres=json_data['genres'])

    try:
        trailer_url = json_data['trailer']['videoURL']
        movie.trailer = trailer_url
    except KeyError:
        movie.trailer = None

    movie.original_title = json_data['title']

    akas = json_data['akas']
    for aka in akas:
        if aka['country'] == 'Italy':
            movie.title = aka['title']

    run_times = json_data['runtime']
    if len(run_times) == 0:
        movie.run_times = None
    else:
        movie.run_times = run_times[0]

    year = json_data['year']
    if len(year) > 4:
        year = year[-4:]

    movie.year = year
    key = movie.put()
    actors_list = json_data['actors']
    directors_list = json_data['directors']
    writers_list = json_data['writers']

    retrieve_artists(movie, actors_list, directors_list, writers_list)

    logging.info('Retrieved %s', movie_id)
    return key
开发者ID:PRIMETIME4U,项目名称:PRIMETIME4U-server,代码行数:58,代码来源:IMDB_retriever.py

示例4: aggregateMovies

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

示例5: retrieve_movie_from_title

# 需要导入模块: from models import Movie [as 别名]
# 或者: from models.Movie import title [as 别名]
def retrieve_movie_from_title(movie_original_title, movie_director, movie_cast, movie_title=None, movie_url=None,
                              movie_year=None, movie_genre=None):
    """
    Retrieve movie info from IMDB by movie title.
    :param movie_title: title of the film to retrieve info
    :type movie_title: string
    :param movie_original_title: original title of the film to retrieve info
    :type movie_original_title: string
    :param movie_director: director of the film to retrieve info
    :type movie_director: string
    :param movie_genre: genre of the film to retrieve info
    :type movie_genre: string
    :return: Movie's key
    :rtype: ndb.Key
    :raise RetrieverError: if there is an error from MYAPIFILMS
    """
    logging.info('Retrieving %s', movie_original_title)

    url = BASE_URL_MYAPIFILMS + 'imdb?title=' + movie_original_title + '&format=JSON&aka=0&business=0&seasons=0&seasonYear=' + movie_year + '&technical=0&filter=M&exactFilter=0&limit=1&lang=en-us&actors=S&biography=0&trailer=1&uniqueName=0&filmography=0&bornDied=0&starSign=0&actorActress=0&actorTrivia=0&movieTrivia=0&awards=0&token=307cccfe-d20b-4b69-b976-d6a024538864'
    logging.info('Url My API Films: %s', url)

    json_page = get(url).encode('utf-8')
    json_data = json.loads(json_page)

    if type(json_data) is not list:  # If it is not a list there is a problem
        logging.info('Movie not found in IMDB.')
        for x in range(26, len(movie_url)):
            if movie_url[x] == "/":
                end = x
                break

        movie_id = movie_url[26: end]
        movie = Movie(id=movie_id,
                      year=movie_year,
                      original_title=movie_original_title,
                      title=movie_title,
                      genres=[movie_genre])

        actors_string = movie_cast
        directors_list = movie_director
        writers_list = []
        #print actors_string

        actors_list = []
        begin = 0
        count = 0
        for i in actors_string:
            count += 1
            if i == "," or count == len(actors_string) - 1:
                actors_list.append(actors_string[begin:count - 1])
                begin = count + 1
                search_artist_from_name(actors_list[len(actors_list) - 1], movie)

        for director_name in directors_list:
            search_artist_from_name(actors_list[len(actors_list) - 1], movie, director_name)

        html_page_plot = get(movie_url).encode('utf-8')
        tree = lxml.html.fromstring(html_page_plot)
        try:
            movie.plot_it = tree.xpath('//article[@class="scheda-desc"]/p/text()')[0]
        except IndexError:
            logging.error('Impossible to retrieve info from FilmTV')
            pass
        movie.put()
    else:
        directors_list = json_data[0]['directors']
        #print movie_director
        #prova = directors_list[0]['name'].encode('utf-8')
        #print prova
        if (movie_director in directors_list[0]['name'].encode('utf-8')) or (directors_list[0]['name'].encode('utf-8') in movie_director):
            movie = Movie(id=json_data[0]['idIMDB'],
                          plot=json_data[0]['plot'],
                          poster=clear_url(json_data[0]['urlPoster']),
                          rated=json_data[0]['rated'],
                          simple_plot=json_data[0]['simplePlot'],
                          genres=json_data[0]['genres'])
            try:
                trailer_url = json_data[0]['trailer']['videoURL']
                movie.trailer = trailer_url
            except KeyError:
                movie.trailer = None

            movie.title = movie_title
            movie.original_title = movie_original_title

            run_times = json_data[0]['runtime']
            if len(run_times) == 0:
                movie.run_times = None
            else:
                movie.run_times = run_times[0]

            year = json_data[0]['year']
            if len(year) > 4:
                year = year[-4:]
            movie.year = year

            actors_list = json_data[0]['actors']
            writers_list = json_data[0]['writers']

            retrieve_artists(movie, actors_list, directors_list, writers_list)
#.........这里部分代码省略.........
开发者ID:PRIMETIME4U,项目名称:PRIMETIME4U-server,代码行数:103,代码来源:IMDB_retriever.py


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