From d05c6b8d70e0c2c7851a4200a45769d682c9385f Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 5 Dec 2011 19:47:50 +0000 Subject: [PATCH] Fix up song import code --- openlp/plugins/songs/lib/mediaitem.py | 7 +++++-- openlp/plugins/songs/lib/xml.py | 13 ++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index c73966dd2..c5b59b0fe 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -558,16 +558,19 @@ class SongMediaItem(MediaManagerItem): # If there's any backing tracks, copy them over. if len(item.background_audio) > 0: self._updateBackgroundAudio(song, item) - if add_song and self.addSongFromService: + if add_song: song = self.openLyrics.xml_to_song(item.xml_version) # If there's any backing tracks, copy them over. if len(item.background_audio) > 0: self._updateBackgroundAudio(song, item) editId = song.id self.onSearchTextButtonClick() - else: + elif not self.addSongFromService: # Make sure we temporary import formatting tags. song = self.openLyrics.xml_to_song(item.xml_version, True) + # If there's any backing tracks, copy them over. + if len(item.background_audio) > 0: + self._updateBackgroundAudio(song, item) editId = song.id # Update service with correct song id. if editId: diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index 99427d979..b16db7e94 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -346,7 +346,7 @@ class OpenLyrics(object): lines_element.set(u'break', u'optional') return self._extract_xml(song_xml) - def xml_to_song(self, xml, parse_and_not_save=False): + def xml_to_song(self, xml, parse_and_temporary_save=False): """ Create and save a song from OpenLyrics format xml to the database. Since we also export XML from external sources (e. g. OpenLyrics import), we @@ -355,9 +355,9 @@ class OpenLyrics(object): ``xml`` The XML to parse (unicode). - ``parse_and_not_save`` - Switch to skip processing the whole song and to prevent storing the - songs to the database. Defaults to ``False``. + ``parse_and_temporary_save`` + Switch to skip processing the whole song and storing the songs in + the database with a temporary flag. Defaults to ``False``. """ # No xml get out of here. if not xml: @@ -371,14 +371,13 @@ class OpenLyrics(object): return None # Formatting tags are new in OpenLyrics 0.8 if float(song_xml.get(u'version')) > 0.7: - self._process_formatting_tags(song_xml, parse_and_not_save) + self._process_formatting_tags(song_xml, parse_and_temporary_save) song = Song() # Values will be set when cleaning the song. song.search_lyrics = u'' song.verse_order = u'' song.search_title = u'' - if parse_and_not_save: - song.temporary = True + song.temporary = parse_and_temporary_save self._process_copyright(properties, song) self._process_cclinumber(properties, song) self._process_titles(properties, song)