49 lines
947 B
Python
Executable File
49 lines
947 B
Python
Executable File
#!/usr/bin/env python
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
import sys
|
|
import logging
|
|
|
|
from mopidy import settings
|
|
from mopidy.utils.log import setup_console_logging, setup_root_logger
|
|
from mopidy.scanner import Scanner, translator
|
|
from mopidy.frontends.mpd.translator import tracks_to_tag_cache_format
|
|
|
|
|
|
setup_root_logger()
|
|
setup_console_logging(2)
|
|
|
|
|
|
tracks = []
|
|
|
|
|
|
def store(data):
|
|
track = translator(data)
|
|
tracks.append(track)
|
|
logging.debug('Added %s', track.uri)
|
|
|
|
|
|
def debug(uri, error, debug):
|
|
logging.error('Failed %s: %s - %s', uri, error, debug)
|
|
|
|
|
|
logging.info('Scanning %s', settings.LOCAL_MUSIC_PATH)
|
|
|
|
|
|
scanner = Scanner(settings.LOCAL_MUSIC_PATH, store, debug)
|
|
try:
|
|
scanner.start()
|
|
except KeyboardInterrupt:
|
|
scanner.stop()
|
|
|
|
|
|
logging.info('Done')
|
|
|
|
|
|
for a in tracks_to_tag_cache_format(tracks):
|
|
if len(a) == 1:
|
|
print ('%s' % a).encode('utf-8')
|
|
else:
|
|
print ('%s: %s' % a).encode('utf-8')
|