Index: channels/youtube.py ================================================================== --- channels/youtube.py +++ channels/youtube.py @@ -85,13 +85,14 @@ ] } categories = [ "mostPopular", - ["Music", "Comedy", "Movies", "Shows", "Short Movies", "Trailers", "Film & Animation", "Entertainment", "News & Politics", "Sci-Fi/Fantasy"], + ["Music", "Comedy", "Movies", "Shows", "Short Movies", "Trailers", "Film & Animation", "Entertainment", "News & Politics"], "topics", - ["music", "pop", "music video"], + ["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"] ] # plugin settings @@ -147,13 +148,27 @@ "Shows": 43, "Trailers": 44, } # Freebase topics topic_id = { - "music": "/m/0kpv0g", "pop": "/m/064t9", - "music video": "/m/05k5h7g", + "billboard charts": "/m/04qf57", + "rock": "/m/06by7", + "dance": "/m/0ggx5q", + "classical": "/m/0ggq0m", + "hip hop": "/m/0glt670", + "soundtrack": "/m/0l14gg", + "ambient": "/m/0fd3y", + "electronica": "/m/0m0jc", + "jazz": "/m/03_d0", + "techno": "/m/07gxw", + "disco": "/m/026z9", + "country": "/m/01lyv", + "blues": "/m/0155w", + "soul": "/m/0gywn", + "trance": "/m/07lnk", + "house": "/m/03mb9", } # just a static list for now def update_categories(self): @@ -164,10 +179,11 @@ # retrieve and parse def update_streams(self, cat, force=0, search=None): entries = [] channels = self.categories[self.categories.index("my channels") + 1] + self.parent.status(-0.1) # Most Popular if cat == "mostPopular": #for row in self.api("feeds/api/standardfeeds/%s/most_popular"%conf.youtube_region, ver=2): # entries.append(self.wrap2(row)) @@ -178,12 +194,12 @@ elif cat in self.videocat_id: for row in self.api("search", chart="mostPopular", videoCategoryId=self.videocat_id[cat], order="date", type="video"): entries.append( self.wrap3(row, {"genre": cat}) ) # Topics - elif cat in self.topic_id: - for row in self.api("search", order="date", regionCode=conf.youtube_region, topicId=self.topic_id[cat], type="video"): + elif cat.lower() in self.topic_id: + for row in self.api("search", order="date", regionCode=conf.youtube_region, topicId=self.topic_id[cat.lower()], type="video"): entries.append( self.wrap3(row, {"genre": cat}) ) # My Channels # - searches channel id for given title # - iterates over playlist @@ -210,10 +226,11 @@ # empty entries else: entries = [dict(title="Placeholder for subcategories", genre="./.", playing="./.", url="http://youtube.com/")] # done + self.parent.status(1.0) return entries # Search for channel name: @@ -234,16 +251,17 @@ def api(self, method, ver=3, pages=5, **params): items = [] # URL and default parameters (base_url, defaults) = self.service[ver] - params = dict(defaults.items() + params.items()) + #params = dict( defaults.items() | params.items() ) + params = dict( defaults, **params ) # Retrieve data set while pages > 0: j = ahttp.get(base_url + method, params=params) - __print__(dbg.DATA, j) + #__print__(dbg.DATA, j) if j: # json decode data = json.loads(j) # extract items @@ -253,20 +271,20 @@ items += data["feed"]["entry"] else: pages = 0 # Continue to load results? - if items >= conf.max_streams: + if len(items) >= int(conf.max_streams): pages = 0 elif "pageInfo" in data and data["pageInfo"]["totalResults"] < 50: pages = 0 elif "nextPageToken" in data: params["pageToken"] = data["nextPageToken"] pages -= 1 else: pages = 0 - self.parent.status(pages / 10.0) + self.parent.status( (11 - 1.852 * pages) / 10.0 ) return items