Restored access to audios by users

This commit is contained in:
Manuel Cortez 2018-12-09 05:22:37 -06:00
parent bb26d45f1d
commit ba5d734a05
3 changed files with 49 additions and 60 deletions

View File

@ -13,7 +13,7 @@ import webbrowser
import logging import logging
import longpollthread import longpollthread
import selector import selector
from vk.exceptions import VkAuthError, VkAPIError from vk_api.exceptions import LoginRequired, VkApiError
from pubsub import pub from pubsub import pub
from mysc.repeating_timer import RepeatingTimer from mysc.repeating_timer import RepeatingTimer
from mysc.thread_utils import call_threaded from mysc.thread_utils import call_threaded
@ -74,23 +74,23 @@ class Controller(object):
# Translators: Own user's wall name in the tree view. # Translators: Own user's wall name in the tree view.
self.window.insert_buffer(feed.tab, _(u"My wall"), self.window.search("posts")) self.window.insert_buffer(feed.tab, _(u"My wall"), self.window.search("posts"))
### Disabled audio stuff for now. ### Disabled audio stuff for now.
# 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)
# Translators: name for the music category in the tree view. # 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"]) 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.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"))
# 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"]) # 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.buffers.append(p_audio)
# self.window.insert_buffer(p_audio.tab, _(u"Populars"), self.window.search("audios")) # 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"]) # 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.buffers.append(r_audio)
# self.window.insert_buffer(r_audio.tab, _(u"Recommendations"), self.window.search("audios")) # self.window.insert_buffer(r_audio.tab, _(u"Recommendations"), self.window.search("audios"))
# albums = buffers.empty(parent=self.window.tb, name="albums") albums = buffers.empty(parent=self.window.tb, name="albums")
# self.buffers.append(albums) self.buffers.append(albums)
# self.window.insert_buffer(albums.tab, _(u"Albums"), self.window.search("audios")) self.window.insert_buffer(albums.tab, _(u"Albums"), self.window.search("audios"))
videos = buffers.empty(parent=self.window.tb, name="videos") videos = buffers.empty(parent=self.window.tb, name="videos")
self.buffers.append(videos) self.buffers.append(videos)
# Translators: name for the videos category in the tree view. # 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.in_post, "posted")
pub.subscribe(self.download, "download-file") pub.subscribe(self.download, "download-file")
pub.subscribe(self.play_audio, "play-audio") 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.view_post, "open-post")
pub.subscribe(self.update_status_bar, "update-status-bar") pub.subscribe(self.update_status_bar, "update-status-bar")
pub.subscribe(self.chat_from_id, "new-chat") 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.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.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.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.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.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.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.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)
# 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_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_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_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_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_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_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_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_mute, menuitem=self.window.player_mute)
pub.subscribe(self.get_chat, "order-sent-message") 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, menuitem=self.window.view_profile)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.view_my_profile_in_browser, menuitem=self.window.open_in_browser) widgetUtils.connect_event(self.window, widgetUtils.MENU, self.view_my_profile_in_browser, menuitem=self.window.open_in_browser)
def disconnect_events(self): def disconnect_events(self):
log.debug("Disconnecting some events...") log.debug("Disconnecting some events...")
pub.unsubscribe(self.in_post, "posted") pub.unsubscribe(self.in_post, "posted")
# pub.unsubscribe(self.download, "download-file") pub.unsubscribe(self.download, "download-file")
# pub.unsubscribe(self.play_audio, "play-audio") pub.unsubscribe(self.play_audio, "play-audio")
pub.unsubscribe(self.authorisation_failed, "authorisation-failed") 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.view_post, "open-post")
pub.unsubscribe(self.update_status_bar, "update-status-bar") pub.unsubscribe(self.update_status_bar, "update-status-bar")
@ -320,7 +321,7 @@ class Controller(object):
commonMessages.no_user_exist() commonMessages.no_user_exist()
return return
if buffertype == "audio": 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. # Translators: {0} will be replaced with an user.
name_ = _(u"{0}'s audios").format(self.session.get_user_name(user_id, "gen"),) name_ = _(u"{0}'s audios").format(self.session.get_user_name(user_id, "gen"),)
elif buffertype == "wall": elif buffertype == "wall":
@ -409,7 +410,7 @@ class Controller(object):
try: try:
log.debug("Getting possible unread messages.") log.debug("Getting possible unread messages.")
msgs = self.session.vk.client.messages.getDialogs(count=200, unread=1) msgs = self.session.vk.client.messages.getDialogs(count=200, unread=1)
except VkAPIError as ex: except VkApiError as ex:
if ex.code == 6: if ex.code == 6:
log.exception("Something went wrong when getting messages. Waiting a second to retry") log.exception("Something went wrong when getting messages. Waiting a second to retry")
time.sleep(2) time.sleep(2)
@ -431,7 +432,7 @@ class Controller(object):
try: try:
log.debug("Create audio albums...") log.debug("Create audio albums...")
albums = self.session.vk.client.audio.getAlbums(owner_id=user_id) albums = self.session.vk.client.audio.getAlbums(owner_id=user_id)
except VkAPIError as ex: except VkApiError as ex:
if ex.code == 6: if ex.code == 6:
log.exception("Something went wrong when getting albums. Waiting a second to retry") log.exception("Something went wrong when getting albums. Waiting a second to retry")
time.sleep(2) time.sleep(2)
@ -454,7 +455,7 @@ class Controller(object):
try: try:
log.debug("Create video albums...") log.debug("Create video albums...")
albums = self.session.vk.client.video.getAlbums(owner_id=user_id) albums = self.session.vk.client.video.getAlbums(owner_id=user_id)
except VkAPIError as ex: except VkApiError as ex:
if ex.code == 6: if ex.code == 6:
log.exception("Something went wrong when getting albums. Waiting a second to retry") log.exception("Something went wrong when getting albums. Waiting a second to retry")
time.sleep(2) time.sleep(2)

View File

@ -16,11 +16,11 @@ class timelineDialog(widgetUtils.BaseDialog):
userSizer.Add(self.cb, 0, wx.ALL, 5) userSizer.Add(self.cb, 0, wx.ALL, 5)
actionsstatic = wx.StaticBox(panel, label=_(u"Buffer type")) actionsstatic = wx.StaticBox(panel, label=_(u"Buffer type"))
self.wall = wx.RadioButton(panel, wx.NewId(), _(u"&Wall posts"), style=wx.RB_GROUP) 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")) self.friends = wx.RadioButton(panel, wx.NewId(), _(u"Friends"))
radioSizer = wx.StaticBoxSizer(actionsstatic, wx.HORIZONTAL) radioSizer = wx.StaticBoxSizer(actionsstatic, wx.HORIZONTAL)
radioSizer.Add(self.wall, 0, wx.ALL, 5) 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) radioSizer.Add(self.friends, 0, wx.ALL, 5)
sizer.Add(radioSizer, 0, wx.ALL, 5) sizer.Add(radioSizer, 0, wx.ALL, 5)
ok = wx.Button(panel, wx.ID_OK, _(u"&OK")) ok = wx.Button(panel, wx.ID_OK, _(u"&OK"))
@ -37,9 +37,9 @@ class timelineDialog(widgetUtils.BaseDialog):
return self.cb.GetValue() return self.cb.GetValue()
def get_buffer_type(self): def get_buffer_type(self):
# if self.audio.GetValue() == True: if self.audio.GetValue() == True:
# return "audio" return "audio"
if self.wall.GetValue() == True: elif self.wall.GetValue() == True:
return "wall" return "wall"
elif self.friends.GetValue() == True: elif self.friends.GetValue() == True:
return "friends" return "friends"

View File

@ -8,13 +8,11 @@ class mainWindow(wx.Frame):
mb = wx.MenuBar() mb = wx.MenuBar()
app_ = wx.Menu() app_ = wx.Menu()
create = wx.Menu() create = wx.Menu()
# self.audio_album = create.Append(wx.NewId(), _(u"Audio album")) self.audio_album = create.Append(wx.NewId(), _(u"Audio album"))
# self.audio_album.Enable(False)
self.video_album = create.Append(wx.NewId(), _(u"Video album")) self.video_album = create.Append(wx.NewId(), _(u"Video album"))
app_.Append(wx.NewId(), _(u"Create"), create) app_.Append(wx.NewId(), _(u"Create"), create)
delete = wx.Menu() delete = wx.Menu()
# self.delete_audio_album = delete.Append(wx.NewId(), _(u"Audio album")) self.delete_audio_album = delete.Append(wx.NewId(), _(u"Audio album"))
# self.delete_audio_album.Enable(False)
self.delete_video_album = delete.Append(wx.NewId(), _(u"Video album")) self.delete_video_album = delete.Append(wx.NewId(), _(u"Video album"))
app_.Append(wx.NewId(), _(u"Delete"), delete) app_.Append(wx.NewId(), _(u"Delete"), delete)
self.settings_dialog = app_.Append(wx.NewId(), _(u"Preferences")) 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")) self.set_status = me.Append(wx.NewId(), _(u"Set status message"))
buffer = wx.Menu() buffer = wx.Menu()
search = wx.Menu() search = wx.Menu()
# self.search_audios = search.Append(wx.NewId(), _(u"Audio")) self.search_audios = search.Append(wx.NewId(), _(u"Audio"))
# self.search_audios.Enable(False)
self.search_videos = search.Append(wx.NewId(), _(u"Video")) self.search_videos = search.Append(wx.NewId(), _(u"Video"))
self.timeline = buffer.Append(wx.NewId(), _(u"&New timeline")) self.timeline = buffer.Append(wx.NewId(), _(u"&New timeline"))
buffer.Append(wx.NewId(), _(u"Search"), search) buffer.Append(wx.NewId(), _(u"Search"), search)
@ -38,31 +35,22 @@ class mainWindow(wx.Frame):
mb.Append(app_, _(u"Application")) mb.Append(app_, _(u"Application"))
mb.Append(me, _(u"Me")) mb.Append(me, _(u"Me"))
mb.Append(buffer, _(u"Buffer")) mb.Append(buffer, _(u"Buffer"))
# player = wx.Menu() player = wx.Menu()
# self.player_play = player.Append(wx.NewId(), _(u"Play")) 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 = player.Append(wx.NewId(), _(u"Play all")) self.player_stop = player.Append(wx.NewId(), _(u"Stop"))
# self.player_play_all.Enable(False) self.player_previous = player.Append(wx.NewId(), _(u"Previous"))
# self.player_stop = player.Append(wx.NewId(), _(u"Stop")) self.player_next = player.Append(wx.NewId(), _(u"Next"))
# self.player_stop.Enable(False) self.player_shuffle = player.AppendCheckItem(wx.NewId(), _(u"Shuffle"))
# self.player_previous = player.Append(wx.NewId(), _(u"Previous")) self.player_volume_down = player.Append(wx.NewId(), _(u"Volume down"))
# self.player_previous.Enable(False) self.player_volume_up = player.Append(wx.NewId(), _(u"Volume up"))
# self.player_next = player.Append(wx.NewId(), _(u"Next")) self.player_mute = player.Append(wx.NewId(), _(u"Mute"))
# 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)
help_ = wx.Menu() help_ = wx.Menu()
self.about = help_.Append(wx.NewId(), _(u"About {0}").format(application.name,)) self.about = help_.Append(wx.NewId(), _(u"About {0}").format(application.name,))
self.documentation = help_.Append(wx.NewId(), _(u"Manual")) self.documentation = help_.Append(wx.NewId(), _(u"Manual"))
self.check_for_updates = help_.Append(wx.NewId(), _(u"Check for updates")) self.check_for_updates = help_.Append(wx.NewId(), _(u"Check for updates"))
self.changelog = help_.Append(wx.NewId(), _(u"Chan&gelog")) 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")) mb.Append(help_, _(u"Help"))
self.SetMenuBar(mb) self.SetMenuBar(mb)