def processxml(ruta):
    movielist = []
    with open(ruta) as doc:
            tree = ET.parse(doc)
    for node in tree.iter('movie'):
        name = node.find('title').text
        ide = node.find('id').text
        path = node.find('path').text
        fileinfo = node.find('fileinfo')
        audiocad = []
        if fileinfo != None:
            streamdetails = fileinfo.find('streamdetails')
            width = streamdetails.find('video').find('width').text
            height = streamdetails.find('video').find('height').text
            if streamdetails != None:
                audio = streamdetails.findall("audio")
                for x in audio:
                    audiocad.append((x.find('language').text))
        movielist.append(movie(ide, name, width, height, path, audiocad))
    return movielist
def getMovies(urlServicio):
	movielist = []
	movieListRequest =	requests.get(urlServicio+'/jsonrpc?request={"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies","params": {	"properties" : ["tag","imdbnumber"],"sort": { "order": "ascending", "method": "label", "ignorearticle": true } }, "id": "libMovies"}')
	lista  = movieListRequest.json()
	movieListJson=lista['result']['movies']
	for jsonMovie in movieListJson:
		movieID = jsonMovie['movieid']
		url =urlServicio+ '/jsonrpc?request={"jsonrpc": "2.0", "method": "VideoLibrary.GetMovieDetails", "params": {"movieid": %s, "properties": ["title", "imdbnumber", "streamdetails", "rating", "file"]}, "id": "1"}' % movieID
		movieInfoRequest = requests.get(url)
		movies =movieInfoRequest.json() 
		ide =movies['result']['moviedetails']['imdbnumber']
		name=movies['result']['moviedetails']['title']
		width = 0;
		height = 0;
		for media in movies['result']['moviedetails']['streamdetails']['video']:
			width = media['width'];
			height = media['height'];
		path=movies['result']['moviedetails']['file']
		#audiocad=len(movie['result']['moviedetails']['streamdetails']['audio'])
		audiocad = []
		for audio in movies['result']['moviedetails']['streamdetails']['audio']:
			audiocad.append(audio['language'])
		movielist.append(movie(ide, name, width, height, path, audiocad))
	return movielist