forked from openlp/openlp
Merge branch 'CCLI-fixes' into 'master'
CCLI fixes Closes #245 See merge request openlp/openlp!132
This commit is contained in:
commit
0a22c7f77a
@ -344,7 +344,9 @@ class SongSelectForm(QtWidgets.QDialog, Ui_SongSelectDialog, RegistryProperties)
|
|||||||
self.song_count += 1
|
self.song_count += 1
|
||||||
self.result_count_label.setText(translate('SongsPlugin.SongSelectForm',
|
self.result_count_label.setText(translate('SongsPlugin.SongSelectForm',
|
||||||
'Found {count:d} song(s)').format(count=self.song_count))
|
'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 = QtWidgets.QListWidgetItem(item_title, self.search_results_widget)
|
||||||
song_item.setData(QtCore.Qt.UserRole, song)
|
song_item.setData(QtCore.Qt.UserRole, song)
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ class SongSelectImport(object):
|
|||||||
songs = []
|
songs = []
|
||||||
while self.run_search:
|
while self.run_search:
|
||||||
if current_page > 1:
|
if current_page > 1:
|
||||||
params['page'] = current_page
|
params['CurrentPage'] = current_page
|
||||||
try:
|
try:
|
||||||
results_page = BeautifulSoup(self.opener.open(SEARCH_URL + '?' + urlencode(params)).read(), 'lxml')
|
results_page = BeautifulSoup(self.opener.open(SEARCH_URL + '?' + urlencode(params)).read(), 'lxml')
|
||||||
search_results = results_page.find_all('div', 'song-result')
|
search_results = results_page.find_all('div', 'song-result')
|
||||||
@ -196,9 +196,14 @@ class SongSelectImport(object):
|
|||||||
songs.append(song)
|
songs.append(song)
|
||||||
break
|
break
|
||||||
for result in search_results:
|
for result in search_results:
|
||||||
|
authors = result.find('p', 'song-result-subtitle').string
|
||||||
|
if authors:
|
||||||
|
authors = unescape(authors).strip().split(', ')
|
||||||
|
else:
|
||||||
|
authors = ""
|
||||||
song = {
|
song = {
|
||||||
'title': unescape(result.find('p', 'song-result-title').find('a').string).strip(),
|
'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']
|
'link': BASE_URL + result.find('p', 'song-result-title').find('a')['href']
|
||||||
}
|
}
|
||||||
if callback:
|
if callback:
|
||||||
|
@ -246,15 +246,15 @@ class TestSongSelectImport(TestCase, TestMixin):
|
|||||||
# first search result
|
# first search result
|
||||||
mocked_result1 = MagicMock()
|
mocked_result1 = MagicMock()
|
||||||
mocked_result1.find.side_effect = [
|
mocked_result1.find.side_effect = [
|
||||||
MagicMock(find=MagicMock(return_value=MagicMock(string='Title 1'))),
|
|
||||||
MagicMock(string='James, John'),
|
MagicMock(string='James, John'),
|
||||||
|
MagicMock(find=MagicMock(return_value=MagicMock(string='Title 1'))),
|
||||||
MagicMock(find=MagicMock(return_value={'href': '/url1'}))
|
MagicMock(find=MagicMock(return_value={'href': '/url1'}))
|
||||||
]
|
]
|
||||||
# second search result
|
# second search result
|
||||||
mocked_result2 = MagicMock()
|
mocked_result2 = MagicMock()
|
||||||
mocked_result2.find.side_effect = [
|
mocked_result2.find.side_effect = [
|
||||||
MagicMock(find=MagicMock(return_value=MagicMock(string='Title 2'))),
|
|
||||||
MagicMock(string='Philip'),
|
MagicMock(string='Philip'),
|
||||||
|
MagicMock(find=MagicMock(return_value=MagicMock(string='Title 2'))),
|
||||||
MagicMock(find=MagicMock(return_value={'href': '/url2'}))
|
MagicMock(find=MagicMock(return_value={'href': '/url2'}))
|
||||||
]
|
]
|
||||||
# rest of the stuff
|
# rest of the stuff
|
||||||
@ -291,22 +291,22 @@ class TestSongSelectImport(TestCase, TestMixin):
|
|||||||
# first search result
|
# first search result
|
||||||
mocked_result1 = MagicMock()
|
mocked_result1 = MagicMock()
|
||||||
mocked_result1.find.side_effect = [
|
mocked_result1.find.side_effect = [
|
||||||
MagicMock(find=MagicMock(return_value=MagicMock(string='Title 1'))),
|
|
||||||
MagicMock(string='James, John'),
|
MagicMock(string='James, John'),
|
||||||
|
MagicMock(find=MagicMock(return_value=MagicMock(string='Title 1'))),
|
||||||
MagicMock(find=MagicMock(return_value={'href': '/url1'}))
|
MagicMock(find=MagicMock(return_value={'href': '/url1'}))
|
||||||
]
|
]
|
||||||
# second search result
|
# second search result
|
||||||
mocked_result2 = MagicMock()
|
mocked_result2 = MagicMock()
|
||||||
mocked_result2.find.side_effect = [
|
mocked_result2.find.side_effect = [
|
||||||
MagicMock(find=MagicMock(return_value=MagicMock(string='Title 2'))),
|
|
||||||
MagicMock(string='Philip'),
|
MagicMock(string='Philip'),
|
||||||
|
MagicMock(find=MagicMock(return_value=MagicMock(string='Title 2'))),
|
||||||
MagicMock(find=MagicMock(return_value={'href': '/url2'}))
|
MagicMock(find=MagicMock(return_value={'href': '/url2'}))
|
||||||
]
|
]
|
||||||
# third search result
|
# third search result
|
||||||
mocked_result3 = MagicMock()
|
mocked_result3 = MagicMock()
|
||||||
mocked_result3.find.side_effect = [
|
mocked_result3.find.side_effect = [
|
||||||
MagicMock(find=MagicMock(return_value=MagicMock(string='Title 3'))),
|
|
||||||
MagicMock(string='Luke, Matthew'),
|
MagicMock(string='Luke, Matthew'),
|
||||||
|
MagicMock(find=MagicMock(return_value=MagicMock(string='Title 3'))),
|
||||||
MagicMock(find=MagicMock(return_value={'href': '/url3'}))
|
MagicMock(find=MagicMock(return_value={'href': '/url3'}))
|
||||||
]
|
]
|
||||||
# rest of the stuff
|
# rest of the stuff
|
||||||
|
Loading…
Reference in New Issue
Block a user