Ejemplo n.º 1
0
def postLibraryMovie():
	movieTitle = request.json['title']
	movieYear = request.json['year']
	linkedMediaFileId = request.json['associatedMediaFileId']

	linkedMediaFile = mediaFile.getByMediaFileId(linkedMediaFileId)
	newMovie = movie.create(movieTitle, movieYear).save()
	mediaLinker.associateMovieWithMediaFile(newMovie, linkedMediaFile)

	if 'active' in request.json and request.json['active'] == 1:
		mediaLinker.linkMediaFileToMovie(linkedMediaFile, newMovie)
	return newMovie.asJson()
Ejemplo n.º 2
0
def main():
	systemConf = settingsManager.systemSettings()
	dirConf = settingsManager.directorySettings()
	conn = mySql.createConnection()

	addedContent = []
	for root, dirs, files in os.walk(dirConf.contentSource):
		for file in files:
			fullPath = os.path.join(root, file)
			if isNewTvEpisode(file, root, conn):
				tvShowInfo = getSeries(file)
				newMediaFile = mediaFile.createWithPath(fullPath).save(conn)
				anEpisode = episode.create(tvShowInfo[1], tvShowInfo[2])
				aSeriesAlias = seriesAlias.getBySeriesAliasString(tvShowInfo[0], conn)
				anEpisode = mediaLinker.associateEpisodeWithMediaFile(anEpisode, newMediaFile)
				if aSeriesAlias == None:
					aSeriesAlias = seriesAlias.create(tvShowInfo[0]).save(conn)
					anEpisode = mediaLinker.associateEpisodeWithSeriesAlias(anEpisode, aSeriesAlias)
					seriesArray = findImdbSeriesLikeTitle(file)
					if len(seriesArray) > 0:
						mediaLinker.associateArrayOfSeriesWithSeriesAlias(seriesArray, aSeriesAlias)
						episodeName = mediaLinker.linkMediaFileToSeries(newMediaFile, seriesArray[0])
						addedContent.append(episodeName)
						print file, '  ->  ', episodeName
					else:
						print "\t", "No series for " + file
				else:
					anEpisode = mediaLinker.associateEpisodeWithSeriesAlias(anEpisode, aSeriesAlias)
					aSeries = series.getActiveBySeriesAliasId(aSeriesAlias.id, conn)
					episodeName = mediaLinker.linkMediaFileToSeries(newMediaFile, aSeries)
					addedContent.append(episodeName)
					print file, '  ->  ', episodeName
			elif isNewMovie(file, root, conn):
				newMediaFile = mediaFile.createWithPath(fullPath).save(conn)
				#Check to see if the movie is in a sub folder
				#if so then do the search based on folder name instead of file name
				if len(root) > len(dirConf.contentSource):
					folderTitle = os.path.basename(root)
					movies = findImdbMoviesLikeTitle(folderTitle)
				else:
					movies = findImdbMoviesLikeTitle(file)

				if len(movies) > 0:
					mediaLinker.associateArrayOfMoviesWithMediaFile(movies, newMediaFile, conn)
					movieName = mediaLinker.linkMediaFileToMovie(newMediaFile, movies[0], conn)
					addedContent.append(movieName)
					print file, '  ->  ', movieName
				else:
					print "\t", "No movies for " + file			

	conn.close()
	if len(addedContent) == 1:
		sendXbmcNotification("New Content", addedContent[0]+" was added to the library.")
		sendXbmcLibraryUpdate()
	elif len(addedContent) > 1:
		sendXbmcNotification("New Content", str(len(addedContent))+" new items were added to the library.")
		sendXbmcLibraryUpdate()
Ejemplo n.º 3
0
def getLibraryMovieCreateLink(movieId):
	linkedMovie = movie.getByMovieId(movieId)
	linkedMediaFile = mediaFile.getByMediaFileId(linkedMovie.associatedMediaFileId)
	mediaLinker.linkMediaFileToMovie(linkedMediaFile, linkedMovie)
	return linkedMovie.asJson()