forked from openlp/openlp
Head r1320
This commit is contained in:
commit
b967fbf650
@ -60,8 +60,9 @@ class MediaMediaItem(MediaManagerItem):
|
||||
def retranslateUi(self):
|
||||
self.onNewPrompt = translate('MediaPlugin.MediaItem', 'Select Media')
|
||||
self.onNewFileMasks = unicode(translate('MediaPlugin.MediaItem',
|
||||
'Videos (%s);;Audio (%s);;%s (*)')) % (self.parent.video_list,
|
||||
self.parent.audio_list, UiStrings.AllFiles)
|
||||
'Videos (%s);;Audio (%s);;%s (*)')) % (
|
||||
u' '.join(self.parent.video_list),
|
||||
u' '.join(self.parent.audio_list), UiStrings.AllFiles)
|
||||
self.replaceAction.setText(UiStrings.ReplaceBG)
|
||||
self.replaceAction.setToolTip(UiStrings.ReplaceLiveBG)
|
||||
self.resetAction.setText(UiStrings.ResetBG)
|
||||
|
@ -45,36 +45,28 @@ class MediaPlugin(Plugin):
|
||||
self.icon = build_icon(self.icon_path)
|
||||
# passed with drag and drop messages
|
||||
self.dnd_id = u'Media'
|
||||
self.audio_list = u''
|
||||
self.video_list = u''
|
||||
self.audio_list = []
|
||||
self.video_list = []
|
||||
mimetypes.init()
|
||||
for mimetype in Phonon.BackendCapabilities.availableMimeTypes():
|
||||
mimetype = unicode(mimetype)
|
||||
type = mimetype.split(u'audio/x-')
|
||||
self.audio_list, mimetype = self._addToList(self.audio_list,
|
||||
type, mimetype)
|
||||
type = mimetype.split(u'audio/')
|
||||
self.audio_list, mimetype = self._addToList(self.audio_list,
|
||||
type, mimetype)
|
||||
type = mimetype.split(u'video/x-')
|
||||
self.video_list, mimetype = self._addToList(self.video_list,
|
||||
type, mimetype)
|
||||
type = mimetype.split(u'video/')
|
||||
self.video_list, mimetype = self._addToList(self.video_list,
|
||||
type, mimetype)
|
||||
if mimetype.startswith(u'audio/'):
|
||||
self._addToList(self.audio_list, mimetype)
|
||||
elif mimetype.startswith(u'video/'):
|
||||
self._addToList(self.video_list, mimetype)
|
||||
log.info(u'MediaPlugin handles audio extensions: %s',
|
||||
u' '.join(self.audio_list))
|
||||
log.info(u'MediaPlugin handles video extensions: %s',
|
||||
u' '.join(self.video_list))
|
||||
|
||||
def _addToList(self, list, value, mimetype):
|
||||
def _addToList(self, list, mimetype):
|
||||
# Is it a media type
|
||||
if len(value) == 2:
|
||||
extensions = mimetypes.guess_all_extensions(unicode(mimetype))
|
||||
# we have an extension
|
||||
if extensions:
|
||||
for extension in extensions:
|
||||
if list.find(extension) == -1:
|
||||
list += u'*%s ' % extension
|
||||
self.serviceManager.supportedSuffixes(extension[1:])
|
||||
mimetype = u''
|
||||
return list, mimetype
|
||||
extensions = mimetypes.guess_all_extensions(unicode(mimetype))
|
||||
for extension in extensions:
|
||||
ext = u'*%s' % extension
|
||||
if ext not in list:
|
||||
list.append(ext)
|
||||
self.serviceManager.supportedSuffixes(extension[1:])
|
||||
|
||||
def about(self):
|
||||
about_text = translate('MediaPlugin', '<strong>Media Plugin</strong>'
|
||||
|
@ -254,9 +254,9 @@ class SongMediaItem(MediaManagerItem):
|
||||
"""
|
||||
if self.searchAsYouType:
|
||||
search_length = 1
|
||||
if self.searchTextEdit.currentSearchType() == 1:
|
||||
if self.searchTextEdit.currentSearchType() == SongSearch.Entire:
|
||||
search_length = 3
|
||||
elif self.searchTextEdit.currentSearchType() == 3:
|
||||
elif self.searchTextEdit.currentSearchType() == SongSearch.Lyrics:
|
||||
search_length = 7
|
||||
if len(text) > search_length:
|
||||
self.onSearchTextButtonClick()
|
||||
|
@ -245,6 +245,8 @@ class SongBeamerImport(SongImport):
|
||||
self.song_number = u''
|
||||
elif tag_val[0] == u'#Speed':
|
||||
pass
|
||||
elif tag_val[0] == u'Tempo':
|
||||
pass
|
||||
elif tag_val[0] == u'#TextAlign':
|
||||
pass
|
||||
elif tag_val[0] == u'#Title':
|
||||
|
@ -299,9 +299,9 @@ class OpenLyrics(object):
|
||||
# Remove chords from xml.
|
||||
xml = re.compile(u'<chord name=".*?"/>').sub(u'', xml)
|
||||
song_xml = objectify.fromstring(xml)
|
||||
try:
|
||||
if hasattr(song_xml, u'properties'):
|
||||
properties = song_xml.properties
|
||||
except AttributeError:
|
||||
else:
|
||||
return None
|
||||
song = Song()
|
||||
self._process_copyright(properties, song)
|
||||
@ -369,13 +369,11 @@ class OpenLyrics(object):
|
||||
The song object.
|
||||
"""
|
||||
authors = []
|
||||
try:
|
||||
if hasattr(properties, u'authors'):
|
||||
for author in properties.authors.author:
|
||||
display_name = self._text(author)
|
||||
if display_name:
|
||||
authors.append(display_name)
|
||||
except AttributeError:
|
||||
pass
|
||||
if not authors:
|
||||
authors.append(SongStrings.AuthorUnknownUnT)
|
||||
for display_name in authors:
|
||||
@ -399,10 +397,8 @@ class OpenLyrics(object):
|
||||
``song``
|
||||
The song object.
|
||||
"""
|
||||
try:
|
||||
if hasattr(properties, u'ccliNo'):
|
||||
song.ccli_number = self._text(properties.ccliNo)
|
||||
except AttributeError:
|
||||
song.ccli_number = u''
|
||||
|
||||
def _process_comments(self, properties, song):
|
||||
"""
|
||||
@ -414,15 +410,13 @@ class OpenLyrics(object):
|
||||
``song``
|
||||
The song object.
|
||||
"""
|
||||
try:
|
||||
comments_list = []
|
||||
if hasattr(properties, u'comments'):
|
||||
comments_list = []
|
||||
for comment in properties.comments.comment:
|
||||
commenttext = self._text(comment)
|
||||
if commenttext:
|
||||
comments_list.append(commenttext)
|
||||
song.comments = u'\n'.join(comments_list)
|
||||
except AttributeError:
|
||||
song.comments = u''
|
||||
|
||||
def _process_copyright(self, properties, song):
|
||||
"""
|
||||
@ -434,10 +428,8 @@ class OpenLyrics(object):
|
||||
``song``
|
||||
The song object.
|
||||
"""
|
||||
try:
|
||||
if hasattr(properties, u'copyright'):
|
||||
song.copyright = self._text(properties.copyright)
|
||||
except AttributeError:
|
||||
song.copyright = u''
|
||||
|
||||
def _process_lyrics(self, properties, lyrics, song):
|
||||
"""
|
||||
@ -478,9 +470,9 @@ class OpenLyrics(object):
|
||||
song.search_lyrics = search_text.lower()
|
||||
song.lyrics = unicode(sxml.extract_xml(), u'utf-8')
|
||||
# Process verse order
|
||||
try:
|
||||
if hasattr(properties, u'verseOrder'):
|
||||
song.verse_order = self._text(properties.verseOrder)
|
||||
except AttributeError:
|
||||
else:
|
||||
# We have to process the temp_verse_order, as the verseOrder
|
||||
# property is not present.
|
||||
previous_type = u''
|
||||
@ -511,7 +503,7 @@ class OpenLyrics(object):
|
||||
"""
|
||||
song.song_book_id = 0
|
||||
song.song_number = u''
|
||||
try:
|
||||
if hasattr(properties, u'songbooks'):
|
||||
for songbook in properties.songbooks.songbook:
|
||||
bookname = self._get(songbook, u'name')
|
||||
if bookname:
|
||||
@ -522,15 +514,10 @@ class OpenLyrics(object):
|
||||
book = Book.populate(name=bookname, publisher=u'')
|
||||
self.manager.save_object(book)
|
||||
song.song_book_id = book.id
|
||||
try:
|
||||
if self._get(songbook, u'entry'):
|
||||
song.song_number = self._get(songbook, u'entry')
|
||||
except AttributeError:
|
||||
pass
|
||||
if hasattr(songbook, u'entry'):
|
||||
song.song_number = self._get(songbook, u'entry')
|
||||
# We only support one song book, so take the first one.
|
||||
break
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
def _process_titles(self, properties, song):
|
||||
"""
|
||||
@ -563,7 +550,7 @@ class OpenLyrics(object):
|
||||
``song``
|
||||
The song object.
|
||||
"""
|
||||
try:
|
||||
if hasattr(properties, u'themes'):
|
||||
for topictext in properties.themes.theme:
|
||||
topictext = self._text(topictext)
|
||||
if topictext:
|
||||
@ -574,8 +561,6 @@ class OpenLyrics(object):
|
||||
topic = Topic.populate(name=topictext)
|
||||
self.manager.save_object(topic)
|
||||
song.topics.append(topic)
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
def _dump_xml(self, xml):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user