Added support for ALL DreamBeam file formats.

This commit is contained in:
Philip Ridout 2012-04-07 17:41:03 +01:00
parent 4ce95e9d56
commit 9c11494364

View File

@ -108,6 +108,22 @@ class DreamBeamImport(SongImport):
('Invalid DreamBeam song file. Missing ' ('Invalid DreamBeam song file. Missing '
'DreamSong tag.')))) 'DreamSong tag.'))))
continue continue
if hasattr(song_xml, u'Version'):
self.version = float(song_xml.Version.text)
# Version numbers found in DreamBeam Source /FileTypes/Song.cs
if self.version <= 0.49:
if hasattr(song_xml.Text0, u'Text'):
self.title = unicode(song_xml.Text0.Text.text)
if hasattr(song_xml.Text1, u'Text'):
self.lyrics = unicode(song_xml.Text1.Text.text)
for verse in self.lyrics.split(u'\n\n\n'):
self.addVerse(verse)
if hasattr(song_xml.Text2, u'Text'):
# DreamBeam does not have a copyright field, instead it
# sometimes uses the author field
self.addCopyright(unicode(song_xml.Text2.Text.text))
self.parseAuthor(unicode(song_xml.Text2.Text.text))
elif self.version >= 0.5:
if hasattr(song_xml, u'Title'): if hasattr(song_xml, u'Title'):
self.title = unicode(song_xml.Title.text) self.title = unicode(song_xml.Title.text)
if hasattr(song_xml, u'Author'): if hasattr(song_xml, u'Author'):
@ -127,11 +143,17 @@ class DreamBeamImport(SongImport):
if hasattr(song_xml, u'Number'): if hasattr(song_xml, u'Number'):
self.songNumber = unicode(song_xml.Number.text) self.songNumber = unicode(song_xml.Number.text)
if hasattr(song_xml, u'Sequence'): if hasattr(song_xml, u'Sequence'):
for LyricsSequenceItem in song_xml.Sequence.iterchildren(): for LyricsSequenceItem in (
song_xml.Sequence.iterchildren()):
self.verseOrderList.append( self.verseOrderList.append(
"%s%s" % (LyricsSequenceItem.get(u'Type')[:1], "%s%s" % (LyricsSequenceItem.get(u'Type')[:1],
LyricsSequenceItem.get(u'Number'))) LyricsSequenceItem.get(u'Number')))
if hasattr(song_xml, u'Notes'): if hasattr(song_xml, u'Notes'):
self.comments = unicode(song_xml.Notes.text) self.comments = unicode(song_xml.Notes.text)
else:
log.exception(u'No valid version information.'
'Invalid file %s' % file)
self.logError(file, SongStrings.XMLSyntaxError)
continue
if not self.finish(): if not self.finish():
self.logError(file) self.logError(file)