|
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191 |
# 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))
for row in self.api("videos", chart="mostPopular", regionCode=conf.youtube_region):
entries.append( self.wrap3(row, {"genre": "mostPopular"}) ) |
<
| 177
178
179
180
181
182
183
184
185
186
187
188
189
190 |
# retrieve and parse
def update_streams(self, cat, force=0, search=None):
entries = []
channels = self.categories[self.categories.index("my channels") + 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))
for row in self.api("videos", chart="mostPopular", regionCode=conf.youtube_region):
entries.append( self.wrap3(row, {"genre": "mostPopular"}) ) |
|
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238 | entries.append( self.wrap3(row, {"genre": ""}) )
# 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:
def channel_id(self, title):
id = self.channel2id.get(title) |
<
| 223
224
225
226
227
228
229
230
231
232
233
234
235
236 | entries.append( self.wrap3(row, {"genre": ""}) )
# empty entries
else:
entries = [dict(title="Placeholder for subcategories", genre="./.", playing="./.", url="http://youtube.com/")]
# done
return entries
# Search for channel name:
def channel_id(self, title):
id = self.channel2id.get(title) |
|
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264 | #-- Retrieve Youtube API query results
#
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, **params )
# Retrieve data set
while pages > 0:
j = ahttp.get(base_url + method, params=params)
#__print__(dbg.DATA, j)
if j:
# json decode |
<
|
| 247
248
249
250
251
252
253
254
255
256
257
258
259
260
261 | #-- Retrieve Youtube API query results
#
def api(self, method, ver=3, pages=5, **params):
items = []
# URL and default parameters
(base_url, defaults) = self.service[ver]
params = dict( list(defaults.items()) + list(params.items()) )
# Retrieve data set
while pages > 0:
j = ahttp.get(base_url + method, params=params)
#__print__(dbg.DATA, j)
if j:
# json decode |
|
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292 | 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( (11 - 1.852 * pages) / 10.0 )
return items
# Wrap API 3.0 result into streams row
def wrap3(self, row, data): |
|
| 275
276
277
278
279
280
281
282
283
284
285
286
287
288
289 | 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( (10 - 1.852 * pages) / 10.5 )
return items
# Wrap API 3.0 result into streams row
def wrap3(self, row, data): |
|