def update(self, settings): configPlaylists = [] count = 1 while count <= MAX_PLAYLIST: property = 'service.skin.smartplaylist.widgets.SmartPlaylist%s' %count if helper.get_property(property) != '': configPlaylists.append({'alias': property, 'path': helper.get_property(property)}) count += 1 newPlaylistPath = [playlist['path'] for playlist in configPlaylists] for playlist in [playlist for playlist in self.__playlists if playlist.playlistPath not in newPlaylistPath]: playlist.clean() self.__playlists.remove(playlist) for existingPlaylists in [existingPlaylist for existingPlaylist in self.__playlists if existingPlaylist.playlistPath in [playlist['path'] for playlist in configPlaylists]]: existingPlaylist.clean() for playlist in configPlaylists: existingPlaylists = [existingPlaylist for existingPlaylist in self.__playlists if existingPlaylist.playlistPath == playlist['path']] if len(existingPlaylists) > 0: for existingPlaylist in existingPlaylists: existingPlaylist.update_settings(playlist['alias'], settings) else: self.__register(playlist['alias'], playlist['path'], settings)
def __daemon(self): home_update = False timer = 0 while (not xbmc.abortRequested): xbmc.sleep(500) if helper.get_property('service.skin.smartplaylist.widgets.ReloadSettings') == 'true': helper.set_property('service.skin.smartplaylist.widgets.ReloadSettings', 'false') self.__on_settings_changed_cb() if int(self.__settings.getSetting("random_method")) == 0 : # convert time to seconds, times 2 for 0,5 second sleep compensation targetTimet = int(float(self.__settings.getSetting("random_timer"))) * 60 * 2 timer += 1 if timer == targetTimet: self.__collection.update_all_playlists(['Random']) timer = 0 if int(self.__settings.getSetting("random_method")) == 2 : if home_update and helper.is_home_screen(): self.__collection.update_all_playlists(['Random']) home_update = False elif not home_update and not helper.is_home_screen(): home_update = True