def __init__(self): self.timeout = 0 self.artists_tags = {} if cache.exists('artists_tags'): self.artists_tags = cache.read('artists_tags') self.albums_tags = {} if cache.exists('albums_tags'): self.albums_tags = cache.read('albums_tags')
def get_all_songs_tags(self, update=False): if self.all_songs_tags is not None and not update: pass elif cache.exists('songs_tags') and not update: self.all_songs_tags = cache.read('songs_tags') else: self.all_songs_tags = collections.OrderedDict() for song in self.mpdclient.listallinfo(): if 'file' in song: self.all_songs_tags[song['file']] = { 'artist': self.clear_tag(song.get('artist', '')), 'albumartist': self.clear_tag(song.get('albumartist', song.get('artist', ''))), 'album': self.clear_tag(song.get('album', '')), 'title': self.clear_tag(song.get('title', '')), 'track': self.clear_tag(song.get('track', '')) } cache.write('songs_tags', self.all_songs_tags) return self.all_songs_tags
def feed(self, force=False): if cache.exists('collections') and not force: self.collections = cache.read('collections') else: with open(self.path, 'r') as f: self.collections = raw_to_optimized(f.readlines())