Exemple #1
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()
Exemple #2
0
def sendXbmcLibraryUpdate():
	try:
		settings = settingsManager.systemSettings()
		conn = httplib.HTTPConnection('localhost', settings.xbmcPort, timeout=1)
		conn.connect()
		conn.request('GET', '/xbmcCmds/xbmcHttp?command=ExecBuiltIn(UpdateLibrary(video))')
		r = conn.getresponse()
		conn.close()
	except:
		print "Had a problem updating XBMC's library"
Exemple #3
0
def sendXbmcNotification(title, message):
	title = string.replace(title, ' ', '%20')
	message = string.replace(message, ' ', '%20')
	try:
		settings = settingsManager.systemSettings()
		conn = httplib.HTTPConnection('localhost', settings.xbmcPort, timeout=1)
		conn.connect()
		conn.request('GET', '/xbmcCmds/xbmcHttp?command=ExecBuiltIn(Notification('+title+','+message+'))')
		r = conn.getresponse()
		conn.close()
	except:
		print "Had a problem sending message to XBMC"
Exemple #4
0
def main():
	argument = grabArguments()
	if argument == 's':
		scanTorrents.main()
	elif argument == 'r':
		systemConf = settingsManager.systemSettings()
		databaseSetup.resetTables(systemConf)
		databaseSetup.createTables(systemConf)
	elif argument == 'b':
		generateBackdrops.main()
	elif argument == None:
		scanTorrents.main()
	else:
		print 'There was an issue starting movServer'
Exemple #5
0
def createConnection():
    systemConf = settingsManager.systemSettings()
    conn = mdb.connect(systemConf.mysqlServer, systemConf.mysqlUser, systemConf.mysqlPassword, "movServer")
    return conn