# Path: playa/common/storage.py
# def load(path):
#     start = time.time()
# 
#     print "Loading %s" % path
# 
#     with open(path, 'rb') as fp:
#         try:
#             result = pickle.load(fp)
#         except EOFError:
#             return
# 
#     print "Done! (took %.2fs)" % (time.time() - start)
# 
#     return result
# 
# def save(path, data):
#     start = time.time()
# 
#     print "Saving %s" % path
# 
#     with open(path, 'wb') as fp:
#         pickle.dump(data, fp)
#     
#     print "Done! (took %.2fs)" % (time.time() - start)


import hashlib
import os.path
import re
import time
import threading
from collections import defaultdict
from mutagen.easymp4 import EasyMP4
from mutagen.mp3 import EasyMP3
from playa.common.storage import load, save
                    del self.files[key]

            for path in self.app.config['AUDIO_PATHS']:
                self.add_path(path)

            print "Done! (%d entries, took %.2fs)" % (len(self), time.time() - start)

            self._ready = True

            if self.files.keys() != prev:
                self.save()
            
            time.sleep(3)
        
    
    def load(self):
        results = load(self._data_file)
        if not results:
            return
        
        for k, v in results.iteritems():
            if k == 'files' and not isinstance(v, dict):
                continue
            
            if isinstance(v, dict):
                getattr(self, k).update(v)
            else:
                setattr(self, k, v)

    def save(self):

# Path: playa/common/storage.py
# def load(path):
#     start = time.time()
# 
#     print "Loading %s" % path
# 
#     with open(path, 'rb') as fp:
#         try:
#             result = pickle.load(fp)
#         except EOFError:
#             return
# 
#     print "Done! (took %.2fs)" % (time.time() - start)
# 
#     return result
# 
# def save(path, data):
#     start = time.time()
# 
#     print "Saving %s" % path
# 
#     with open(path, 'wb') as fp:
#         pickle.dump(data, fp)
#     
#     print "Done! (took %.2fs)" % (time.time() - start)


# Path: playa/ext/audio/index.py
import hashlib
import os.path
import re
import time
import threading
from collections import defaultdict
from mutagen.easymp4 import EasyMP4
from mutagen.mp3 import EasyMP3
from playa.common.storage import load, save

                    del self.files[key]

            for path in self.app.config['AUDIO_PATHS']:
                self.add_path(path)

            print "Done! (%d entries, took %.2fs)" % (len(self), time.time() - start)

            self._ready = True

            if self.files.keys() != prev:
                self.save()
            
            time.sleep(3)
        
    
    def load(self):
        results = load(self._data_file)
        if not results:
            return
        
        for k, v in results.iteritems():
            if k == 'files' and not isinstance(v, dict):
                continue
            
            if isinstance(v, dict):
                getattr(self, k).update(v)
            else:
                setattr(self, k, v)

    def save(self):

        save(self._data_file, {