def __init__(self, keyword=None, username=None, playlist=None, page=1): super(VideoListYoutube, self).__init__() self.get_style_context().add_class('video_list_youtube') start_index = page_to_index(page) entries = None self._parsed_entries = None if keyword: entries = search_youtube_by_keyword( keyword, start_index=start_index, parent_control=self.ParentalControl) logger.info('searching by keyword: ' + keyword) elif username: entries = search_youtube_by_user( username, parent_control=self.ParentalControl) logger.info('listing by username: '******'listing playlist: ' + playlist) else: entries = search_youtube_by_user( 'KanoComputing', parent_control=self.ParentalControl) logger.info('listing default videos by KanoComputing') if entries: self._parsed_entries = parse_youtube_entries(entries) else: self._grid.attach(self._no_results, 0, 0, 1, 1) self.refresh()
def __init__(self, search_keyword=None, users=False, page=1): super(YoutubeView, self).__init__() if search_keyword and search_keyword.get_text(): index = page_to_index(page) if users is False: self._list = VideoListYoutube( keyword=search_keyword.get_text(), page=page) else: self._list = VideoListYoutube( username=search_keyword.get_text()) self._header = SearchResultsHeader(search_keyword.get_text(), get_last_search_count(), start=index) else: self._header = YoutubeHeader() self._list = VideoListYoutube(page=page) if search_keyword and search_keyword.get_text() is not '': navigation_grid = Gtk.Grid() self._grid.attach(navigation_grid, 0, 3, 1, 1) prev_button = Gtk.Button('Back') prev_button.get_style_context().add_class('green') prev_button.connect('clicked', self._switch_page, page - 1, search_keyword) navigation_grid.attach(prev_button, 0, 0, 1, 1) if page == 1: prev_button.set_sensitive(False) navigation_grid.attach(Gtk.Label('', hexpand=True), 1, 0, 1, 1) next_button = Gtk.Button('Next') next_button.get_style_context().add_class('green') next_button.connect('clicked', self._switch_page, page + 1, search_keyword) navigation_grid.attach(next_button, 2, 0, 1, 1) self.refresh()
def __init__(self, search_keyword=None, users=False, page=1): super(YoutubeView, self).__init__() if search_keyword and search_keyword.get_text(): index = page_to_index(page) if users is False: self._list = VideoListYoutube( keyword=search_keyword.get_text(), page=page) else: self._list = VideoListYoutube( username=search_keyword.get_text()) self._header = SearchResultsHeader( search_keyword.get_text(), get_last_search_count(), start=index) else: self._header = YoutubeHeader() self._list = VideoListYoutube(page=page) if search_keyword and search_keyword.get_text() is not '': navigation_grid = Gtk.Grid() self._grid.attach(navigation_grid, 0, 3, 1, 1) prev_button = Gtk.Button('Back') prev_button.get_style_context().add_class('green') prev_button.connect('clicked', self._switch_page, page - 1, search_keyword) navigation_grid.attach(prev_button, 0, 0, 1, 1) if page == 1: prev_button.set_sensitive(False) navigation_grid.attach(Gtk.Label('', hexpand=True), 1, 0, 1, 1) next_button = Gtk.Button('Next') next_button.get_style_context().add_class('green') next_button.connect('clicked', self._switch_page, page + 1, search_keyword) navigation_grid.attach(next_button, 2, 0, 1, 1) self.refresh()