@@ -360,25 +360,30 @@ def widgets_changed_by_watching(media_type):
360360
361361 count_prob_changed = 0
362362 randoms = 0
363+ i = 0
363364 for chance , path , history_path in priority :
364365 hash = path2hash (path )
365- if chance >= 0.3 :
366+ if "page=" in path :
367+ # HACK: must be a better way
368+ continue
369+ elif chance >= 0.3 or i < 7 :
366370 utils .log (
367- "Queue {:.2 }% {} {}" .format (chance * 100 , hash [:5 ], path ),
371+ "Queue {:.2f }% {} {}" .format (chance * 100 , hash [:5 ], path ),
368372 "notice" ,
369373 )
370374 count_prob_changed += 1
371375 yield hash , path
372376 elif random .random () <= (1 / len (priority )):
373377 # If widgets never get updated after playback we never get to know if they change after playback. So always pick some randomly
374- utils .log ("Queue random {:.2 }% {} {}" .format (chance * 100 , hash [:5 ], path ), 'notice' )
378+ utils .log ("Queue random {:.2f }% {} {}" .format (chance * 100 , hash [:5 ], path ), 'notice' )
375379 randoms += 1
376380 yield hash , path
377381 else :
378- utils .log ("Prob not changes due to playback {:.2}% {} {}" .format (chance * 100 , hash [:5 ], path ), 'notice' )
382+ utils .log ("Prob not changes due to playback {:.2f}% {} {}" .format (chance * 100 , hash [:5 ], path ), 'notice' )
383+ i += 1
379384 utils .log ("=== End Widget update: {} prob changed after playback {} randoms" .format (count_prob_changed , randoms ), 'notice' )
380385
381- def chance_playback_updates_widget (cache_data , plays , cutoff_time = 60 * 60 * 24 * 30 ):
386+ def chance_playback_updates_widget (cache_data , plays , cutoff_time = 60 * 60 ):
382387 history = cache_data .setdefault ("history" , [])
383388 hist_len = len (history )
384389 path = cache_data .get ("path" , "" )
@@ -390,32 +395,34 @@ def chance_playback_updates_widget(cache_data, plays, cutoff_time=60 * 60 * 24 *
390395 # C C P C C
391396 changes , non_changes , unrelated_changes , too_late_changes = 0 , 0 , 0 , 0
392397 update = ""
393- update_time = None
394- time_since_play = 0
398+ update_time = 0
395399 for play_time , media_type in plays :
396- while True :
400+ while ( update_time - play_time ) <= 0 :
397401 last_update = update
398402 last_update_time = update_time
399403 if not history :
400404 break
401405 update_time , update = history .pop (0 )
402- time_since_play = update_time - play_time
403406 # log("{} {} {} {}".format(update[:5],last_update[:5], unrelated_changes, time_since_play), 'notice')
404- if time_since_play > 0 :
407+ if ( update_time - play_time ) > 0 :
405408 break
406409 elif update != last_update :
407410 # Update that happened with no play inbetween
408411 unrelated_changes += 1
409412 # We now have a update after a playback
410-
411- if update == last_update :
413+ if not update_time :
414+ break
415+ elif not last_update :
416+ # haven't got to first update yet
417+ pass
418+ elif update == last_update :
412419 if update_time == last_update_time :
413420 # Two playbacks without any updates
414421 pass
415422 else :
416423 # Didn't change after playback
417424 non_changes += 1
418- elif time_since_play <= cutoff_time :
425+ elif ( update_time - play_time ) <= cutoff_time :
419426 # Did change after playback
420427 changes += 1
421428 else :
@@ -438,13 +445,13 @@ def chance_playback_updates_widget(cache_data, plays, cutoff_time=60 * 60 * 24 *
438445 # we have no data or lost it. let's get it updated
439446 prob = 1.0
440447 else :
441- prob = (changes + too_late_changes ) / all_changes
448+ prob = (changes ) / all_changes
442449 unknown_weight = 4
443450 prob = (prob * datapoints + 0.5 * unknown_weight ) / (datapoints + unknown_weight )
444451
445452 utils .log (
446- "prob:{} changes:{} non_changes:{} non_play_changes:{} too_late:{} plays:{} hist:{}: {}" .format (
447- prob , changes , non_changes , unrelated_changes , too_late_changes , len (plays ), hist_len , path ,
453+ "prob:{:.2f}% changes:{} non_changes:{} non_play_changes:{} too_late:{} plays:{} hist:{}: {}" .format (
454+ prob * 100 , changes , non_changes , unrelated_changes , too_late_changes , len (plays ), hist_len , path ,
448455 ),
449456 "notice" ,
450457 )
0 commit comments