clr.AddReference("I2Common")
clr.AddReference("TWC.I2Libs")
clr.AddReference("System")

from System.IO import Directory
from System.IO import DirectoryInfo
from System.IO import Path

from TWC.I2.Util import Config

def Run(doc):

	root = doc.CreateElement("Movies")
	moviesDirPath = Path.Combine(Config.SystemRoot, "D:/TWC/I2/Movies")
	if Directory.Exists(moviesDirPath):
		files = DirectoryInfo(moviesDirPath).GetFiles("*.ts")

		for x in range(0, len(files)):
			f = files[x]
			movie = doc.CreateElement("movie")
			movietxt = doc.CreateTextNode(f.Name)
			movie.AppendChild(movietxt)
			root.AppendChild(movie)		
		
	doc.DocumentElement.AppendChild(root)