Added a FileDialog for choosing the filename in audio downloads

This commit is contained in:
Manuel Cortez 2016-02-18 17:16:43 -06:00
parent 79917560f2
commit 34cbfb2251
2 changed files with 3 additions and 2 deletions

View File

@ -212,7 +212,7 @@ class audio(postController):
f = u"{0} - {1}.mp3".format(self.post["title"], self.post["artist"]) f = u"{0} - {1}.mp3".format(self.post["title"], self.post["artist"])
path = self.dialog.get_destination_path(f) path = self.dialog.get_destination_path(f)
if path != None: 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): def play(self, *args, **kwargs):
pub.sendMessage("play-audio", audio_object=self.post["url"]) pub.sendMessage("play-audio", audio_object=self.post["url"])

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import os
import requests import requests
import re import re
@ -46,7 +47,7 @@ def download_file(url, local_filename, window):
dl += len(chunk) dl += len(chunk)
f.write(chunk) f.write(chunk)
done = int(100 * dl / total_length) 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(msg)
window.change_status(_(u"Ready")) window.change_status(_(u"Ready"))
return local_filename return local_filename