diff --git a/src/app-configuration.defaults b/src/app-configuration.defaults index 38f2583..4156b09 100644 --- a/src/app-configuration.defaults +++ b/src/app-configuration.defaults @@ -9,6 +9,9 @@ enabled = boolean(default=True) username = string(default="") password = string(default="") quality=string(default="high") +include_albums = boolean(default=True) +include_compilations = boolean(default=True) +include_singles = boolean(default=True) [[youtube]] enabled = boolean(default=True) diff --git a/src/controller/mainController.py b/src/controller/mainController.py index 594851e..910a73c 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -14,7 +14,7 @@ from issueReporter import issueReporter from wxUI import mainWindow, menus from update import updater from utils import get_services -from . import player, configuration, search +from . import player, configuration log = logging.getLogger("controller.main") @@ -25,13 +25,10 @@ class Controller(object): log.debug("Starting main controller...") # Setting up the player object player.setup() - self.buffers = [] # Get main window self.window = mainWindow.mainWindow(extractors=[i.interface.name for i in get_services()]) log.debug("Main window created") self.window.change_status(_(u"Ready")) - search_buffer = search.search(view=self.window.get_buffer(0)) - self.buffers.append(search_buffer) # Here we will save results for searches as song objects. self.results = [] self.connect_events() @@ -60,6 +57,9 @@ class Controller(object): def connect_events(self): """ connects all widgets to their corresponding events.""" log.debug("Binding events...") + widgetUtils.connect_event(self.window.search, widgetUtils.BUTTON_PRESSED, self.on_search) + widgetUtils.connect_event(self.window.list, widgetUtils.LISTBOX_ITEM_ACTIVATED, self.on_activated) + widgetUtils.connect_event(self.window.list, widgetUtils.KEYPRESS, self.on_keypress) widgetUtils.connect_event(self.window, widgetUtils.MENU, self.on_play, menuitem=self.window.player_play) widgetUtils.connect_event(self.window, widgetUtils.MENU, self.on_settings, menuitem=self.window.settings) widgetUtils.connect_event(self.window, widgetUtils.MENU, self.on_next, menuitem=self.window.player_next) @@ -82,8 +82,8 @@ class Controller(object): self.window.Bind(wx.EVT_COMMAND_SCROLL_CHANGED, self.on_set_volume, self.window.vol_slider) self.window.Bind(wx.EVT_COMMAND_SCROLL_THUMBTRACK, self.on_time_change, self.window.time_slider) self.window.Bind(wx.EVT_COMMAND_SCROLL_CHANGED, self.on_time_change, self.window.time_slider) -# self.window.list.Bind(wx.EVT_LISTBOX_DCLICK, self.on_play) -# self.window.list.Bind(wx.EVT_CONTEXT_MENU, self.on_context) + self.window.list.Bind(wx.EVT_LISTBOX_DCLICK, self.on_play) + self.window.list.Bind(wx.EVT_CONTEXT_MENU, self.on_context) self.window.Bind(wx.EVT_CLOSE, self.on_close) pub.subscribe(self.change_status, "change_status") pub.subscribe(self.on_download_finished, "download_finished") diff --git a/src/controller/search.py b/src/controller/search.py deleted file mode 100644 index e750dd7..0000000 --- a/src/controller/search.py +++ /dev/null @@ -1,25 +0,0 @@ -# -*- coding: utf-8 -*- -import widgetUtils -from pubsub import pub -from . import player - -class search(object): - - def __init__(self, view): - super(search, self).__init__() - self.name = "search" - self.items = [] - self.view = view - print(self.view) - self.connect_events() - - def connect_events(self): - widgetUtils.connect_event(self.view.list, widgetUtils.LISTBOX_ITEM_ACTIVATED, self.on_activated) - pub.subscribe(self.search, "search") - widgetUtils.connect_event(self.view.list, widgetUtils.KEYPRESS, self.on_keypress) - - def create_queue(self, parent): - pass - - def search(self, text, service): - print("Clocked me") diff --git a/src/services/tidal.py b/src/services/tidal.py index 019ec83..2ad1d27 100644 --- a/src/services/tidal.py +++ b/src/services/tidal.py @@ -64,21 +64,24 @@ class interface(base.baseInterface): elif field == "artist": data = [] artist = search_response.artists[0].id - albums = self.session.get_artist_albums(artist) - for album in albums: - tracks = self.session.get_album_tracks(album.id) - for track in tracks: - data.append(track) - compilations = self.session.get_artist_albums_other(artist) - for album in compilations: - tracks = self.session.get_album_tracks(album.id) - for track in tracks: - data.append(track) - singles = self.session.get_artist_albums_ep_singles(artist) - for album in singles: - tracks = self.session.get_album_tracks(album.id) - for track in tracks: - data.append(track) + if config.app["services"]["tidal"]["include_albums"]: + albums = self.session.get_artist_albums(artist) + for album in albums: + tracks = self.session.get_album_tracks(album.id) + for track in tracks: + data.append(track) + if config.app["services"]["tidal"]["include_compilations"]: + compilations = self.session.get_artist_albums_other(artist) + for album in compilations: + tracks = self.session.get_album_tracks(album.id) + for track in tracks: + data.append(track) + if config.app["services"]["tidal"]["include_singles"]: + singles = self.session.get_artist_albums_ep_singles(artist) + for album in singles: + tracks = self.session.get_album_tracks(album.id) + for track in tracks: + data.append(track) for search_result in data: s = base.song(self) s.title = search_result.name @@ -133,7 +136,6 @@ class settings(base.baseSettings): usernamebox.Add(self.username, 0, wx.ALL, 5) sizer.Add(usernamebox, 0, wx.ALL, 5) self.map.append(("username", self.username)) - password = wx.StaticText(self, wx.NewId(), _("Password")) self.password = wx.TextCtrl(self, wx.NewId(), style=wx.TE_PASSWORD) passwordbox = wx.BoxSizer(wx.HORIZONTAL) @@ -154,6 +156,14 @@ class settings(base.baseSettings): self.quality.GetValue = self.get_quality_value self.quality.SetValue = self.set_quality_value self.map.append(("quality", self.quality)) + include = wx.StaticBoxSizer(parent=self, orient=wx.HORIZONTAL, label=_("Search by artist")) + self.include_albums = wx.CheckBox(include.GetStaticBox(), wx.NewId(), _("Include albums")) + self.include_compilations = wx.CheckBox(include.GetStaticBox(), wx.NewId(), _("Include compilations")) + self.include_singles = wx.CheckBox(include.GetStaticBox(), wx.NewId(), _("Include singles")) + sizer.Add(include, 0, wx.ALL, 5) + self.map.append(("include_albums", self.include_albums)) + self.map.append(("include_compilations", self.include_compilations)) + self.map.append(("include_singles", self.include_singles)) self.SetSizer(sizer) def on_enabled(self, *args, **kwargs): diff --git a/src/wxUI/mainWindow.py b/src/wxUI/mainWindow.py index de191fb..45806f0 100644 --- a/src/wxUI/mainWindow.py +++ b/src/wxUI/mainWindow.py @@ -7,7 +7,6 @@ except ImportError: pass import application import widgetUtils -from .search import searchPanel class mainWindow(wx.Frame): def makeMenu(self): @@ -41,10 +40,22 @@ class mainWindow(wx.Frame): self.panel = wx.Panel(self) self.sizer = wx.BoxSizer(wx.VERTICAL) self.sb = self.CreateStatusBar() - self.tb = wx.Treebook(self.panel, -1) - search = searchPanel(extractors, parent=self.tb) - self.add_buffer(search, _("Search")) - self.sizer.Add(self.tb, 1, wx.ALL|wx.EXPAND, 5) + lbl2 = wx.StaticText(self.panel, wx.NewId(), _(u"search")) + self.text = wx.TextCtrl(self.panel, wx.NewId()) + box = wx.BoxSizer(wx.HORIZONTAL) + box.Add(lbl2, 0, wx.GROW) + box.Add(self.text, 1, wx.GROW) + box.Add(wx.StaticText(self.panel, wx.NewId(), _(u"Search in")), 0, wx.GROW) + self.extractor = wx.ComboBox(self.panel, wx.NewId(), choices=extractors, value=extractors[0], style=wx.CB_READONLY) + box.Add(self.extractor, 1, wx.GROW) + self.search = wx.Button(self.panel, wx.NewId(), _(u"Search")) + self.search.SetDefault() + box.Add(self.search, 0, wx.GROW) + self.sizer.Add(box, 0, wx.GROW) + lbl = wx.StaticText(self.panel, wx.NewId(), _(u"Results")) + self.list = wx.ListBox(self.panel, wx.NewId()) + self.sizer.Add(lbl, 0, wx.GROW) + self.sizer.Add(self.list, 1, wx.GROW) box1 = wx.BoxSizer(wx.HORIZONTAL) box2 = wx.BoxSizer(wx.HORIZONTAL) box1.Add(wx.StaticText(self.panel, wx.NewId(), _(u"Position")), 0, wx.GROW) @@ -66,6 +77,9 @@ class mainWindow(wx.Frame): self.progressbar = wx.Gauge(self.panel, wx.NewId(), range=100, style=wx.GA_HORIZONTAL) self.sizer.Add(self.progressbar, 0, wx.ALL, 5) self.panel.SetSizerAndFit(self.sizer) +# self.SetClientSize(self.sizer.CalcMin()) +# self.Layout() +# self.SetSize(self.GetBestSize()) def change_status(self, status): self.sb.SetStatusText(status) @@ -88,6 +102,14 @@ class mainWindow(wx.Frame): except: wx.AboutBox(info) + def get_text(self): + t = self.text.GetValue() + self.text.ChangeValue("") + return t + + def get_item(self): + return self.list.GetSelection() + def get_destination_path(self, filename): saveFileDialog = wx.FileDialog(self, _(u"Save this file"), "", filename, _(u"Audio Files(*.mp3)|*.mp3"), wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) if saveFileDialog.ShowModal() == wx.ID_OK: @@ -99,46 +121,4 @@ class mainWindow(wx.Frame): self.notification = wx.adv.NotificationMessage(title, text, parent=self) except AttributeError: self.notification = wx.NotificationMessage(title, text) - self.notification.Show() - - def get_buffer_count(self): - return self.tb.GetPageCount() - - def add_buffer(self, buffer, name): - self.tb.AddPage(buffer, name) - - def insert_buffer(self, buffer, name, pos): - return self.tb.InsertSubPage(pos, buffer, name) - - def search(self, name_): - for i in range(0, self.tb.GetPageCount()): - if self.tb.GetPage(i).name == name_: return i - - def get_current_buffer(self): - return self.tb.GetCurrentPage() - - def get_current_buffer_pos(self): - return self.tb.GetSelection() - - def get_buffer(self, pos): - return self.tb.GetPage(pos) - - def change_buffer(self, position): - self.tb.ChangeSelection(position) - - def get_buffer_text(self, pos=None): - if pos == None: - pos = self.tb.GetSelection() - return self.tb.GetPageText(pos) - - def get_buffer_by_id(self, id): - return self.tb.FindWindowById(id) - - def advance_selection(self, forward): - self.tb.AdvanceSelection(forward) - - def remove_buffer(self, pos): - self.tb.DeletePage(pos) - - def remove_buffer_from_position(self, pos): - return self.tb.RemovePage(pos) + self.notification.Show() \ No newline at end of file diff --git a/src/wxUI/search.py b/src/wxUI/search.py deleted file mode 100644 index 64b6282..0000000 --- a/src/wxUI/search.py +++ /dev/null @@ -1,41 +0,0 @@ -# -*- coding: utf-8 -*- -import wx -from pubsub import pub - -class searchPanel(wx.Panel): - - def __init__(self, services=[], *args, **kwargs): - super(searchPanel, self).__init__(*args, **kwargs) - sizer = wx.BoxSizer(wx.VERTICAL) - lbl2 = wx.StaticText(self, wx.NewId(), _("search")) - self.text = wx.TextCtrl(self, wx.NewId()) - box = wx.BoxSizer(wx.HORIZONTAL) - box.Add(lbl2, 0, wx.GROW) - box.Add(self.text, 1, wx.GROW) - box.Add(wx.StaticText(self, wx.NewId(), _(u"Search in")), 0, wx.GROW) - self.service = wx.ComboBox(self, wx.NewId(), choices=services, value=services[0], style=wx.CB_READONLY) - box.Add(self.service, 1, wx.GROW) - self.search = wx.Button(self, wx.NewId(), _(u"Search")) - self.search.SetDefault() - self.search.Bind(wx.EVT_BUTTON, self.on_search) - box.Add(self.search, 0, wx.GROW) - sizer.Add(box, 0, wx.GROW) - lbl = wx.StaticText(self, wx.NewId(), _(u"Results")) - self.list = wx.ListBox(self, wx.NewId()) - sizer.Add(lbl, 0, wx.GROW) - sizer.Add(self.list, 1, wx.GROW) - self.SetSizer(sizer) - - def get_text(self): - t = self.text.GetValue() - self.text.ChangeValue("") - return t - - def get_item(self): - return self.list.GetSelection() - - def on_search(self, event, *args, **kwargs): - text = self.get_text() - service = self.service.GetValue() - pub.sendMessage("search", service=service, text=text) - event.Skip() \ No newline at end of file