# 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
    metadata = get_metadata(full_path)

    key = tuple([metadata.get(k) for k in ('artist', 'title', 'album')])

    if not any(key):
        key = hashlib.md5(full_path).hexdigest()

    return key

class AudioIndex(threading.Thread):
    RE_SEARCH_TOKENS = re.compile(r'\b([^\:]+):("[^"]*"|[^\s]*)')

    def __init__(self, app, filter_keys, text_keys):
        super(AudioIndex, self).__init__()
        self.app = app
        self.filter_keys = filter_keys
        self.text_keys = text_keys
        self.tokenized = defaultdict(lambda:defaultdict(int))
        self.filters = defaultdict(lambda:defaultdict(list))
        self.filters_ci = defaultdict(lambda:defaultdict(list))
        self.metadata = defaultdict(dict)
        self.files = {}
        self._data_file = os.path.join(self.app.config['DATA_PATH'], 'index.db')
        self._ready = False

    def __len__(self):
        return len(self.files)

    def run(self):
        if os.path.exists(self._data_file):

# 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

    metadata = get_metadata(full_path)

    key = tuple([metadata.get(k) for k in ('artist', 'title', 'album')])

    if not any(key):
        key = hashlib.md5(full_path).hexdigest()

    return key

class AudioIndex(threading.Thread):
    RE_SEARCH_TOKENS = re.compile(r'\b([^\:]+):("[^"]*"|[^\s]*)')

    def __init__(self, app, filter_keys, text_keys):
        super(AudioIndex, self).__init__()
        self.app = app
        self.filter_keys = filter_keys
        self.text_keys = text_keys
        self.tokenized = defaultdict(lambda:defaultdict(int))
        self.filters = defaultdict(lambda:defaultdict(list))
        self.filters_ci = defaultdict(lambda:defaultdict(list))
        self.metadata = defaultdict(dict)
        self.files = {}
        self._data_file = os.path.join(self.app.config['DATA_PATH'], 'index.db')
        self._ready = False

    def __len__(self):
        return len(self.files)

    def run(self):
        if os.path.exists(self._data_file):

            self.load()