Ejemplo n.º 1
0
def load_all():
    """
    Load information about the music library in the filesystem and
    insert them to the database.
    """
    last_load_time = _get_last_load_time()
    tracks = list()
    db = db_manager.DBLoader()
    for current in [_LIBRARY_DIR] + os.listdir(_LIBRARY_DIR):
        if current is not _LIBRARY_DIR:
            current = os.path.join(_LIBRARY_DIR, current)
        if os.path.isdir(current) and os.path.getmtime(current) > last_load_time:
            # use os.walk here only to find all the files in
            # the current directory:
            for _, _, files in os.walk(current):
                if files:
                    folder_name = os.path.split(current)[-1]
                    cover_path = utils.find_folder_image(
                        files, folder_name.lower(), current, _COVER_EXTENSIONS)
                    if not cover_path:
                        cover_path = os.path.join(current, _FAKE_COVER_NAME)
                        utils.produce_identicon(current, save_path=cover_path)
                    folder_id = db.insert_folder(folder_name, cover_path)
                    for file_name in files:
                        path = os.path.join(current, file_name)
                        meta = _get_metadata(path, file_name)
                        if meta:
                            meta.update({'path': path,
                                         'cover_path': cover_path,
                                         'folder_id': folder_id})
                            tracks.append(meta)
                break
    db.insert_many_tracks(tracks)
    db.close()
    _update_last_load_time(time.time())
Ejemplo n.º 2
0
 def do_work():
     while True:
         with self._lock:
             if self._to_be_framed:
                 movie_path, cover_path = self._to_be_framed.pop(0)
             else:
                 self._worker = None
                 break
         if not self._extract_single_frame(movie_path, cover_path):
             utils.produce_identicon(movie_path, save_path=cover_path)
Ejemplo n.º 3
0
Archivo: model.py Proyecto: Sasza/pisak
 def do_work():
     while True:
         with self._lock:
             if self._to_be_framed:
                 movie_path, cover_path = self._to_be_framed.pop(0)
             else:
                 self._worker = None
                 break
         if not self._extract_single_frame(movie_path, cover_path):
             utils.produce_identicon(movie_path, save_path=cover_path)