forked from openlp/openlp
Fixed up audio file import from version 1.2, plus a few bits I missed from renaming things.
This commit is contained in:
parent
906b0fe67e
commit
017359ff5c
@ -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:
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user