forked from openlp/openlp
parent
04bafa62fa
commit
63f08f0c4a
@ -292,7 +292,7 @@ class SongFormat(object):
|
||||
'class': ProPresenterImport,
|
||||
'name': 'ProPresenter',
|
||||
'prefix': 'proPresenter',
|
||||
'filter': '%s (*.pro4)' % translate('SongsPlugin.ImportWizardForm', 'ProPresenter Song Files')
|
||||
'filter': '%s (*.pro4)' % translate('SongsPlugin.ImportWizardForm', 'ProPresenter 4 Song Files')
|
||||
},
|
||||
SongBeamer: {
|
||||
'class': SongBeamerImport,
|
||||
|
@ -27,5 +27,5 @@
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
"""
|
||||
The :mod:`~openlp.plugins.songs.lib.import` module contains importers for the Songs plugin.
|
||||
The :mod:`~openlp.plugins.songs.lib.importers` module contains importers for the Songs plugin.
|
||||
"""
|
||||
|
@ -33,17 +33,20 @@ ProPresenter song files into the current installation database.
|
||||
|
||||
import os
|
||||
import base64
|
||||
import logging
|
||||
from lxml import objectify
|
||||
|
||||
from openlp.core.ui.wizard import WizardStrings
|
||||
from openlp.plugins.songs.lib import strip_rtf
|
||||
from .songimport import SongImport
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ProPresenterImport(SongImport):
|
||||
"""
|
||||
The :class:`ProPresenterImport` class provides OpenLP with the
|
||||
ability to import ProPresenter song files.
|
||||
ability to import ProPresenter 4 song files.
|
||||
"""
|
||||
def do_import(self):
|
||||
self.import_wizard.progress_bar.setMaximum(len(self.import_source))
|
||||
@ -67,9 +70,15 @@ class ProPresenterImport(SongImport):
|
||||
count = 0
|
||||
for slide in root.slides.RVDisplaySlide:
|
||||
count += 1
|
||||
if not hasattr(slide.displayElements, 'RVTextElement'):
|
||||
log.debug('No text found, may be an image slide')
|
||||
continue
|
||||
RTFData = slide.displayElements.RVTextElement.get('RTFData')
|
||||
rtf = base64.standard_b64decode(RTFData)
|
||||
words, encoding = strip_rtf(rtf.decode())
|
||||
self.add_verse(words, "v%d" % count)
|
||||
# Some songs don't have a title - use the first line as title
|
||||
if not self.title:
|
||||
self.title = self.guess_title()
|
||||
if not self.finish():
|
||||
self.log_error(self.import_source)
|
||||
|
@ -316,6 +316,15 @@ class SongImport(QtCore.QObject):
|
||||
self.verse_order_list_generated.append(self.verse_order_list_generated[-1])
|
||||
self.verse_order_list_generated_useful = True
|
||||
|
||||
def guess_title(self):
|
||||
"""
|
||||
Guess the title from the first verse (to be used when the song has no title information)
|
||||
:return: The guessed title
|
||||
"""
|
||||
if not self.verses:
|
||||
return ''
|
||||
return self.verses[0][1].split('\n')[0].strip()
|
||||
|
||||
def check_complete(self):
|
||||
"""
|
||||
Check the mandatory fields are entered (i.e. title and a verse)
|
||||
|
Loading…
Reference in New Issue
Block a user