26 lines
711 B
Python
26 lines
711 B
Python
# Copyright 2019 (c) Anna Schumaker.
|
|
from . import playlist
|
|
from .. import tags
|
|
from .. import threadqueue
|
|
import os
|
|
|
|
library_thread = threadqueue.ThreadQueue()
|
|
|
|
class LibraryPlaylist(playlist.Playlist):
|
|
def __init__(self, path):
|
|
playlist.Playlist.__init__(self, os.path.abspath(path))
|
|
self.scan()
|
|
|
|
def scan(self):
|
|
library_thread.push(self.thread_scan)
|
|
|
|
def thread_add(self, path):
|
|
track = tags.Track.add(path)
|
|
self.add(track)
|
|
self.notify("on-scan", track)
|
|
|
|
def thread_scan(self):
|
|
for dirname, subdirs, files in os.walk(self.name):
|
|
for f in files:
|
|
library_thread.push(self.thread_add, os.path.join(dirname, f))
|