From ba5d734a05814019ffba3dcba1997e7dcaf4ee0f Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Sun, 9 Dec 2018 05:22:37 -0600 Subject: [PATCH] Restored access to audios by users --- src/controller/mainController.py | 59 ++++++++++++++++---------------- src/wxUI/dialogs/timeline.py | 10 +++--- src/wxUI/mainWindow.py | 40 ++++++++-------------- 3 files changed, 49 insertions(+), 60 deletions(-) diff --git a/src/controller/mainController.py b/src/controller/mainController.py index df4f580..fbc68c9 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -13,7 +13,7 @@ import webbrowser import logging import longpollthread import selector -from vk.exceptions import VkAuthError, VkAPIError +from vk_api.exceptions import LoginRequired, VkApiError from pubsub import pub from mysc.repeating_timer import RepeatingTimer from mysc.thread_utils import call_threaded @@ -74,23 +74,23 @@ class Controller(object): # Translators: Own user's wall name in the tree view. self.window.insert_buffer(feed.tab, _(u"My wall"), self.window.search("posts")) ### Disabled audio stuff for now. -# audios = buffers.empty(parent=self.window.tb, name="audios") -# self.buffers.append(audios) + audios = buffers.empty(parent=self.window.tb, name="audios") + self.buffers.append(audios) # Translators: name for the music category in the tree view. -# self.window.add_buffer(audios.tab, _(u"Music")) + self.window.add_buffer(audios.tab, _(u"Music")) -# audio = buffers.audioBuffer(parent=self.window.tb, name="me_audio", composefunc="render_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.window.insert_buffer(audio.tab, _(u"My audios"), self.window.search("audios")) + audio = buffers.audioBuffer(parent=self.window.tb, name="me_audio", composefunc="render_audio", session=self.session, endpoint="get", parent_endpoint="audio") + self.buffers.append(audio) + self.window.insert_buffer(audio.tab, _(u"My audios"), self.window.search("audios")) # p_audio = buffers.audioBuffer(parent=self.window.tb, name="popular_audio", composefunc="render_audio", session=self.session, endpoint="getPopular", parent_endpoint="audio", full_list=True, count=self.session.settings["buffers"]["count_for_audio_buffers"]) # self.buffers.append(p_audio) # self.window.insert_buffer(p_audio.tab, _(u"Populars"), self.window.search("audios")) # r_audio = buffers.audioBuffer(parent=self.window.tb, name="recommended_audio", composefunc="render_audio", session=self.session, endpoint="getRecommendations", parent_endpoint="audio", full_list=True, count=self.session.settings["buffers"]["count_for_audio_buffers"]) # self.buffers.append(r_audio) # self.window.insert_buffer(r_audio.tab, _(u"Recommendations"), self.window.search("audios")) -# 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")) + 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")) videos = buffers.empty(parent=self.window.tb, name="videos") self.buffers.append(videos) # Translators: name for the videos category in the tree view. @@ -129,7 +129,7 @@ class Controller(object): pub.subscribe(self.in_post, "posted") pub.subscribe(self.download, "download-file") pub.subscribe(self.play_audio, "play-audio") -# pub.subscribe(self.play_audios, "play-audios") + pub.subscribe(self.play_audios, "play-audios") pub.subscribe(self.view_post, "open-post") pub.subscribe(self.update_status_bar, "update-status-bar") pub.subscribe(self.chat_from_id, "new-chat") @@ -139,36 +139,37 @@ class Controller(object): widgetUtils.connect_event(self.window, widgetUtils.MENU, self.update_buffer, menuitem=self.window.update_buffer) widgetUtils.connect_event(self.window, widgetUtils.MENU, self.check_for_updates, menuitem=self.window.check_for_updates) widgetUtils.connect_event(self.window, widgetUtils.MENU, self.window.about_dialog, menuitem=self.window.about) -# widgetUtils.connect_event(self.window, widgetUtils.MENU, self.search_audios, menuitem=self.window.search_audios) + widgetUtils.connect_event(self.window, widgetUtils.MENU, self.search_audios, menuitem=self.window.search_audios) widgetUtils.connect_event(self.window, widgetUtils.MENU, self.search_videos, menuitem=self.window.search_videos) widgetUtils.connect_event(self.window, widgetUtils.MENU,self.remove_buffer, menuitem=self.window.remove_buffer_) widgetUtils.connect_event(self.window, widgetUtils.MENU, self.get_more_items, menuitem=self.window.load_previous_items) 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.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.delete_audio_album, menuitem=self.window.delete_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.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.check_documentation, menuitem=self.window.documentation) -# widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_play_pause, menuitem=self.window.player_play) -# widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_play_next, menuitem=self.window.player_next) -# widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_play_previous, menuitem=self.window.player_previous) -# widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_play_all, menuitem=self.window.player_play_all) -# widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_stop, menuitem=self.window.player_stop) -# widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_volume_down, menuitem=self.window.player_volume_down) -# widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_volume_up, menuitem=self.window.player_volume_up) -# widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_mute, menuitem=self.window.player_mute) + widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_play_pause, menuitem=self.window.player_play) + widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_play_next, menuitem=self.window.player_next) + widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_play_previous, menuitem=self.window.player_previous) + widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_play_all, menuitem=self.window.player_play_all) + widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_stop, menuitem=self.window.player_stop) + widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_volume_down, menuitem=self.window.player_volume_down) + widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_volume_up, menuitem=self.window.player_volume_up) + widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_mute, menuitem=self.window.player_mute) pub.subscribe(self.get_chat, "order-sent-message") widgetUtils.connect_event(self.window, widgetUtils.MENU, self.view_my_profile, menuitem=self.window.view_profile) widgetUtils.connect_event(self.window, widgetUtils.MENU, self.view_my_profile_in_browser, menuitem=self.window.open_in_browser) + def disconnect_events(self): log.debug("Disconnecting some events...") pub.unsubscribe(self.in_post, "posted") -# pub.unsubscribe(self.download, "download-file") -# pub.unsubscribe(self.play_audio, "play-audio") + pub.unsubscribe(self.download, "download-file") + pub.unsubscribe(self.play_audio, "play-audio") pub.unsubscribe(self.authorisation_failed, "authorisation-failed") -# pub.unsubscribe(self.play_audios, "play-audios") + pub.unsubscribe(self.play_audios, "play-audios") pub.unsubscribe(self.view_post, "open-post") pub.unsubscribe(self.update_status_bar, "update-status-bar") @@ -320,7 +321,7 @@ class Controller(object): commonMessages.no_user_exist() return if buffertype == "audio": - buffer = buffers.audioBuffer(parent=self.window.tb, name="{0}_audio".format(user_id,), composefunc="render_audio", session=self.session, endpoint="get", parent_endpoint="audio", full_list=True, count=self.session.settings["buffers"]["count_for_audio_buffers"], owner_id=user_id) + buffer = buffers.audioBuffer(parent=self.window.tb, name="{0}_audio".format(user_id,), composefunc="render_audio", session=self.session, endpoint="get", parent_endpoint="audio", owner_id=user_id) # Translators: {0} will be replaced with an user. name_ = _(u"{0}'s audios").format(self.session.get_user_name(user_id, "gen"),) elif buffertype == "wall": @@ -409,7 +410,7 @@ class Controller(object): try: log.debug("Getting possible unread messages.") msgs = self.session.vk.client.messages.getDialogs(count=200, unread=1) - except VkAPIError as ex: + except VkApiError as ex: if ex.code == 6: log.exception("Something went wrong when getting messages. Waiting a second to retry") time.sleep(2) @@ -431,7 +432,7 @@ class Controller(object): try: log.debug("Create audio albums...") albums = self.session.vk.client.audio.getAlbums(owner_id=user_id) - except VkAPIError as ex: + except VkApiError as ex: if ex.code == 6: log.exception("Something went wrong when getting albums. Waiting a second to retry") time.sleep(2) @@ -454,7 +455,7 @@ class Controller(object): try: log.debug("Create video albums...") albums = self.session.vk.client.video.getAlbums(owner_id=user_id) - except VkAPIError as ex: + except VkApiError as ex: if ex.code == 6: log.exception("Something went wrong when getting albums. Waiting a second to retry") time.sleep(2) diff --git a/src/wxUI/dialogs/timeline.py b/src/wxUI/dialogs/timeline.py index 41ebdff..98e7092 100644 --- a/src/wxUI/dialogs/timeline.py +++ b/src/wxUI/dialogs/timeline.py @@ -16,11 +16,11 @@ class timelineDialog(widgetUtils.BaseDialog): userSizer.Add(self.cb, 0, wx.ALL, 5) actionsstatic = wx.StaticBox(panel, label=_(u"Buffer type")) self.wall = wx.RadioButton(panel, wx.NewId(), _(u"&Wall posts"), style=wx.RB_GROUP) -# self.audio = wx.RadioButton(panel, wx.NewId(), _(u"Audio")) + self.audio = wx.RadioButton(panel, wx.NewId(), _(u"Audio")) self.friends = wx.RadioButton(panel, wx.NewId(), _(u"Friends")) radioSizer = wx.StaticBoxSizer(actionsstatic, wx.HORIZONTAL) radioSizer.Add(self.wall, 0, wx.ALL, 5) -# radioSizer.Add(self.audio, 0, wx.ALL, 5) + radioSizer.Add(self.audio, 0, wx.ALL, 5) radioSizer.Add(self.friends, 0, wx.ALL, 5) sizer.Add(radioSizer, 0, wx.ALL, 5) ok = wx.Button(panel, wx.ID_OK, _(u"&OK")) @@ -37,9 +37,9 @@ class timelineDialog(widgetUtils.BaseDialog): return self.cb.GetValue() def get_buffer_type(self): -# if self.audio.GetValue() == True: -# return "audio" - if self.wall.GetValue() == True: + if self.audio.GetValue() == True: + return "audio" + elif self.wall.GetValue() == True: return "wall" elif self.friends.GetValue() == True: return "friends" \ No newline at end of file diff --git a/src/wxUI/mainWindow.py b/src/wxUI/mainWindow.py index 147d8ea..327df8e 100644 --- a/src/wxUI/mainWindow.py +++ b/src/wxUI/mainWindow.py @@ -8,13 +8,11 @@ class mainWindow(wx.Frame): mb = wx.MenuBar() app_ = wx.Menu() create = wx.Menu() -# self.audio_album = create.Append(wx.NewId(), _(u"Audio album")) -# self.audio_album.Enable(False) + self.audio_album = create.Append(wx.NewId(), _(u"Audio album")) self.video_album = create.Append(wx.NewId(), _(u"Video album")) app_.Append(wx.NewId(), _(u"Create"), create) delete = wx.Menu() -# self.delete_audio_album = delete.Append(wx.NewId(), _(u"Audio album")) -# self.delete_audio_album.Enable(False) + self.delete_audio_album = delete.Append(wx.NewId(), _(u"Audio album")) self.delete_video_album = delete.Append(wx.NewId(), _(u"Video album")) app_.Append(wx.NewId(), _(u"Delete"), delete) self.settings_dialog = app_.Append(wx.NewId(), _(u"Preferences")) @@ -27,8 +25,7 @@ class mainWindow(wx.Frame): self.set_status = me.Append(wx.NewId(), _(u"Set status message")) buffer = wx.Menu() search = wx.Menu() -# self.search_audios = search.Append(wx.NewId(), _(u"Audio")) -# self.search_audios.Enable(False) + self.search_audios = search.Append(wx.NewId(), _(u"Audio")) self.search_videos = search.Append(wx.NewId(), _(u"Video")) self.timeline = buffer.Append(wx.NewId(), _(u"&New timeline")) buffer.Append(wx.NewId(), _(u"Search"), search) @@ -38,31 +35,22 @@ class mainWindow(wx.Frame): mb.Append(app_, _(u"Application")) mb.Append(me, _(u"Me")) mb.Append(buffer, _(u"Buffer")) -# player = wx.Menu() -# self.player_play = player.Append(wx.NewId(), _(u"Play")) -# self.player_play.Enable(False) -# self.player_play_all = player.Append(wx.NewId(), _(u"Play all")) -# self.player_play_all.Enable(False) -# self.player_stop = player.Append(wx.NewId(), _(u"Stop")) -# self.player_stop.Enable(False) -# self.player_previous = player.Append(wx.NewId(), _(u"Previous")) -# self.player_previous.Enable(False) -# self.player_next = player.Append(wx.NewId(), _(u"Next")) -# self.player_next.Enable(False) -# self.player_shuffle = player.AppendCheckItem(wx.NewId(), _(u"Shuffle")) -# self.player_shuffle.Enable(False) -# self.player_volume_down = player.Append(wx.NewId(), _(u"Volume down")) -# self.player_volume_down.Enable(False) -# self.player_volume_up = player.Append(wx.NewId(), _(u"Volume up")) -# self.player_volume_up.Enable(False) -# self.player_mute = player.Append(wx.NewId(), _(u"Mute")) -# self.player_mute.Enable(False) + player = wx.Menu() + self.player_play = player.Append(wx.NewId(), _(u"Play")) + self.player_play_all = player.Append(wx.NewId(), _(u"Play all")) + self.player_stop = player.Append(wx.NewId(), _(u"Stop")) + self.player_previous = player.Append(wx.NewId(), _(u"Previous")) + self.player_next = player.Append(wx.NewId(), _(u"Next")) + self.player_shuffle = player.AppendCheckItem(wx.NewId(), _(u"Shuffle")) + self.player_volume_down = player.Append(wx.NewId(), _(u"Volume down")) + self.player_volume_up = player.Append(wx.NewId(), _(u"Volume up")) + self.player_mute = player.Append(wx.NewId(), _(u"Mute")) help_ = wx.Menu() self.about = help_.Append(wx.NewId(), _(u"About {0}").format(application.name,)) self.documentation = help_.Append(wx.NewId(), _(u"Manual")) self.check_for_updates = help_.Append(wx.NewId(), _(u"Check for updates")) self.changelog = help_.Append(wx.NewId(), _(u"Chan&gelog")) -# mb.Append(player, _(u"Audio player")) + mb.Append(player, _(u"Audio player")) mb.Append(help_, _(u"Help")) self.SetMenuBar(mb)