Merge branch 'CCLI-fixes' into 'master'

CCLI fixes

Closes #245

See merge request openlp/openlp!132
This commit is contained in:
Raoul Snyman 2020-02-10 21:29:31 +00:00
commit 0a22c7f77a
3 changed files with 15 additions and 8 deletions

View File

@ -344,7 +344,9 @@ class SongSelectForm(QtWidgets.QDialog, Ui_SongSelectDialog, RegistryProperties)
self.song_count += 1
self.result_count_label.setText(translate('SongsPlugin.SongSelectForm',
'Found {count:d} song(s)').format(count=self.song_count))
item_title = song['title'] + ' (' + ', '.join(song['authors']) + ')'
item_title = song['title']
if song['authors']:
item_title += ' (' + ', '.join(song['authors']) + ')'
song_item = QtWidgets.QListWidgetItem(item_title, self.search_results_widget)
song_item.setData(QtCore.Qt.UserRole, song)

View File

@ -175,7 +175,7 @@ class SongSelectImport(object):
songs = []
while self.run_search:
if current_page > 1:
params['page'] = current_page
params['CurrentPage'] = current_page
try:
results_page = BeautifulSoup(self.opener.open(SEARCH_URL + '?' + urlencode(params)).read(), 'lxml')
search_results = results_page.find_all('div', 'song-result')
@ -196,9 +196,14 @@ class SongSelectImport(object):
songs.append(song)
break
for result in search_results:
authors = result.find('p', 'song-result-subtitle').string
if authors:
authors = unescape(authors).strip().split(', ')
else:
authors = ""
song = {
'title': unescape(result.find('p', 'song-result-title').find('a').string).strip(),
'authors': unescape(result.find('p', 'song-result-subtitle').string).strip().split(', '),
'authors': authors,
'link': BASE_URL + result.find('p', 'song-result-title').find('a')['href']
}
if callback:

View File

@ -246,15 +246,15 @@ class TestSongSelectImport(TestCase, TestMixin):
# first search result
mocked_result1 = MagicMock()
mocked_result1.find.side_effect = [
MagicMock(find=MagicMock(return_value=MagicMock(string='Title 1'))),
MagicMock(string='James, John'),
MagicMock(find=MagicMock(return_value=MagicMock(string='Title 1'))),
MagicMock(find=MagicMock(return_value={'href': '/url1'}))
]
# second search result
mocked_result2 = MagicMock()
mocked_result2.find.side_effect = [
MagicMock(find=MagicMock(return_value=MagicMock(string='Title 2'))),
MagicMock(string='Philip'),
MagicMock(find=MagicMock(return_value=MagicMock(string='Title 2'))),
MagicMock(find=MagicMock(return_value={'href': '/url2'}))
]
# rest of the stuff
@ -291,22 +291,22 @@ class TestSongSelectImport(TestCase, TestMixin):
# first search result
mocked_result1 = MagicMock()
mocked_result1.find.side_effect = [
MagicMock(find=MagicMock(return_value=MagicMock(string='Title 1'))),
MagicMock(string='James, John'),
MagicMock(find=MagicMock(return_value=MagicMock(string='Title 1'))),
MagicMock(find=MagicMock(return_value={'href': '/url1'}))
]
# second search result
mocked_result2 = MagicMock()
mocked_result2.find.side_effect = [
MagicMock(find=MagicMock(return_value=MagicMock(string='Title 2'))),
MagicMock(string='Philip'),
MagicMock(find=MagicMock(return_value=MagicMock(string='Title 2'))),
MagicMock(find=MagicMock(return_value={'href': '/url2'}))
]
# third search result
mocked_result3 = MagicMock()
mocked_result3.find.side_effect = [
MagicMock(find=MagicMock(return_value=MagicMock(string='Title 3'))),
MagicMock(string='Luke, Matthew'),
MagicMock(find=MagicMock(return_value=MagicMock(string='Title 3'))),
MagicMock(find=MagicMock(return_value={'href': '/url3'}))
]
# rest of the stuff