def update(cls, force=False): manager = request_manager.getManager() d = manager.get(cls.DATA_URL, forceReload=force) j = json.loads(d) data = {} for cardId_s in j: info = j[cardId_s] cardId = int(cardId_s) data[cardId] = info cls.DATA = data cls.INITIALIZED = True
def updateHash(cls, force=False): manager = getManager() d = manager.get(cls.HASH_URL, forceReload=force) j = json.loads(d) data = {} for hashStr in j: cardId = j[hashStr] h = cls.stringToHash(hashStr) data[h] = int(cardId) cls.HASHTABLE = data cls.INITIALIZED = True
def updateMeta(cls, force=False): manager = getManager() d = manager.get(cls.META_URL, forceReload=force) j = json.loads(d) data = {} for songId_s in j: info = j[songId_s] songId = int(songId_s) meta = SongMeta.loadFromBestdori(songId, info) data[songId] = meta cls.DATA = data cls.INITIALIZED = True pass
def notes(self): if self._notes is None: # populate manager = getManager() s = manager.get( self.NOTES_SIMPLE_URL.format( self.id, self.DIFFICULTY_STR[self.difficulty])) j = json.loads(s) self._notes = [] for n in j: note = SongNote(n['time'], n.get('skill', False), n.get('fever', False)) self._notes.append(note) return self._notes
data = {} for songId_s in j: info = j[songId_s] songId = int(songId_s) meta = SongMeta.loadFromBestdori(songId, info) data[songId] = meta cls.DATA = data cls.INITIALIZED = True pass @classmethod def cacheAllSongs(cls, difficulty=None): if difficulty is None: difficulty = {0, 1, 2, 3, 4} if not cls.INITIALIZED: cls.updateMeta() for songId in cls.DATA: print(songId) meta = cls.DATA[songId] for d in meta.difficulties.intersection(difficulty): _ = meta[d].notes meta[d].freeCache() if __name__ == '__main__': try: SongManager.updateMeta() SongManager.cacheAllSongs() finally: getManager().saveCacheIndex()