Implemented adding and removing audio albums appropiately
This commit is contained in:
parent
f968e618ac
commit
d75b7de20b
@ -19,7 +19,7 @@ from mysc import localization
|
|||||||
from sessionmanager import session, utils, renderers
|
from sessionmanager import session, utils, renderers
|
||||||
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 creation, timeline
|
||||||
from update import updater
|
from update import updater
|
||||||
from issueReporter import issueReporter
|
from issueReporter import issueReporter
|
||||||
from . import buffers
|
from . import buffers
|
||||||
@ -137,8 +137,8 @@ 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)
|
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.create_audio_album, menuitem=self.window.audio_album)
|
||||||
# widgetUtils.connect_event(self.window, widgetUtils.MENU, self.delete_audio_album, menuitem=self.window.delete_audio_album)
|
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.delete_audio_album, menuitem=self.window.delete_audio_album)
|
||||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.create_video_album, menuitem=self.window.video_album)
|
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.create_video_album, menuitem=self.window.video_album)
|
||||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.delete_video_album, menuitem=self.window.delete_video_album)
|
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.delete_video_album, menuitem=self.window.delete_video_album)
|
||||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.check_documentation, menuitem=self.window.documentation)
|
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.check_documentation, menuitem=self.window.documentation)
|
||||||
@ -539,9 +539,10 @@ class Controller(object):
|
|||||||
def create_audio_album(self, *args, **kwargs):
|
def create_audio_album(self, *args, **kwargs):
|
||||||
d = creation.audio_album()
|
d = creation.audio_album()
|
||||||
if d.get_response() == widgetUtils.OK and d.get("title") != "":
|
if d.get_response() == widgetUtils.OK and d.get("title") != "":
|
||||||
response = self.session.vk.client.audio.addAlbum(title=d.get("title"))
|
response = self.session.vk.client.audio.createPlaylist(owner_id=self.session.user_id, title=d.get("title"))
|
||||||
if ("album_id" in response) == False: return
|
if "id" not in response:
|
||||||
album_id = response["album_id"]
|
return
|
||||||
|
album_id = response["id"]
|
||||||
buffer = buffers.audioAlbum(parent=self.window.tb, name="{0}_audio_album".format(album_id,), composefunc="render_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)
|
buffer = buffers.audioAlbum(parent=self.window.tb, name="{0}_audio_album".format(album_id,), composefunc="render_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)
|
||||||
buffer.can_get_items = False
|
buffer.can_get_items = False
|
||||||
# Translators: {0} will be replaced with an audio album's title.
|
# Translators: {0} will be replaced with an audio album's title.
|
||||||
@ -549,7 +550,7 @@ class Controller(object):
|
|||||||
self.buffers.append(buffer)
|
self.buffers.append(buffer)
|
||||||
self.window.insert_buffer(buffer.tab, name_, self.window.search("albums"))
|
self.window.insert_buffer(buffer.tab, name_, self.window.search("albums"))
|
||||||
buffer.get_items()
|
buffer.get_items()
|
||||||
self.session.audio_albums = self.session.vk.client.audio.getAlbums(owner_id=self.session.user_id)["items"]
|
self.get_audio_albums(user_id=self.session.user_id, create_buffers=False)
|
||||||
|
|
||||||
def delete_audio_album(self, *args, **kwargs):
|
def delete_audio_album(self, *args, **kwargs):
|
||||||
if len(self.session.audio_albums) == 0:
|
if len(self.session.audio_albums) == 0:
|
||||||
@ -559,13 +560,14 @@ class Controller(object):
|
|||||||
return
|
return
|
||||||
response = commonMessages.delete_audio_album()
|
response = commonMessages.delete_audio_album()
|
||||||
if response != widgetUtils.YES: return
|
if response != widgetUtils.YES: return
|
||||||
removal = self.session.vk.client.audio.deleteAlbum(album_id=answer.item)
|
removal = self.session.vk.client.audio.deletePlaylist(playlist_id=answer.item, owner_id=self.session.user_id)
|
||||||
buffer = self.search("{0}_audio_album".format(answer.item,))
|
if removal == 1:
|
||||||
buff = self.window.search(buffer.name)
|
buffer = self.search("{0}_audio_album".format(answer.item,))
|
||||||
self.window.remove_buffer(buff)
|
buff = self.window.search(buffer.name)
|
||||||
self.buffers.remove(buffer)
|
self.window.remove_buffer(buff)
|
||||||
del buffer
|
self.buffers.remove(buffer)
|
||||||
self.session.audio_albums = self.session.vk.client.audio.getAlbums(owner_id=self.session.user_id)["items"]
|
del buffer
|
||||||
|
self.get_audio_albums(user_id=self.session.user_id, create_buffers=False)
|
||||||
|
|
||||||
def create_video_album(self, *args, **kwargs):
|
def create_video_album(self, *args, **kwargs):
|
||||||
d = creation.audio_album()
|
d = creation.audio_album()
|
||||||
|
Loading…
Reference in New Issue
Block a user