Added album load an creation at startup
This commit is contained in:
parent
47bab9d2c4
commit
b278c8cde9
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
import time
|
||||||
import os
|
import os
|
||||||
import wx
|
import wx
|
||||||
import utils
|
import utils
|
||||||
@ -17,7 +18,7 @@ from mysc.thread_utils import call_threaded
|
|||||||
from sessionmanager import session
|
from sessionmanager import session
|
||||||
from wxUI import (mainWindow, commonMessages)
|
from wxUI import (mainWindow, commonMessages)
|
||||||
from wxUI.dialogs import search as searchDialogs
|
from wxUI.dialogs import search as searchDialogs
|
||||||
from wxUI.dialogs import timeline
|
from wxUI.dialogs import timeline, creation
|
||||||
from update import updater
|
from update import updater
|
||||||
|
|
||||||
log = logging.getLogger("controller.main")
|
log = logging.getLogger("controller.main")
|
||||||
@ -71,6 +72,10 @@ class Controller(object):
|
|||||||
audios = buffers.empty(parent=self.window.tb, name="audios")
|
audios = buffers.empty(parent=self.window.tb, name="audios")
|
||||||
self.buffers.append(audios)
|
self.buffers.append(audios)
|
||||||
self.window.add_buffer(audios.tab, _(u"Music"))
|
self.window.add_buffer(audios.tab, _(u"Music"))
|
||||||
|
albums = buffers.empty(parent=self.window.tb, name="albums")
|
||||||
|
self.buffers.append(albums)
|
||||||
|
self.window.insert_buffer(albums.tab, _(u"Albums"), self.window.search("audios"))
|
||||||
|
|
||||||
audio = buffers.audioBuffer(parent=self.window.tb, name="me_audio", composefunc="compose_audio", session=self.session, endpoint="get", parent_endpoint="audio", full_list=True, count=self.session.settings["buffers"]["count_for_audio_buffers"])
|
audio = buffers.audioBuffer(parent=self.window.tb, name="me_audio", composefunc="compose_audio", session=self.session, endpoint="get", parent_endpoint="audio", full_list=True, count=self.session.settings["buffers"]["count_for_audio_buffers"])
|
||||||
self.buffers.append(audio)
|
self.buffers.append(audio)
|
||||||
self.window.insert_buffer(audio.tab, _(u"My audios"), self.window.search("audios"))
|
self.window.insert_buffer(audio.tab, _(u"My audios"), self.window.search("audios"))
|
||||||
@ -114,6 +119,7 @@ class Controller(object):
|
|||||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.changelog, menuitem=self.window.changelog)
|
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.changelog, menuitem=self.window.changelog)
|
||||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.configuration, menuitem=self.window.settings_dialog)
|
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.configuration, menuitem=self.window.settings_dialog)
|
||||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.new_timeline, menuitem=self.window.timeline)
|
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.new_timeline, menuitem=self.window.timeline)
|
||||||
|
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.create_audio_album, menuitem=self.window.audio_album)
|
||||||
pub.subscribe(self.get_chat, "order-sent-message")
|
pub.subscribe(self.get_chat, "order-sent-message")
|
||||||
|
|
||||||
def disconnect_events(self):
|
def disconnect_events(self):
|
||||||
@ -144,6 +150,8 @@ class Controller(object):
|
|||||||
self.status_setter.start()
|
self.status_setter.start()
|
||||||
self.set_online()
|
self.set_online()
|
||||||
self.create_unread_messages()
|
self.create_unread_messages()
|
||||||
|
wx.CallAfter(self.get_audio_albums, self.session.user_id)
|
||||||
|
|
||||||
def in_post(self, buffer):
|
def in_post(self, buffer):
|
||||||
buffer = self.search(buffer)
|
buffer = self.search(buffer)
|
||||||
buffer.get_items()
|
buffer.get_items()
|
||||||
@ -336,3 +344,27 @@ class Controller(object):
|
|||||||
i.reads = []
|
i.reads = []
|
||||||
if ids != "":
|
if ids != "":
|
||||||
response = self.session.vk.client.messages.markAsRead(message_ids=ids)
|
response = self.session.vk.client.messages.markAsRead(message_ids=ids)
|
||||||
|
|
||||||
|
def get_audio_albums(self, user_id=None):
|
||||||
|
albums = self.session.vk.client.audio.getAlbums(owner_id=user_id)
|
||||||
|
print albums
|
||||||
|
for i in albums["items"]:
|
||||||
|
buffer = buffers.audioBuffer(parent=self.window.tb, name="{0}_album".format(i["id"],), composefunc="compose_audio", session=self.session, endpoint="get", parent_endpoint="audio", full_list=True, count=self.session.settings["buffers"]["count_for_audio_buffers"], user_id=user_id, album_id=i["id"])
|
||||||
|
name_ = _(u"Album: {0}").format(i["title"],)
|
||||||
|
self.buffers.append(buffer)
|
||||||
|
self.window.insert_buffer(buffer.tab, name_, self.window.search("albums"))
|
||||||
|
buffer.get_items()
|
||||||
|
# inserts a pause of 1 second here, so we'll avoid errors 6 in VK.
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
def create_audio_album(self, *args, **kwargs):
|
||||||
|
d = creation.audio_album()
|
||||||
|
if d.get_response() == widgetUtils.OK and d.get("title") != "":
|
||||||
|
response = self.session.vk.client.audio.addAlbum(title=d.get("title"))
|
||||||
|
if response.has_key("album_id") == False: return
|
||||||
|
album_id = response["album_id"]
|
||||||
|
buffer = buffers.audioBuffer(parent=self.window.tb, name="{0}_album".format(album_id,), composefunc="compose_audio", session=self.session, endpoint="get", parent_endpoint="audio", full_list=True, count=self.session.settings["buffers"]["count_for_audio_buffers"], user_id=self.session.user_id, album_id=album_id)
|
||||||
|
name_ = _(u"Album: {0}").format(d.get("title"),)
|
||||||
|
self.buffers.append(buffer)
|
||||||
|
self.window.insert_buffer(buffer.tab, name_, self.window.search("albums"))
|
||||||
|
buffer.get_items()
|
@ -268,7 +268,7 @@ class vkSession(object):
|
|||||||
if data != None:
|
if data != None:
|
||||||
if type(data) == dict:
|
if type(data) == dict:
|
||||||
num = self.order_buffer(name, data["items"], show_nextpage)
|
num = self.order_buffer(name, data["items"], show_nextpage)
|
||||||
if data["items"][0].has_key("first_name"):
|
if len(data["items"]) > 0 and data["items"][0].has_key("first_name"):
|
||||||
for i in data["items"]:
|
for i in data["items"]:
|
||||||
self.db["users"][i["id"]] = u"{0} {1}".format(i["first_name"], i["last_name"])
|
self.db["users"][i["id"]] = u"{0} {1}".format(i["first_name"], i["last_name"])
|
||||||
if data.has_key("profiles") and data.has_key("groups"):
|
if data.has_key("profiles") and data.has_key("groups"):
|
||||||
|
24
src/wxUI/dialogs/creation.py
Normal file
24
src/wxUI/dialogs/creation.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import wx
|
||||||
|
import widgetUtils
|
||||||
|
|
||||||
|
class audio_album(widgetUtils.BaseDialog):
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(audio_album, self).__init__(title=_(u"Create a new album"), parent=None)
|
||||||
|
panel = wx.Panel(self)
|
||||||
|
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||||
|
lbl = wx.StaticText(panel, wx.NewId(), _(u"Album title"))
|
||||||
|
self.title = wx.TextCtrl(panel, wx.NewId())
|
||||||
|
box = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
|
box.Add(lbl, 1, wx.ALL, 5)
|
||||||
|
box.Add(self.title, 1, wx.ALL, 5)
|
||||||
|
sizer.Add(box, 1, wx.ALL, 5)
|
||||||
|
ok = wx.Button(panel, wx.ID_OK, _(u"&OK"))
|
||||||
|
ok.SetDefault()
|
||||||
|
cancel = wx.Button(panel, wx.ID_CANCEL, _(u"&Close"))
|
||||||
|
btnsizer = wx.BoxSizer()
|
||||||
|
btnsizer.Add(ok, 0, wx.ALL, 5)
|
||||||
|
btnsizer.Add(cancel, 0, wx.ALL, 5)
|
||||||
|
sizer.Add(btnsizer, 0, wx.ALL, 5)
|
||||||
|
panel.SetSizer(sizer)
|
||||||
|
self.SetClientSize(sizer.CalcMin())
|
@ -6,12 +6,15 @@ class mainWindow(wx.Frame):
|
|||||||
def makeMenu(self):
|
def makeMenu(self):
|
||||||
mb = wx.MenuBar()
|
mb = wx.MenuBar()
|
||||||
app_ = wx.Menu()
|
app_ = wx.Menu()
|
||||||
|
create = wx.Menu()
|
||||||
|
self.audio_album = create.Append(wx.NewId(), _(u"Audio album"))
|
||||||
|
app_.AppendMenu(wx.NewId(), _(u"Create"), create)
|
||||||
self.settings_dialog = app_.Append(wx.NewId(), _(u"Preferences"))
|
self.settings_dialog = app_.Append(wx.NewId(), _(u"Preferences"))
|
||||||
buffer = wx.Menu()
|
buffer = wx.Menu()
|
||||||
self.new_buffer = wx.Menu()
|
search = wx.Menu()
|
||||||
self.search_audios = self.new_buffer.Append(wx.NewId(), _(u"Audio"))
|
self.search_audios = search.Append(wx.NewId(), _(u"Audio"))
|
||||||
buffer.AppendMenu(wx.NewId(), _(u"Search"), self.new_buffer)
|
|
||||||
self.timeline = buffer.Append(wx.NewId(), _(u"&New timeline"))
|
self.timeline = buffer.Append(wx.NewId(), _(u"&New timeline"))
|
||||||
|
buffer.AppendMenu(wx.NewId(), _(u"Search"), search)
|
||||||
self.update_buffer = buffer.Append(wx.NewId(), _(u"Update current buffer"))
|
self.update_buffer = buffer.Append(wx.NewId(), _(u"Update current buffer"))
|
||||||
self.load_previous_items = buffer.Append(wx.NewId(), _(u"Load previous items"))
|
self.load_previous_items = buffer.Append(wx.NewId(), _(u"Load previous items"))
|
||||||
self.remove_buffer_ = buffer.Append(wx.NewId(), _(u"&Remove buffer"))
|
self.remove_buffer_ = buffer.Append(wx.NewId(), _(u"&Remove buffer"))
|
||||||
|
Loading…
Reference in New Issue
Block a user