From bfc49bb6e05c738ee5319586e006d914b2cdf6bc Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Fri, 23 Feb 2018 17:52:26 -0600 Subject: [PATCH] Added working youtube extractor. Needs converting mp3 at the end of downloads --- src/controller/mainController.py | 10 ++++++++-- src/extractors/youtube.py | 1 - src/wxUI/mainWindow.py | 7 +++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/controller/mainController.py b/src/controller/mainController.py index eb12022..8847bfb 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -6,7 +6,7 @@ import widgetUtils import utils from pubsub import pub from wxUI import mainWindow, menus -from extractors import zaycev +from extractors import zaycev, youtube from . import player log = logging.getLogger("controller.main") @@ -19,7 +19,6 @@ class Controller(object): # Setting up the player object player.setup() # Instantiate the only available extractor for now. - self.extractor = zaycev.interface() # Get main window self.window = mainWindow.mainWindow() log.debug("Main window created") @@ -177,6 +176,13 @@ class Controller(object): text = self.window.get_text() if text == "": return + extractor = self.window.extractor.GetValue() + if extractor == "youtube": + self.extractor = youtube.interface() + elif extractor == "zaycev.net": + self.extractor = zaycev.interface() + elif extractor == "": + return self.window.list.Clear() self.change_status(_("Searching {0}... ").format(text,)) self.extractor.search(text) diff --git a/src/extractors/youtube.py b/src/extractors/youtube.py index ed21cb3..b73184d 100644 --- a/src/extractors/youtube.py +++ b/src/extractors/youtube.py @@ -24,7 +24,6 @@ class interface(object): s = baseFile.song(self) s.title = search_result["snippet"]["title"] s.url = "https://www.youtube.com/watch?v="+search_result["id"]["videoId"] - print(search_result.keys()) self.results.append(s) def get_download_url(self, url): diff --git a/src/wxUI/mainWindow.py b/src/wxUI/mainWindow.py index 0b52b57..47af5c1 100644 --- a/src/wxUI/mainWindow.py +++ b/src/wxUI/mainWindow.py @@ -33,11 +33,14 @@ class mainWindow(wx.Frame): self.sb = self.CreateStatusBar() lbl2 = wx.StaticText(self.panel, wx.NewId(), _(u"search")) self.text = wx.TextCtrl(self.panel, wx.NewId()) - self.search = wx.Button(self.panel, wx.NewId(), _("Search")) - self.search.SetDefault() 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(), _("Search in")), 0, wx.GROW) + self.extractor = wx.ComboBox(self.panel, wx.NewId(), choices=["youtube", "zaycev.net"], value="youtube", style=wx.CB_READONLY) + box.Add(self.extractor, 1, wx.GROW) + self.search = wx.Button(self.panel, wx.NewId(), _("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(), _("Results"))