From 017359ff5c280239d920e9f89a9f681b9068e6fd Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Mon, 12 Sep 2011 18:35:32 +0200 Subject: [PATCH] Fixed up audio file import from version 1.2, plus a few bits I missed from renaming things. --- openlp/plugins/songs/forms/songimportform.py | 6 +++--- openlp/plugins/songs/lib/olp1import.py | 5 +++-- openlp/plugins/songs/lib/songimport.py | 13 +++++++------ openlp/plugins/songs/songsplugin.py | 4 ++-- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 52524b838..6f09c9b8c 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -686,7 +686,7 @@ class SongImportForm(OpenLPWizard): def performWizard(self): """ Perform the actual import. This method pulls in the correct importer - class, and then runs the ``do_import`` method of the importer to do + class, and then runs the ``doImport`` method of the importer to do the actual importing. """ source_format = self.formatComboBox.currentIndex() @@ -759,8 +759,8 @@ class SongImportForm(OpenLPWizard): importer = self.plugin.importSongs(SongFormat.FoilPresenter, filenames=self.getListOfFiles(self.foilPresenterFileListWidget) ) - importer.do_import() - if importer.error_log: + importer.doImport() + if importer.errorLog: self.progressLabel.setText(translate( 'SongsPlugin.SongImportForm', 'Your song import failed.')) else: diff --git a/openlp/plugins/songs/lib/olp1import.py b/openlp/plugins/songs/lib/olp1import.py index cd12ca937..72bd5f952 100644 --- a/openlp/plugins/songs/lib/olp1import.py +++ b/openlp/plugins/songs/lib/olp1import.py @@ -33,6 +33,7 @@ import logging from chardet.universaldetector import UniversalDetector import sqlite import sys +import os from openlp.core.lib import translate from openlp.plugins.songs.lib import retrieve_windows_encoding @@ -131,8 +132,8 @@ class OpenLP1SongImport(SongImport): if self.stopImportFlag: break if new_db: - cursor.execute(u'-- types int, unicode, int') - cursor.execute(u'SELECT trackid, fulltrackname, listindex ' + cursor.execute(u'-- types int, int') + cursor.execute(u'SELECT trackid, listindex ' u'FROM songtracks ' u'WHERE songid = %s ORDER BY listindex' % song_id) track_ids = cursor.fetchall() diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport.py index 7afe6b054..ee6c7da41 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport.py @@ -359,7 +359,7 @@ class SongImport(QtCore.QObject): MediaFile.file_name == filename) if not media_file: if os.path.dirname(filename): - filename = self.copyMediaFile(filename) + filename = self.copyMediaFile(song.id, filename) song.media_files.append( MediaFile.populate(file_name=filename, weight=weight) ) @@ -367,7 +367,7 @@ class SongImport(QtCore.QObject): self.setDefaults() return True - def copyMediaFile(self, filename): + def copyMediaFile(self, song_id, filename): """ This method copies the media file to the correct location and returns the new file location. @@ -377,12 +377,13 @@ class SongImport(QtCore.QObject): """ if not hasattr(self, u'save_path'): self.save_path = os.path.join( - AppLocation.get_section_data_path(self.mediaitem.plugin.name), - 'audio', str(self.song.id)) + AppLocation.get_section_data_path( + self.importWizard.plugin.name), + 'audio', str(song_id)) if not os.path.exists(self.save_path): os.makedirs(self.save_path) - if not filename.startswith(save_path): - oldfile, filename = filename, os.path.join(save_path, + if not filename.startswith(self.save_path): + oldfile, filename = filename, os.path.join(self.save_path, os.path.split(filename)[1]) shutil.copyfile(oldfile, filename) return filename diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index f2bf36790..54b1d3f1f 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -196,7 +196,7 @@ class SongsPlugin(Plugin): def importSongs(self, format, **kwargs): class_ = SongFormat.get_class(format) importer = class_(self.manager, **kwargs) - importer.register(self.mediaItem.import_wizard) + importer.register(self.mediaItem.importWizard) return importer def setPluginTextStrings(self): @@ -252,7 +252,7 @@ class SongsPlugin(Plugin): progress.setValue(idx) Receiver.send_message(u'openlp_process_events') importer = OpenLPSongImport(self.manager, filename=db) - importer.do_import() + importer.doImport() progress.setValue(len(song_dbs)) self.mediaItem.onSearchTextButtonClick()