Added video search

This commit is contained in:
Manuel Cortez 2016-08-15 17:00:49 -05:00
parent 4900b67882
commit ee308fb5aa
3 changed files with 64 additions and 0 deletions

View File

@ -144,6 +144,7 @@ class Controller(object):
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_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)
@ -259,6 +260,24 @@ class Controller(object):
# Translators: {0} will be replaced with the search term.
self.window.insert_buffer(newbuff.tab, _(u"Search for {0}").format(q.decode("utf-8"),), self.window.search("audios"))
def search_videos(self, *args, **kwargs):
dlg = searchDialogs.searchVideoDialog()
if dlg.get_response() == widgetUtils.OK:
params = {}
params["q"] = dlg.get("term").encode("utf-8")
params["count"] = 200
hd = dlg.get_checkable("hd")
if hd != 0:
params["hd"] = 1
params["adult"] = dlg.get_checkable("safe_search")
params["sort"] = dlg.get_sort_order()
params["filters"] = "youtube, vimeo, short, long"
newbuff = buffers.videoBuffer(parent=self.window.tb, name=u"{0}_videosearch".format(params["q"].decode("utf-8"),), session=self.session, composefunc="compose_video", parent_endpoint="video", endpoint="search", **params)
self.buffers.append(newbuff)
call_threaded(newbuff.get_items)
# Translators: {0} will be replaced with the search term.
self.window.insert_buffer(newbuff.tab, _(u"Search for {0}").format(params["q"].decode("utf-8"),), self.window.search("videos"))
def update_status_bar(self, status):
self.window.change_status(status)

View File

@ -49,5 +49,49 @@ class searchAudioDialog(widgetUtils.BaseDialog):
else:
return 0
def get_sort_order(self):
return self.sortorder.GetSelection()
class searchVideoDialog(widgetUtils.BaseDialog):
def __init__(self, value=""):
super(searchVideoDialog, self).__init__(None, -1)
panel = wx.Panel(self)
sizer = wx.BoxSizer(wx.VERTICAL)
self.SetTitle(_(u"video Search"))
label = wx.StaticText(panel, -1, _(u"&Search"))
self.term = wx.TextCtrl(panel, -1, value)
dc = wx.WindowDC(self.term)
dc.SetFont(self.term.GetFont())
self.term.SetSize(dc.GetTextExtent("0"*40))
sizer.Add(label, 0, wx.ALL, 5)
sizer.Add(self.term, 0, wx.ALL, 5)
sort_order = wx.StaticText(panel, -1, _(U"&Sort order by: "))
self.sortorder = wx.ComboBox(panel, wx.NewId(), choices=[_(u"Date added"), _(u"Duration"), _(u"Popularity")], value=_(u"Popularity"), style=wx.CB_READONLY)
rBox = wx.BoxSizer(wx.HORIZONTAL)
rBox.Add(sort_order, 0, wx.ALL, 5)
rBox.Add(self.sortorder, 0, wx.ALL, 5)
sizer.Add(rBox, 0, wx.ALL, 5)
self.hd = wx.CheckBox(panel, wx.NewId(), _(u"Search only for videos in &High definition"))
self.hd.SetValue(False)
sizer.Add(self.hd, 0, wx.ALL, 5)
self.safe_search = wx.CheckBox(panel, wx.NewId(), _(u"S&afe search"))
self.safe_search.SetValue(True)
sizer.Add(self.safe_search, 0, wx.ALL, 5)
ok = wx.Button(panel, wx.ID_OK, _(u"&OK"))
ok.SetDefault()
cancel = wx.Button(panel, wx.ID_CANCEL, _(u"&Close"))
btnsizer = wx.BoxSizer()
btnsizer.Add(ok, 0, wx.ALL, 5)
btnsizer.Add(cancel, 0, wx.ALL, 5)
sizer.Add(btnsizer, 0, wx.ALL, 5)
panel.SetSizer(sizer)
self.SetClientSize(sizer.CalcMin())
def get_checkable(self, control):
if getattr(self, control).GetValue() == True:
return 1
else:
return 0
def get_sort_order(self):
return self.sortorder.GetSelection()

View File

@ -18,6 +18,7 @@ class mainWindow(wx.Frame):
buffer = wx.Menu()
search = wx.Menu()
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.AppendMenu(wx.NewId(), _(u"Search"), search)
self.update_buffer = buffer.Append(wx.NewId(), _(u"Update current buffer"))