def grab_random_fanart(controlNum, special): global fanart get_fanart_list() if len(fanart) == 0: return # sometimes the list control isn't available yet onload # so add some checking to make sure control = common.get_control(controlNum, special) count = 10 while control == "" and count > 0: time.sleep(0.25) control = common.get_control(controlNum, special) count = count - 1 window = common.get_window_id(special) if control == "": pass else: while 1: if xbmcgui.getCurrentWindowDialogId() == 9999: art = fanart[fanart.keys()[randint(0, len(fanart) - 1)]] if art != "": art = "$COMMA".join(art.split(",")) xbmc.executebuiltin("Skin.SetString(random-fanart,%s)" % art) count = 4 while count > 0: if window != common.get_window_id(special): return time.sleep(2) count = count - 1
def grab_random_fanart(controlNum, special): global fanart get_fanart_list(True) if len(fanart) == 0: return # sometimes the list control isn't available yet onload # so add some checking to make sure control = common.get_list(controlNum, special) count = 10 while control == "" and count > 0: time.sleep(0.25) control = common.get_list(controlNum, special) count = count - 1 window = common.get_window_id(special) if control == "": pass else: item = control.GetItem(0) while 1: if xbmcgui.getCurrentWindowDialogId() == 9999: art = fanart[fanart.keys()[randint(0, len(fanart) - 1)]].encode("utf-8") item.SetProperty("fanart", str(art)) count = 5 while count > 0: if window != common.get_window_id(special): return time.sleep(2) count = count - 1
def grab_fanart_list(listNum, special): global fanart_changed get_fanart_list() # sometimes the list control isn't available yet onload # so add some checking to make sure lst = common.get_list(listNum, special) count = 10 while lst == "" and count > 0: time.sleep(0.25) lst = common.get_list(listNum, special) count = count - 1 window = common.get_window_id(special) if lst == "": pass else: # as long as the list exists (while the window exists) # the list gets updated at regular intervals. otherwise # the fanart disappears when you change sort-orders or # select a genre # should have very little overhead because all the values # get cached in memory focusedItem = "" while 1: # don't spend any time doing stuff if a dialog is open # 9999 is the dialog number when no dialogs are open # if special == True then the scanning is happening in # a dialog so we DO continue processing if xbmcgui.getCurrentWindowDialogId() == 9999 or special: newFocusedItem = mc.GetInfoString("Container(%s).ListItem.Label" % listNum) newFocusedItem = str(newFocusedItem) if newFocusedItem != focusedItem and newFocusedItem != "": lst = common.get_list(listNum, special) if lst != "": items = lst.GetItems() if len(items) > 0: for item in items: grab_fanart_for_item(item) focusedItem = newFocusedItem del items if window != common.get_window_id(special): return time.sleep(2) # store the fanart list for next time if the list # was modified if fanart_changed == 1: store_fanart_list()
def grab_fanart_list(listNum, special): global fanart_changed get_fanart_list(False) # sometimes the list control isn't available yet onload # so add some checking to make sure lst = common.get_list(listNum, special) count = 10 while lst == "" and count > 0: time.sleep(0.25) lst = common.get_list(listNum, special) count = count - 1 window = common.get_window_id(special) if lst == "": pass else: # as long as the list exists (while the window exists) # the list gets updated at regular intervals. otherwise # the fanart disappears when you change sort-orders or # select a genre # should have very little overhead because all the values # get cached in memory focusedItem = "" while 1: # don't spend any time doing stuff if a dialog is open # 9999 is the dialog number when no dialogs are open # if special == True then the scanning is happening in # a dialog so we DO continue processing if xbmcgui.getCurrentWindowDialogId() == 9999 or special: theItem = mc.GetInfoString("Container(%s).ListItem.Label" % listNum) theItem = str(theItem) if theItem != "": newFocusedItem = theItem else: newFocusedItem = focusedItem if (newFocusedItem != focusedItem and newFocusedItem != "") or (newFocusedItem == "" and special): lst = common.get_list(listNum, special) if lst != "": items = lst.GetItems() if len(items) > 0: if newFocusedItem == "": newFocusedItem = items[0].GetLabel() for item in items: grab_fanart_for_item(item) focusedItem = newFocusedItem del items if window != common.get_window_id(special): return time.sleep(2) # store the fanart list for next time if the list # was modified if fanart_changed == 1: store_fanart_list()