# -*- coding: utf-8 -*- # **************************************************************************** # Copyright (c) 2008 INdT/Fucapi. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see . # # ============================================================================ # Project Name : PC Remote # Author : Jonatas Isvi # Email : jonatas.nona@gmail.com # Reviewer : # Email : # Version : 1.0 # Package : utils # Description : plisparser # ============================================================================ from xml.etree import cElementTree as ElementTree # get the file def _request(url): xml = url return parse_playlist_file(xml) # parser the file def parse_playlist_file(xml): tree = ElementTree.parse(xml) listsongs = [] dictsongs = {} count = duration = filesize = 0 title = artist = path = '' for child in tree.getiterator(): if child.tag == 'Title': title = child.text elif child.tag == 'Artist': artist = child.text elif child.tag == 'Length': duration = child.text elif child.tag == 'Filesize': filesize = child.text count = count + 1 dictsongs = {'track' : count, 'title' : title, 'artist' : artist, 'duration' : duration, 'filesize' : filesize, 'path' : None, 'extension' : None, } listsongs.append(dictsongs) return listsongs