Added working youtube extractor. Needs converting mp3 at the end of downloads

This commit is contained in:
Manuel Cortez 2018-02-23 17:52:26 -06:00
parent 9830da2924
commit bfc49bb6e0
3 changed files with 13 additions and 5 deletions

View File

@ -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)

View File

@ -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):

View File

@ -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"))