From 34cbfb2251090efcbaece4a02520ab5d7e15ba36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Cort=C3=A9z?= Date: Thu, 18 Feb 2016 17:16:43 -0600 Subject: [PATCH] Added a FileDialog for choosing the filename in audio downloads --- src/controller/posts.py | 2 +- src/utils.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/controller/posts.py b/src/controller/posts.py index 6a5a37e..4d5eff6 100644 --- a/src/controller/posts.py +++ b/src/controller/posts.py @@ -212,7 +212,7 @@ class audio(postController): f = u"{0} - {1}.mp3".format(self.post["title"], self.post["artist"]) path = self.dialog.get_destination_path(f) if path != None: - pub.sendMessage("download-file", url=self.post["url"], filename=f) + pub.sendMessage("download-file", url=self.post["url"], filename=path) def play(self, *args, **kwargs): pub.sendMessage("play-audio", audio_object=self.post["url"]) diff --git a/src/utils.py b/src/utils.py index 2f46004..4cbd8f7 100644 --- a/src/utils.py +++ b/src/utils.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +import os import requests import re @@ -46,7 +47,7 @@ def download_file(url, local_filename, window): dl += len(chunk) f.write(chunk) done = int(100 * dl / total_length) - msg = _(u"Downloading {0} ({1}%)").format(local_filename, done) + msg = _(u"Downloading {0} ({1}%)").format(os.path.basename(local_filename), done) window.change_status(msg) window.change_status(_(u"Ready")) return local_filename \ No newline at end of file