Head r1320

This commit is contained in:
Jon Tibble 2011-02-20 22:58:45 +00:00
commit b967fbf650
5 changed files with 37 additions and 57 deletions

View File

@ -60,8 +60,9 @@ class MediaMediaItem(MediaManagerItem):
def retranslateUi(self): def retranslateUi(self):
self.onNewPrompt = translate('MediaPlugin.MediaItem', 'Select Media') self.onNewPrompt = translate('MediaPlugin.MediaItem', 'Select Media')
self.onNewFileMasks = unicode(translate('MediaPlugin.MediaItem', self.onNewFileMasks = unicode(translate('MediaPlugin.MediaItem',
'Videos (%s);;Audio (%s);;%s (*)')) % (self.parent.video_list, 'Videos (%s);;Audio (%s);;%s (*)')) % (
self.parent.audio_list, UiStrings.AllFiles) u' '.join(self.parent.video_list),
u' '.join(self.parent.audio_list), UiStrings.AllFiles)
self.replaceAction.setText(UiStrings.ReplaceBG) self.replaceAction.setText(UiStrings.ReplaceBG)
self.replaceAction.setToolTip(UiStrings.ReplaceLiveBG) self.replaceAction.setToolTip(UiStrings.ReplaceLiveBG)
self.resetAction.setText(UiStrings.ResetBG) self.resetAction.setText(UiStrings.ResetBG)

View File

@ -45,36 +45,28 @@ class MediaPlugin(Plugin):
self.icon = build_icon(self.icon_path) self.icon = build_icon(self.icon_path)
# passed with drag and drop messages # passed with drag and drop messages
self.dnd_id = u'Media' self.dnd_id = u'Media'
self.audio_list = u'' self.audio_list = []
self.video_list = u'' self.video_list = []
mimetypes.init() mimetypes.init()
for mimetype in Phonon.BackendCapabilities.availableMimeTypes(): for mimetype in Phonon.BackendCapabilities.availableMimeTypes():
mimetype = unicode(mimetype) mimetype = unicode(mimetype)
type = mimetype.split(u'audio/x-') if mimetype.startswith(u'audio/'):
self.audio_list, mimetype = self._addToList(self.audio_list, self._addToList(self.audio_list, mimetype)
type, mimetype) elif mimetype.startswith(u'video/'):
type = mimetype.split(u'audio/') self._addToList(self.video_list, mimetype)
self.audio_list, mimetype = self._addToList(self.audio_list, log.info(u'MediaPlugin handles audio extensions: %s',
type, mimetype) u' '.join(self.audio_list))
type = mimetype.split(u'video/x-') log.info(u'MediaPlugin handles video extensions: %s',
self.video_list, mimetype = self._addToList(self.video_list, u' '.join(self.video_list))
type, mimetype)
type = mimetype.split(u'video/')
self.video_list, mimetype = self._addToList(self.video_list,
type, mimetype)
def _addToList(self, list, value, mimetype): def _addToList(self, list, mimetype):
# Is it a media type # Is it a media type
if len(value) == 2: extensions = mimetypes.guess_all_extensions(unicode(mimetype))
extensions = mimetypes.guess_all_extensions(unicode(mimetype)) for extension in extensions:
# we have an extension ext = u'*%s' % extension
if extensions: if ext not in list:
for extension in extensions: list.append(ext)
if list.find(extension) == -1: self.serviceManager.supportedSuffixes(extension[1:])
list += u'*%s ' % extension
self.serviceManager.supportedSuffixes(extension[1:])
mimetype = u''
return list, mimetype
def about(self): def about(self):
about_text = translate('MediaPlugin', '<strong>Media Plugin</strong>' about_text = translate('MediaPlugin', '<strong>Media Plugin</strong>'

View File

@ -254,9 +254,9 @@ class SongMediaItem(MediaManagerItem):
""" """
if self.searchAsYouType: if self.searchAsYouType:
search_length = 1 search_length = 1
if self.searchTextEdit.currentSearchType() == 1: if self.searchTextEdit.currentSearchType() == SongSearch.Entire:
search_length = 3 search_length = 3
elif self.searchTextEdit.currentSearchType() == 3: elif self.searchTextEdit.currentSearchType() == SongSearch.Lyrics:
search_length = 7 search_length = 7
if len(text) > search_length: if len(text) > search_length:
self.onSearchTextButtonClick() self.onSearchTextButtonClick()

View File

@ -245,6 +245,8 @@ class SongBeamerImport(SongImport):
self.song_number = u'' self.song_number = u''
elif tag_val[0] == u'#Speed': elif tag_val[0] == u'#Speed':
pass pass
elif tag_val[0] == u'Tempo':
pass
elif tag_val[0] == u'#TextAlign': elif tag_val[0] == u'#TextAlign':
pass pass
elif tag_val[0] == u'#Title': elif tag_val[0] == u'#Title':

View File

@ -299,9 +299,9 @@ class OpenLyrics(object):
# Remove chords from xml. # Remove chords from xml.
xml = re.compile(u'<chord name=".*?"/>').sub(u'', xml) xml = re.compile(u'<chord name=".*?"/>').sub(u'', xml)
song_xml = objectify.fromstring(xml) song_xml = objectify.fromstring(xml)
try: if hasattr(song_xml, u'properties'):
properties = song_xml.properties properties = song_xml.properties
except AttributeError: else:
return None return None
song = Song() song = Song()
self._process_copyright(properties, song) self._process_copyright(properties, song)
@ -369,13 +369,11 @@ class OpenLyrics(object):
The song object. The song object.
""" """
authors = [] authors = []
try: if hasattr(properties, u'authors'):
for author in properties.authors.author: for author in properties.authors.author:
display_name = self._text(author) display_name = self._text(author)
if display_name: if display_name:
authors.append(display_name) authors.append(display_name)
except AttributeError:
pass
if not authors: if not authors:
authors.append(SongStrings.AuthorUnknownUnT) authors.append(SongStrings.AuthorUnknownUnT)
for display_name in authors: for display_name in authors:
@ -399,10 +397,8 @@ class OpenLyrics(object):
``song`` ``song``
The song object. The song object.
""" """
try: if hasattr(properties, u'ccliNo'):
song.ccli_number = self._text(properties.ccliNo) song.ccli_number = self._text(properties.ccliNo)
except AttributeError:
song.ccli_number = u''
def _process_comments(self, properties, song): def _process_comments(self, properties, song):
""" """
@ -414,15 +410,13 @@ class OpenLyrics(object):
``song`` ``song``
The song object. The song object.
""" """
try: if hasattr(properties, u'comments'):
comments_list = [] comments_list = []
for comment in properties.comments.comment: for comment in properties.comments.comment:
commenttext = self._text(comment) commenttext = self._text(comment)
if commenttext: if commenttext:
comments_list.append(commenttext) comments_list.append(commenttext)
song.comments = u'\n'.join(comments_list) song.comments = u'\n'.join(comments_list)
except AttributeError:
song.comments = u''
def _process_copyright(self, properties, song): def _process_copyright(self, properties, song):
""" """
@ -434,10 +428,8 @@ class OpenLyrics(object):
``song`` ``song``
The song object. The song object.
""" """
try: if hasattr(properties, u'copyright'):
song.copyright = self._text(properties.copyright) song.copyright = self._text(properties.copyright)
except AttributeError:
song.copyright = u''
def _process_lyrics(self, properties, lyrics, song): def _process_lyrics(self, properties, lyrics, song):
""" """
@ -478,9 +470,9 @@ class OpenLyrics(object):
song.search_lyrics = search_text.lower() song.search_lyrics = search_text.lower()
song.lyrics = unicode(sxml.extract_xml(), u'utf-8') song.lyrics = unicode(sxml.extract_xml(), u'utf-8')
# Process verse order # Process verse order
try: if hasattr(properties, u'verseOrder'):
song.verse_order = self._text(properties.verseOrder) song.verse_order = self._text(properties.verseOrder)
except AttributeError: else:
# We have to process the temp_verse_order, as the verseOrder # We have to process the temp_verse_order, as the verseOrder
# property is not present. # property is not present.
previous_type = u'' previous_type = u''
@ -511,7 +503,7 @@ class OpenLyrics(object):
""" """
song.song_book_id = 0 song.song_book_id = 0
song.song_number = u'' song.song_number = u''
try: if hasattr(properties, u'songbooks'):
for songbook in properties.songbooks.songbook: for songbook in properties.songbooks.songbook:
bookname = self._get(songbook, u'name') bookname = self._get(songbook, u'name')
if bookname: if bookname:
@ -522,15 +514,10 @@ class OpenLyrics(object):
book = Book.populate(name=bookname, publisher=u'') book = Book.populate(name=bookname, publisher=u'')
self.manager.save_object(book) self.manager.save_object(book)
song.song_book_id = book.id song.song_book_id = book.id
try: if hasattr(songbook, u'entry'):
if self._get(songbook, u'entry'): song.song_number = self._get(songbook, u'entry')
song.song_number = self._get(songbook, u'entry')
except AttributeError:
pass
# We only support one song book, so take the first one. # We only support one song book, so take the first one.
break break
except AttributeError:
pass
def _process_titles(self, properties, song): def _process_titles(self, properties, song):
""" """
@ -563,7 +550,7 @@ class OpenLyrics(object):
``song`` ``song``
The song object. The song object.
""" """
try: if hasattr(properties, u'themes'):
for topictext in properties.themes.theme: for topictext in properties.themes.theme:
topictext = self._text(topictext) topictext = self._text(topictext)
if topictext: if topictext:
@ -574,8 +561,6 @@ class OpenLyrics(object):
topic = Topic.populate(name=topictext) topic = Topic.populate(name=topictext)
self.manager.save_object(topic) self.manager.save_object(topic)
song.topics.append(topic) song.topics.append(topic)
except AttributeError:
pass
def _dump_xml(self, xml): def _dump_xml(self, xml):
""" """