Overview
Context
Changes
Modified channels/_generic.py
from [6c89a69b5c]
to [80b2da3d25] .
182
183
184
185
186
187
188
189
190
191
192
193
194
195 182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
+
+
# load data,
# update treeview content
def load ( self , category , force = False ):
# get data from cache or download
if ( force or not category in self . streams ):
__print__ ( dbg . PROC , "load" , "update_streams" )
self . parent . status ( "Updating streams..." )
self . parent . status (- 0.1 )
new_streams = self . update_streams ( category )
if new_streams :
# check and modify entry;
# assert that title and url are present
modified = []
227
228
229
230
231
232
233
234
235
236
237
238
239
240 229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
+
+
# self.gtk_list.set_model(self.liststore[category])
#else : # currently list is new, had not been converted to gtk array before
# self.liststore[category] = \
mygtk . do ( lambda : mygtk . columns ( self . gtk_list , self . datamap , self . prepare ( self . streams [ category ])))
# set pointer
self . current = category
self . parent . status ( "" )
self . parent . status ( 1.0 )
pass
# store current streams data
def save ( self ):
conf . save ( "cache/" + self . module , self . streams , gz = 1 )
Modified channels/youtube.py
from [2213612999]
to [068cf22437] .
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191 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 ]
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" }) )
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238 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
self . parent . status ( 1.0 )
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 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( defaults.items() | params.items() )
params = dict ( defaults , ** params )
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 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 ( ( 1 1 - 1.852 * pages ) / 10. 0 )
self . parent . status ( ( 1 0 - 1.852 * pages ) / 10. 5 )
return items
# Wrap API 3.0 result into streams row
def wrap3 ( self , row , data ):
Modified st2.py
from [9efbd2b2e3]
to [131924495a] .
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439 418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
-
-
-
sbar_cid = self . get_widget ( "statusbar" ). get_context_id ( "messages" )
# remove text
while (( not text ) and ( type ( text )== str ) and len ( sbar_msg )):
sbar_msg . pop ()
mygtk . do ( lambda : self . statusbar . pop ( sbar_cid ))
# progressbar
if ( type ( text )== float ):
__print__ ( dbg . PROC , "status.progressbar" , float , text )
if ( text >= 999.0 / 1000 ): # completed
mygtk . do ( lambda : self . progress . hide ())
else : # show percentage
__print__ ( dbg . PROC , "status.progressbar" , dbg . ERR , "fraction" )
mygtk . do ( lambda : self . progress . show () or self . progress . set_fraction ( text ))
if ( text <= 0 ): # unknown state
__print__ ( dbg . PROC , "status.progressbar" , dbg . STAT , "PULSE" )
mygtk . do ( lambda : self . progress . pulse ())
# add text
elif ( type ( text )== str ):
sbar_msg . append ( 1 )
mygtk . do ( lambda : self . statusbar . push ( sbar_cid , text ))
pass