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):
|
def performWizard(self):
|
||||||
"""
|
"""
|
||||||
Perform the actual import. This method pulls in the correct importer
|
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.
|
the actual importing.
|
||||||
"""
|
"""
|
||||||
source_format = self.formatComboBox.currentIndex()
|
source_format = self.formatComboBox.currentIndex()
|
||||||
@ -759,8 +759,8 @@ class SongImportForm(OpenLPWizard):
|
|||||||
importer = self.plugin.importSongs(SongFormat.FoilPresenter,
|
importer = self.plugin.importSongs(SongFormat.FoilPresenter,
|
||||||
filenames=self.getListOfFiles(self.foilPresenterFileListWidget)
|
filenames=self.getListOfFiles(self.foilPresenterFileListWidget)
|
||||||
)
|
)
|
||||||
importer.do_import()
|
importer.doImport()
|
||||||
if importer.error_log:
|
if importer.errorLog:
|
||||||
self.progressLabel.setText(translate(
|
self.progressLabel.setText(translate(
|
||||||
'SongsPlugin.SongImportForm', 'Your song import failed.'))
|
'SongsPlugin.SongImportForm', 'Your song import failed.'))
|
||||||
else:
|
else:
|
||||||
|
@ -33,6 +33,7 @@ import logging
|
|||||||
from chardet.universaldetector import UniversalDetector
|
from chardet.universaldetector import UniversalDetector
|
||||||
import sqlite
|
import sqlite
|
||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
from openlp.core.lib import translate
|
from openlp.core.lib import translate
|
||||||
from openlp.plugins.songs.lib import retrieve_windows_encoding
|
from openlp.plugins.songs.lib import retrieve_windows_encoding
|
||||||
@ -131,8 +132,8 @@ class OpenLP1SongImport(SongImport):
|
|||||||
if self.stopImportFlag:
|
if self.stopImportFlag:
|
||||||
break
|
break
|
||||||
if new_db:
|
if new_db:
|
||||||
cursor.execute(u'-- types int, unicode, int')
|
cursor.execute(u'-- types int, int')
|
||||||
cursor.execute(u'SELECT trackid, fulltrackname, listindex '
|
cursor.execute(u'SELECT trackid, listindex '
|
||||||
u'FROM songtracks '
|
u'FROM songtracks '
|
||||||
u'WHERE songid = %s ORDER BY listindex' % song_id)
|
u'WHERE songid = %s ORDER BY listindex' % song_id)
|
||||||
track_ids = cursor.fetchall()
|
track_ids = cursor.fetchall()
|
||||||
|
@ -359,7 +359,7 @@ class SongImport(QtCore.QObject):
|
|||||||
MediaFile.file_name == filename)
|
MediaFile.file_name == filename)
|
||||||
if not media_file:
|
if not media_file:
|
||||||
if os.path.dirname(filename):
|
if os.path.dirname(filename):
|
||||||
filename = self.copyMediaFile(filename)
|
filename = self.copyMediaFile(song.id, filename)
|
||||||
song.media_files.append(
|
song.media_files.append(
|
||||||
MediaFile.populate(file_name=filename, weight=weight)
|
MediaFile.populate(file_name=filename, weight=weight)
|
||||||
)
|
)
|
||||||
@ -367,7 +367,7 @@ class SongImport(QtCore.QObject):
|
|||||||
self.setDefaults()
|
self.setDefaults()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def copyMediaFile(self, filename):
|
def copyMediaFile(self, song_id, filename):
|
||||||
"""
|
"""
|
||||||
This method copies the media file to the correct location and returns
|
This method copies the media file to the correct location and returns
|
||||||
the new file location.
|
the new file location.
|
||||||
@ -377,12 +377,13 @@ class SongImport(QtCore.QObject):
|
|||||||
"""
|
"""
|
||||||
if not hasattr(self, u'save_path'):
|
if not hasattr(self, u'save_path'):
|
||||||
self.save_path = os.path.join(
|
self.save_path = os.path.join(
|
||||||
AppLocation.get_section_data_path(self.mediaitem.plugin.name),
|
AppLocation.get_section_data_path(
|
||||||
'audio', str(self.song.id))
|
self.importWizard.plugin.name),
|
||||||
|
'audio', str(song_id))
|
||||||
if not os.path.exists(self.save_path):
|
if not os.path.exists(self.save_path):
|
||||||
os.makedirs(self.save_path)
|
os.makedirs(self.save_path)
|
||||||
if not filename.startswith(save_path):
|
if not filename.startswith(self.save_path):
|
||||||
oldfile, filename = filename, os.path.join(save_path,
|
oldfile, filename = filename, os.path.join(self.save_path,
|
||||||
os.path.split(filename)[1])
|
os.path.split(filename)[1])
|
||||||
shutil.copyfile(oldfile, filename)
|
shutil.copyfile(oldfile, filename)
|
||||||
return filename
|
return filename
|
||||||
|
@ -196,7 +196,7 @@ class SongsPlugin(Plugin):
|
|||||||
def importSongs(self, format, **kwargs):
|
def importSongs(self, format, **kwargs):
|
||||||
class_ = SongFormat.get_class(format)
|
class_ = SongFormat.get_class(format)
|
||||||
importer = class_(self.manager, **kwargs)
|
importer = class_(self.manager, **kwargs)
|
||||||
importer.register(self.mediaItem.import_wizard)
|
importer.register(self.mediaItem.importWizard)
|
||||||
return importer
|
return importer
|
||||||
|
|
||||||
def setPluginTextStrings(self):
|
def setPluginTextStrings(self):
|
||||||
@ -252,7 +252,7 @@ class SongsPlugin(Plugin):
|
|||||||
progress.setValue(idx)
|
progress.setValue(idx)
|
||||||
Receiver.send_message(u'openlp_process_events')
|
Receiver.send_message(u'openlp_process_events')
|
||||||
importer = OpenLPSongImport(self.manager, filename=db)
|
importer = OpenLPSongImport(self.manager, filename=db)
|
||||||
importer.do_import()
|
importer.doImport()
|
||||||
progress.setValue(len(song_dbs))
|
progress.setValue(len(song_dbs))
|
||||||
self.mediaItem.onSearchTextButtonClick()
|
self.mediaItem.onSearchTextButtonClick()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user