diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 20ebe6176..bb7710e91 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -822,7 +822,7 @@ class ThemeManager(QtWidgets.QWidget, RegistryBase, Ui_ThemeManager, LogMixin, R plugin_usage = "{plug}{text}".format(plug=plugin_usage, text=(translate('OpenLP.ThemeManager', '{count} time(s) by {plugin}' - ).format(name=used_count, + ).format(count=used_count, plugin=plugin.name))) plugin_usage = "{text}\n".format(text=plugin_usage) if plugin_usage: diff --git a/openlp/plugins/songs/lib/importers/openlp.py b/openlp/plugins/songs/lib/importers/openlp.py index 49a4f38dc..9bb44becf 100644 --- a/openlp/plugins/songs/lib/importers/openlp.py +++ b/openlp/plugins/songs/lib/importers/openlp.py @@ -23,6 +23,7 @@ The :mod:`openlp` module provides the functionality for importing OpenLP song databases into the current installation database. """ import logging +from pathlib import Path from sqlalchemy import MetaData, Table, create_engine from sqlalchemy.orm import class_mapper, mapper, relation, scoped_session, sessionmaker @@ -271,12 +272,18 @@ class OpenLPSongImport(SongImport): # Find or create all the media files and add them to the new song object if has_media_files and song.media_files: for media_file in song.media_files: + # Database now uses paths rather than strings for media files, and the key name has + # changed appropriately. This catches any databases using the old key name. + try: + media_path = media_file.file_path + except Exception: + media_path = Path(media_file.file_name) existing_media_file = self.manager.get_object_filtered( - MediaFile, MediaFile.file_path == media_file.file_path) + MediaFile, MediaFile.file_path == media_path) if existing_media_file: new_song.media_files.append(existing_media_file) else: - new_song.media_files.append(MediaFile.populate(file_name=media_file.file_name)) + new_song.media_files.append(MediaFile.populate(file_path=media_path)) clean_song(self.manager, new_song) self.manager.save_object(new_song) if progress_dialog: