Ejemplo n.º 1
0
def findImdbMoviesLikeTitle(fileName):
	imdbContext = imdb.IMDb()
	fileNameArray = titleHandler.returnWellFormatedArrayFromTitle(fileName)

	titles = {}
	movies = []
	lastSuccessfulTitle = ''
	for i in range(0, len(fileNameArray)):
		partialFileName = titleStringFromIndexOfTitleArray(fileNameArray, i)
		imdbResults = imdbContext.search_movie(partialFileName)

		loop = 15 if len(imdbResults) >= 15 else len(imdbResults)
		for j in range(0, loop):
			imdbResult = imdbResults[j]
			newMovie = movie.create(imdbResult['title'])
			if imdbResult.has_key('year'):
				newMovie.year = imdbResult['year']
			try:
				titleIndex = '{0} {1}'.format(newMovie.title, newMovie.year)
				if not titleIndex in titles:
					titles[titleIndex] = True
					movies.append(newMovie)
			except UnicodeEncodeError:
				continue
			lastSuccessfulTitle = partialFileName
	movies = titleHandler.orderMovieArrayByMatchingTitle(movies, lastSuccessfulTitle)
	return movies
Ejemplo n.º 2
0
def findImdbSeriesLikeTitle(fileName):
	imdbContext = imdb.IMDb()
	fileNameArray = titleHandler.returnWellFormatedArrayFromTitle(fileName)

	seriesTitles = {}
	serieses = []
	lastSuccessfulSeries = ''
	for i in range(0, len(fileNameArray)):		
		partialFileName = titleStringFromIndexOfTitleArray(fileNameArray, i)
		imdbResults = imdbContext.search_movie(partialFileName)

		loop = 10 if len(imdbResults) >= 10 else len(imdbResults)
		for j in range(0, loop):
			imdbResult = imdbResults[j]
			if imdbResult['kind'] == 'tv series':
				newSeries = series.create(imdbResult['title'])
				if not newSeries.title in seriesTitles:
					seriesTitles[newSeries.title] = True
					serieses.append(newSeries)
				lastSuccessfulSeries = partialFileName
	serieses = titleHandler.orderTvArrayByMatchingSeries(serieses, lastSuccessfulSeries)
	return serieses