Index: channels/youtube.py ================================================================== --- channels/youtube.py +++ channels/youtube.py @@ -61,10 +61,11 @@ # description title = "Youtube" module = "youtube" homepage = "http://www.youtube.com/" listformat = "url/youtube" + has_search = True fmt = "video/youtube" titles = dict( genre="Channel", title="Title", playing="Playlist", bitrate=False, listeners=False ) # API config service = { @@ -85,11 +86,11 @@ ] } categories = [ "mostPopular", - ["Music", "Comedy", "Movies", "Shows", "Short Movies", "Trailers", "Film & Animation", "Entertainment", "News & Politics"], + ["Music", "Comedy", "Movies", "Shows", "Trailers", "Film & Animation", "Entertainment", "News & Politics"], "topics", ["Pop", "Billboard charts", "Rock", "Hip Hop", "Classical", "Soundtrack", "Ambient", "Jazz", "Blues", "Soul", "Country", "Disco", "Dance", "House", "Trance", "Techno", "Electronica"], "my channels", ["Key of Awesome", "Pentatonix"] @@ -175,17 +176,22 @@ i = self.categories.index("my channels") + 1 self.categories[i] = [ title.strip() for title in conf.youtube_channels.split(",") ] # retrieve and parse - def update_streams(self, cat, force=0, search=None): + def update_streams(self, cat, search=None): entries = [] channels = self.categories[self.categories.index("my channels") + 1] + # plain search request for videos + if search is not None: + for row in self.api("search", type="video", regionCode=conf.youtube_region, q=search): + entries.append( self.wrap3(row, {"genre": "Youtube"}) ) + # Most Popular - if cat == "mostPopular": + elif cat == "mostPopular": #for row in self.api("feeds/api/standardfeeds/%s/most_popular"%conf.youtube_region, ver=2): # entries.append(self.wrap2(row)) for row in self.api("videos", chart="mostPopular", regionCode=conf.youtube_region): entries.append( self.wrap3(row, {"genre": "mostPopular"}) ) @@ -215,14 +221,10 @@ entries.append(self.wrap3(row, {"genre": cat, "playing": playlist["snippet"]["title"]})) self.update_streams_partially_done(entries) self.parent.status(i / 15.0) - # plain search request for videos - elif search is not None: - for row in self.api("search", type="video", regionCode=conf.youtube_region, q=search): - entries.append( self.wrap3(row, {"genre": ""}) ) # empty entries else: entries = [dict(title="Placeholder for subcategories", genre="./.", playing="./.", url="http://youtube.com/")] Index: gtk2.xml ================================================================== --- gtk2.xml +++ gtk2.xml @@ -1067,10 +1067,20 @@ + + True + False + gtk-harddisk + + + True + False + gtk-add + False 5 station search center-on-parent @@ -1089,84 +1099,23 @@ True False end - - cancel - True - True - True - - - - False - False - 0 - - - - - True - True - - - False - False - 1 - - - - - google it - True - True - True - Instead of searching in the station list, just look up the above search term on google. - half - - - - False - False - 2 - - - - - query srv - True - False - True - Instead of doing a cache search, go through the search functions on the directory service homepages. (UNIMPLEMENTED) - half - - - - False - False - 3 - - - - - cache _search - True - False - True - True - True - Start searching for above search term in the currently loaded station lists. Doesn't find *new* information, just looks through the known data. - True - - - - - False - False - 4 - + + + + + + + + + + + + + False False @@ -1191,845 +1140,11 @@ True 0 - - True - False - Which channels/directories to look through. - 4 - 4 - 5 - 1 - True - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - all channels - True - True - False - True - True - - - - - True - True - 1 - + True False @@ -2082,193 +1197,58 @@ True 2 - + + + + + + + True False - In which fields to look for the search term. - 3 - True + 20 - - + + Cache _find True - True + False + True + True True - none + Start searching for above search term in the currently loaded station lists. Doesn't find *new* information, just looks through the known data. + image1 + half + True + + - False - False + True + True 0 - - in title + + Server _search True - True - False - True - True + False + True + Instead of doing a cache search, go through the search functions on the directory service homepages. (UNIMPLEMENTED) + image2 + True + True True 1 - - - in description - True - True - False - True - True - - - True - True - 2 - - - - - any fields - True - True - False - True - - - True - True - 3 - - - - - - True - True - True - none - - - False - False - 4 - - - - - True - True - 3 - - - - - True - False - In which fields to look for the search term. - 3 - True - - - - True - True - True - none - - - False - False - 0 - - - - - homepage url - True - True - False - True - True - - - True - True - 1 - - - - - extra info - True - True - False - True - - - True - True - 2 - - - - - and genre - True - True - False - True - - - True - True - 3 - - - - - - True - True - True - none - - - False - False - 4 - - - - - True - True - 4 - - - - - True - False - - - - - - - - - True True 5 @@ -2281,17 +1261,10 @@ 1 - - cancel - togglebutton1 - google_search - server_search - cache_search - True False @@ -2748,10 +1721,28 @@ + + + + + + + + + + + + + + + + + + True True @@ -2766,10 +1757,13 @@ 2 1 2 + + + @@ -3294,12 +2288,12 @@ True False bookmark True - + @@ -3306,12 +2300,12 @@ gtk-save-as True False True True - + @@ -3318,13 +2312,13 @@ gtk-edit True False True True - + - + @@ -3393,12 +2387,12 @@ gtk-delete True False True True - + Index: gtk3.xml ================================================================== --- gtk3.xml +++ gtk3.xml @@ -794,11 +794,10 @@ True True - 30 False False True @@ -1057,10 +1056,20 @@ + + True + False + gtk-harddisk + + + True + False + gtk-add + False 0.95999999999999996 5 station search @@ -1079,84 +1088,23 @@ True False end - - cancel - True - True - True - - - - False - False - 0 - - - - - True - True - - - False - False - 1 - - - - - google it - True - True - True - Instead of searching in the station list, just look up the above search term on google. - half - - - - False - False - 2 - - - - - query srv - True - False - True - Instead of doing a cache search, go through the search functions on the directory service homepages. (UNIMPLEMENTED) - half - - - - False - False - 3 - - - - - cache _search - True - False - True - True - True - Start searching for above search term in the currently loaded station lists. Doesn't find *new* information, just looks through the known data. - True - - - - - False - False - 4 - + + + + + + + + + + + + + False False @@ -1181,936 +1129,11 @@ True 0 - - True - False - Which channels/directories to look through. - 4 - 4 - 5 - 1 - True - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - all channels - True - True - False - 0.5 - True - True - - - - - True - True - 1 - + True False @@ -2161,199 +1184,58 @@ True 2 - + + + + + + + True False - In which fields to look for the search term. - 3 - True + 20 - - + + Cache _find True - True + False + True + True True - none + Start searching for above search term in the currently loaded station lists. Doesn't find *new* information, just looks through the known data. + image1 + half + True + + - False - False + True + True 0 - - in title + + Server _search True - True - False - 0.5 - True - True + False + True + Instead of doing a cache search, go through the search functions on the directory service homepages. (UNIMPLEMENTED) + image2 + True + True True 1 - - - in description - True - True - False - 0.5 - True - True - - - True - True - 2 - - - - - any fields - True - True - False - 0.5 - True - - - True - True - 3 - - - - - - True - True - True - none - - - False - False - 4 - - - - - True - True - 3 - - - - - True - False - In which fields to look for the search term. - 3 - True - - - - True - True - True - none - - - False - False - 0 - - - - - homepage url - True - True - False - 0.5 - True - True - - - True - True - 1 - - - - - extra info - True - True - False - 0.5 - True - - - True - True - 2 - - - - - and genre - True - True - False - 0.5 - True - - - True - True - 3 - - - - - - True - True - True - none - - - False - False - 4 - - - - - True - True - 4 - - - - - True - False - - - - - - - - - True True 5 @@ -2366,17 +1248,10 @@ 1 - - cancel - togglebutton1 - google_search - server_search - cache_search - True False Index: st2.py ================================================================== --- st2.py +++ st2.py @@ -215,13 +215,12 @@ "menu_copy": self.menu_copy, "delete_entry": self.delete_entry, # search dialog "quicksearch_set": search.quicksearch_set, "search_open": search.menu_search, - "search_go": search.start, - "search_srv": search.start, - "search_google": search.google, + "search_go": search.cache_search, + "search_srv": search.server_search, "search_cancel": search.cancel, "true": lambda w,*args: True, # win_streamedit "streamedit_open": streamedit.open, "streamedit_save": streamedit.save, @@ -593,66 +592,69 @@ # hide dialog box again def cancel(self, *args): self.search_dialog.hide() return True # stop any other gtk handlers - - # perform search - def start(self, *w): + + # prepare variables + def prepare_search(self): + main.status("Searching... Stand back.") self.cancel() - - # prepare variables self.q = self.search_full.get_text().lower() - entries = [] main.bookmarks.streams["search"] = [] + # perform search + def cache_search(self, *w): + self.prepare_search() + entries = [] # which fields? - fields = ["title", "playing", "genre", "homepage", "url", "extra", "favicon", "format"] - if not self.search_in_all.get_active(): - fields = [f for f in fields if (main.get_widget("search_in_"+f) and main.get_widget("search_in_"+f).get_active())] + fields = ["title", "playing", "homepage"] + #if not self.search_in_all.get_active(): + # fields = [f for f in fields if (main.get_widget("search_in_"+f) and main.get_widget("search_in_"+f).get_active())] # channels? channels = main.channel_names[:] - if not self.search_channel_all.get_active(): - channels = [c for c in channels if main.get_widget("search_channel_"+c).get_active()] - - # step through channels + #if not self.search_channel_all.get_active(): + # channels = [c for c in channels if main.get_widget("search_channel_"+c).get_active()] for c in channels: if main.channels[c] and main.channels[c].streams: # skip disabled plugins - # categories for cat in main.channels[c].streams.keys(): - # stations for row in main.channels[c].streams[cat]: - - # assemble text fields + # assemble text fields to compare text = " ".join([row.get(f, " ") for f in fields]) - - # compare if text.lower().find(self.q) >= 0: - - # add result + row["genre"] = c + " " + row["genre"] entries.append(row) + self.show_results(entries) - - # display "search" in "bookmarks" + # display "search" in "bookmarks" + def show_results(self, entries): + main.status(1.0) main.channel_switch(None, "bookmarks", 0) main.bookmarks.set_category("search") # insert data and show main.channels["bookmarks"].streams["search"] = entries # we have to set it here, else .currentcat() might reset it main.bookmarks.load("search") # live search on directory server homepages - def server_query(self, w): - "unimplemented" - - - # don't search at all, open a web browser - def google(self, w): - self.cancel() - action.browser("http://www.google.com/search?q=" + self.search_full.get_text()) + def server_search(self, w): + self.prepare_search() + entries = [] + for i,cn in enumerate([main.channels[c] for c in main.channels]): +# main.status(main, 1.0 * i / 15) + if cn.has_search: + __print__(dbg.PROC, "has_search:", cn.module) + try: + add = cn.update_streams(cat=None, search=self.q) + for row in add: + row["genre"] = cn.title + " " + row["genre"] + entries += add + except: + continue + self.show_results(entries) # search text edited in text entry box def quicksearch_set(self, w, *eat, **up): @@ -957,11 +959,11 @@ # content categories = ["favourite", ] # timer, links, search, and links show up as needed current = "favourite" default = "favourite" - streams = {"favourite":[], "search":[], "scripts":[], "timer":[], } + streams = {"favourite":[], "search":[], "scripts":[], "timer":[], "history":[], } # cache list, to determine if a PLS url is bookmarked urls = []