Added audio uploading support in posts. Needs improvements to detect its ID3 tags
This commit is contained in:
parent
93e6cd36a7
commit
d71721ab87
@ -22,6 +22,7 @@ class attachFromLocal(object):
|
||||
self.type = "local"
|
||||
self.dialog = gui.attachDialog(voice_messages)
|
||||
widgetUtils.connect_event(self.dialog.photo, widgetUtils.BUTTON_PRESSED, self.upload_image)
|
||||
widgetUtils.connect_event(self.dialog.audio, widgetUtils.BUTTON_PRESSED, self.upload_audio)
|
||||
widgetUtils.connect_event(self.dialog.remove, widgetUtils.BUTTON_PRESSED, self.remove_attachment)
|
||||
self.dialog.get_response()
|
||||
log.debug("Attachments controller started.")
|
||||
@ -40,6 +41,18 @@ class attachFromLocal(object):
|
||||
self.dialog.attachments.insert_item(False, *info)
|
||||
self.dialog.remove.Enable(True)
|
||||
|
||||
def upload_audio(self, *args, **kwargs):
|
||||
audio = self.dialog.get_audio()
|
||||
if audio != None:
|
||||
# Define data structure for this attachment, as will be required by VK API later.
|
||||
audioInfo = {"type": "audio", "file": audio}
|
||||
log.debug("Audio data to upload: %r" % (audioInfo,))
|
||||
self.attachments.append(audioInfo)
|
||||
# Translators: This is the text displayed in the attachments dialog, when the user adds a photo.
|
||||
info = [_(u"Audio file"), os.path.basename(audio)]
|
||||
self.dialog.attachments.insert_item(False, *info)
|
||||
self.dialog.remove.Enable(True)
|
||||
|
||||
def remove_attachment(self, *args, **kwargs):
|
||||
""" Remove the currently focused item from the attachments list."""
|
||||
current_item = self.dialog.attachments.get_selected()
|
||||
|
@ -146,6 +146,13 @@ class baseBuffer(object):
|
||||
id = r[0]["id"]
|
||||
owner_id = r[0]["owner_id"]
|
||||
local_attachments += "photo{0}_{1},".format(owner_id, id)
|
||||
|
||||
elif i["type"] == "audio":
|
||||
audio = i["file"]
|
||||
r = uploader.audio(audio, "untitled", "untitled")
|
||||
id = r["id"]
|
||||
owner_id = r["owner_id"]
|
||||
local_attachments += "audio{0}_{1},".format(owner_id, id)
|
||||
return local_attachments
|
||||
|
||||
def connect_events(self):
|
||||
|
@ -49,3 +49,9 @@ class attachDialog(widgetUtils.BaseDialog):
|
||||
result = dlg.GetValue()
|
||||
dlg.Destroy()
|
||||
return result
|
||||
|
||||
def get_audio(self):
|
||||
openFileDialog = wx.FileDialog(self, _(u"Select the audio file to be uploaded"), "", "", _("Audio files (*.mp3)|*.mp3"), wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
|
||||
if openFileDialog.ShowModal() == wx.ID_CANCEL:
|
||||
return None
|
||||
return openFileDialog.GetPath()
|
||||
|
Loading…
Reference in New Issue
Block a user