← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~derek-scotney/openlp/songselectfix into lp:openlp

 

Derek Scotney has proposed merging lp:~derek-scotney/openlp/songselectfix into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  #655102 CCLI song importer brings in some text not needed
  https://bugs.launchpad.net/bugs/655102


Fixes unwanted text imported from some SongSelect files.  SongSelect only has a few verse types available for verses and adds extra ones by setting the verse type to 'misc' and then including the actual type on the next line.  In the case of a 'misc' type or unknown type, the next line is checked for a valid verse type. The fix has been made for both .txt and .usr file types.     
-- 
https://code.launchpad.net/~derek-scotney/openlp/songselectfix/+merge/43005
Your team OpenLP Core is requested to review the proposed merge of lp:~derek-scotney/openlp/songselectfix into lp:openlp.
=== modified file 'openlp/plugins/songs/lib/cclifileimport.py'
--- openlp/plugins/songs/lib/cclifileimport.py	2010-11-03 17:19:44 +0000
+++ openlp/plugins/songs/lib/cclifileimport.py	2010-12-07 20:16:22 +0000
@@ -165,6 +165,7 @@
                 song_words = line[6:].strip()
             #Unhandled usr keywords:Type,Version,Admin,Themes,Keys
         #Process Fields and words sections
+        check_first_verse_line = False
         field_list = song_fields.split(u'/t')
         words_list = song_words.split(u'/t')
         for counter in range(0, len(field_list)):
@@ -176,10 +177,25 @@
                 verse_type = u'B'
             else: #Other
                 verse_type = u'O'
+                check_first_verse_line = True
             verse_text = unicode(words_list[counter])
             verse_text = verse_text.replace("/n",  "\n")
+            verse_lines = verse_text.split(u'\n',  1)
+            if check_first_verse_line:
+                if verse_lines[0].startswith(u'(PRE-CHORUS'):
+                    verse_type = u'P'
+                    log.debug(u'USR verse PRE-CHORUS: %s', verse_lines[0] )
+                    verse_text = verse_lines[1]
+                elif verse_lines[0].startswith(u'(BRIDGE'):
+                    verse_type = u'B'
+                    log.debug(u'USR verse BRIDGE')
+                    verse_text = verse_lines[1]
+                elif verse_lines[0].startswith(u'('):
+                    verse_type = u'O'
+                    verse_text = verse_lines[1]            
             if len(verse_text) > 0:
                 self.add_verse(verse_text, verse_type)
+            check_first_verse_line = False
         #Handle multiple authors
         author_list = song_author.split(u'/')
         if len(author_list) < 2:
@@ -228,6 +244,7 @@
         log.debug(u'TXT file text: %s', textList)
         self.set_defaults()
         line_number = 0
+        check_first_verse_line = False
         verse_text = u''
         song_comments = u''
         song_copyright = u''
@@ -265,16 +282,32 @@
                             elif verse_desc_parts[0].startswith(u'Br'):
                                 verse_type = u'B'
                             else:
+                                #we need to analyse the next line for
+                                #verse type, so set flag
                                 verse_type = u'O'
+                                check_first_verse_line = True
                             verse_number = verse_desc_parts[1]
                         else:
                             verse_type = u'O'
                             verse_number = 1
                         verse_start = True
                     else:
-                        # We have verse content or the start of the
-                        # last part. Add l so as to keep the CRLF
-                        verse_text = verse_text + line
+                        #check first line for verse type
+                        if check_first_verse_line:
+                            if line.startswith(u'(PRE-CHORUS'):
+                                verse_type = u'P'
+                            elif line.startswith(u'(BRIDGE'):
+                                verse_type = u'B'
+                            # Handle all other misc types	
+                            elif line.startswith(u'('):
+                                verse_type = u'O'
+                            else:
+                                verse_text = verse_text + line	
+                            check_first_verse_line = False
+                        else:																		
+                            # We have verse content or the start of the
+                            # last part. Add l so as to keep the CRLF
+                            verse_text = verse_text + line
                 else:
                     #line_number=2, copyright
                     if line_number == 2:


Follow ups