diff --git a/openlp/plugins/songs/lib/songselect.py b/openlp/plugins/songs/lib/songselect.py index 0a59c7420..788139988 100644 --- a/openlp/plugins/songs/lib/songselect.py +++ b/openlp/plugins/songs/lib/songselect.py @@ -182,7 +182,7 @@ class SongSelectImport(object): except (TypeError, URLError) as error: log.exception('Could not get song from SongSelect, {error}'.format(error=error)) return None - lyrics_link = song_page.find('a', title='View song lyrics')['href'] + lyrics_link = song_page.find('section', 'page-section').find('a')['href'] if callback: callback() try: @@ -192,15 +192,13 @@ class SongSelectImport(object): return None if callback: callback() - copyright_elements = [] theme_elements = [] - copyrights_regex = re.compile(r'\bCopyrights\b') + # Themes regex only works if the ccli site is in english. themes_regex = re.compile(r'\bThemes\b') for ul in song_page.find_all('ul', 'song-meta-list'): - if ul.find('li', string=copyrights_regex): - copyright_elements.extend(ul.find_all('li')[1:]) if ul.find('li', string=themes_regex): theme_elements.extend(ul.find_all('li')[1:]) + copyright_elements = lyrics_page.find('ul', 'copyright').find_all('li') author_elements = song_page.find('div', 'content-title').find('ul', 'authors').find_all('li') song['title'] = unescape(song_page.find('div', 'content-title').find('h1').string.strip()) song['authors'] = [unescape(li.find('a').string).strip() for li in author_elements] diff --git a/tests/functional/openlp_plugins/songs/test_songselect.py b/tests/functional/openlp_plugins/songs/test_songselect.py index fe6805a16..cf4b9b31c 100644 --- a/tests/functional/openlp_plugins/songs/test_songselect.py +++ b/tests/functional/openlp_plugins/songs/test_songselect.py @@ -314,13 +314,12 @@ class TestSongSelectImport(TestCase, TestMixin):
- +
+ +
- ''' fake_lyrics_page = ''' @@ -330,6 +329,9 @@ class TestSongSelectImport(TestCase, TestMixin):

Verse 2

verse thing 2

+ ''' mocked_get_page.side_effect = [fake_song_page, fake_lyrics_page]