Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scanner: Move main() function from bin/ to mopidy.scanner
- Loading branch information
Showing
2 changed files
with
42 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,5 @@ | ||
#!/usr/bin/env python | ||
#! /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') | ||
if __name__ == '__main__': | ||
from mopidy.scanner import main | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters