From 3cf6ac5c063f1c9aeaa26a536aeb3ec3a3ec4734 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Sat, 6 May 2017 19:40:31 +0400 Subject: [PATCH] Re-added SndUp's API key for audio uploads. Fixes #134 --- doc/changelog.md | 1 + src/Conf.defaults | 1 + src/controller/settings.py | 3 ++- src/extra/AudioUploader/audioUploader.py | 6 +++++- src/wxUI/dialogs/configuration.py | 7 ++++++- 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/doc/changelog.md b/doc/changelog.md index 8ce3dae9..74f91858 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -6,6 +6,7 @@ * Removed TwUp as service as it no longer exists. ([#112](https://github.com/manuelcortez/TWBlue/issues/112)) * Release audio files after uploading them. ([#130](https://github.com/manuelcortez/TWBlue/issues/130)) * Now TWBlue will use Yandex's translation services instead microsoft translator. ([#132](https://github.com/manuelcortez/TWBlue/issues/132)) +* SndUp users will be able to upload audio in their account by using their API Key again. ([#134](https://github.com/manuelcortez/TWBlue/issues/134)) ## Changes in version 0.90 diff --git a/src/Conf.defaults b/src/Conf.defaults index 6564076e..9c415648 100644 --- a/src/Conf.defaults +++ b/src/Conf.defaults @@ -25,6 +25,7 @@ current_soundpack = string(default="default") indicate_audio = boolean(default=True) indicate_geo = boolean(default=True) indicate_img = boolean(default=True) +sndup_api_key = string(default="") [other_buffers] timelines = list(default=list()) diff --git a/src/controller/settings.py b/src/controller/settings.py index ae8be63c..b8836d10 100644 --- a/src/controller/settings.py +++ b/src/controller/settings.py @@ -166,6 +166,7 @@ class accountSettingsController(globalSettingsController): self.dialog.set_value("sound", "indicate_geo", self.config["sound"]["indicate_geo"]) self.dialog.set_value("sound", "indicate_img", self.config["sound"]["indicate_img"]) self.dialog.create_extras(OCRSpace.translatable_langs) + self.dialog.set_value("extras", "sndup_apiKey", self.config["sound"]["sndup_api_key"]) self.dialog.realize() self.dialog.set_title(_(u"Account settings for %s") % (self.user,)) self.response = self.dialog.get_response() @@ -238,9 +239,9 @@ class accountSettingsController(globalSettingsController): self.config["sound"]["indicate_audio"] = self.dialog.get_value("sound", "indicate_audio") self.config["sound"]["indicate_geo"] = self.dialog.get_value("sound", "indicate_geo") self.config["sound"]["indicate_img"] = self.dialog.get_value("sound", "indicate_img") + self.config["sound"]["sndup_api_key"] = self.dialog.get_value("extras", "apiKey") self.buffer.session.sound.config = self.config["sound"] self.buffer.session.sound.check_soundpack() - self.config.write() def toggle_state(self,*args,**kwargs): diff --git a/src/extra/AudioUploader/audioUploader.py b/src/extra/AudioUploader/audioUploader.py index aa4d9549..8f812701 100644 --- a/src/extra/AudioUploader/audioUploader.py +++ b/src/extra/AudioUploader/audioUploader.py @@ -52,7 +52,11 @@ class audioUploader(object): self.uploaderDialog = wx_transfer_dialogs.UploadDialog(self.file) output.speak(_(u"Attaching...")) if self.dialog.get("services") == "SNDUp": - url = "http://sndup.net/post.php" + base_url = "http://sndup.net/post.php" + if len(self.config["sound"]["sndup_api_key"]) > 0: + url = base_url + '?apikey=' + self.config['sound']['sndup_api_key'] + else: + url = base_url self.uploaderFunction = transfer.Upload(obj=self, field='file', url=url, filename=self.file, completed_callback=completed_callback) pub.subscribe(self.uploaderDialog.update, "uploading") self.uploaderDialog.get_response(self.uploaderFunction.perform_threaded) diff --git a/src/wxUI/dialogs/configuration.py b/src/wxUI/dialogs/configuration.py index 9adbaf28..f45ff40c 100644 --- a/src/wxUI/dialogs/configuration.py +++ b/src/wxUI/dialogs/configuration.py @@ -304,7 +304,12 @@ class extrasPanel(wx.Panel): ocrLanguageSizer = wx.StaticBoxSizer(OCRBox, wx.HORIZONTAL) ocrLanguageSizer.Add(self.ocr_lang, 0, wx.ALL, 5) mainSizer.Add(ocrLanguageSizer, 0, wx.ALL, 5) - + lbl = wx.StaticText(self, wx.NewId(), _(u"API Key for SndUp")) + self.sndup_apiKey = wx.TextCtrl(self, -1) + sndupBox = wx.BoxSizer(wx.HORIZONTAL) + sndupBox.Add(lbl, 0, wx.ALL, 5) + sndupBox.Add(self.sndup_apiKey, 0, wx.ALL, 5) + mainSizer.Add(sndupBox, 0, wx.ALL, 5) self.SetSizer(mainSizer) class configurationDialog(baseDialog.BaseWXDialog):