forked from openlp/openlp
try to avoid duplicates when opening an old service file
This commit is contained in:
parent
e2bd77ea4d
commit
a031784146
|
@ -416,6 +416,16 @@ class SongMediaItem(MediaManagerItem):
|
||||||
log.debug(u'serviceLoad')
|
log.debug(u'serviceLoad')
|
||||||
if self.plugin.status != PluginStatus.Active or not item.data_string:
|
if self.plugin.status != PluginStatus.Active or not item.data_string:
|
||||||
return
|
return
|
||||||
|
if item.data_string[u'title'].find(u'@') == -1:
|
||||||
|
# This file seems to be an old one, which means, that the search
|
||||||
|
# title (data_string[u'title']) is probably wrong. We add "@" to
|
||||||
|
# search title and hope that we do not add any duplicate. This
|
||||||
|
# should work for songs without alternate title.
|
||||||
|
search_results = self.parent.manager.get_all_objects(Song,
|
||||||
|
Song.search_title == (re.compile(r'\W+', re.UNICODE).sub(u' ',
|
||||||
|
item.data_string[u'title'].strip()) + u'@'),
|
||||||
|
Song.search_title.asc())
|
||||||
|
else:
|
||||||
search_results = self.parent.manager.get_all_objects(Song,
|
search_results = self.parent.manager.get_all_objects(Song,
|
||||||
Song.search_title == item.data_string[u'title'],
|
Song.search_title == item.data_string[u'title'],
|
||||||
Song.search_title.asc())
|
Song.search_title.asc())
|
||||||
|
|
Loading…
Reference in New Issue