forked from openlp/openlp
Don't duplicate songs if a single author contains a comma
This commit is contained in:
parent
099b62f233
commit
f3b7e609e9
@ -467,23 +467,20 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
search_results = self.plugin.manager.get_all_objects(Song,
|
search_results = self.plugin.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())
|
||||||
author_list = item.data_string[u'authors'].split(u', ')
|
|
||||||
editId = 0
|
editId = 0
|
||||||
add_song = True
|
add_song = True
|
||||||
if search_results:
|
if search_results:
|
||||||
for song in search_results:
|
for song in search_results:
|
||||||
|
author_list = item.data_string[u'authors']
|
||||||
same_authors = True
|
same_authors = True
|
||||||
# If the author counts are different, we do not have to do any
|
|
||||||
# further checking.
|
|
||||||
if len(song.authors) == len(author_list):
|
|
||||||
for author in song.authors:
|
for author in song.authors:
|
||||||
if author.display_name not in author_list:
|
if author.display_name in author_list:
|
||||||
same_authors = False
|
author_list = author_list.replace(author.display_name,
|
||||||
|
u'', 1)
|
||||||
else:
|
else:
|
||||||
same_authors = False
|
same_authors = False
|
||||||
# All authors are the same, so we can stop here and the song
|
break
|
||||||
# does not have to be saved.
|
if same_authors and author_list.strip(u', ') == u'':
|
||||||
if same_authors:
|
|
||||||
add_song = False
|
add_song = False
|
||||||
editId = song.id
|
editId = song.id
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user