Download audio files support from the details dialogue for songs
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import utils
|
||||
import widgetUtils
|
||||
import messages
|
||||
import buffers
|
||||
from pubsub import pub
|
||||
from mysc.repeating_timer import RepeatingTimer
|
||||
from mysc.thread_utils import call_threaded
|
||||
from sessionmanager import session
|
||||
from wxUI import (mainWindow)
|
||||
|
||||
@@ -39,6 +41,7 @@ class Controller(object):
|
||||
self.buffers.append(audio)
|
||||
self.window.add_buffer(audio.tab, _(u"My audios"))
|
||||
pub.subscribe(self.in_post, "posted")
|
||||
pub.subscribe(self.download, "download-file")
|
||||
|
||||
def login(self):
|
||||
self.window.change_status(_(u"Logging in VK"))
|
||||
@@ -60,4 +63,7 @@ class Controller(object):
|
||||
for i in self.buffers:
|
||||
if hasattr(i, "get_items"):
|
||||
i.get_items()
|
||||
print "executed for %s" % (i.name)
|
||||
print "executed for %s" % (i.name)
|
||||
|
||||
def download(self, url, filename):
|
||||
call_threaded(utils.download_file, url, filename, self.window)
|
@@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
import arrow
|
||||
import messages
|
||||
import languageHandler
|
||||
@@ -193,6 +194,7 @@ class audio(postController):
|
||||
self.post = postObject
|
||||
self.dialog = postDialogs.audio()
|
||||
self.fill_information()
|
||||
widgetUtils.connect_event(self.dialog.download, widgetUtils.BUTTON_PRESSED, self.download)
|
||||
|
||||
def fill_information(self):
|
||||
if self.post.has_key("artist"):
|
||||
@@ -207,4 +209,10 @@ class audio(postController):
|
||||
def get_lyrics(self):
|
||||
if self.post.has_key("lyrics_id"):
|
||||
l = self.session.vk.client.audio.getLyrics(lyrics_id=int(self.post["lyrics_id"]))
|
||||
self.dialog.set("lyric", l["text"])
|
||||
self.dialog.set("lyric", l["text"])
|
||||
|
||||
def download(self, *args, **kwargs):
|
||||
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)
|
Reference in New Issue
Block a user