|
@@ -6,21 +6,33 @@ import os
|
|
import symuid
|
|
import symuid
|
|
import symuid.library.cmus
|
|
import symuid.library.cmus
|
|
|
|
|
|
|
|
+LIBRARY_ID_LENGTH_MIN = 8
|
|
|
|
|
|
-def symuid_import_cmus(cache_path):
|
|
+
|
|
|
|
+def symuid_import_cmus(library_id, cache_path):
|
|
|
|
+ assert len(library_id) >= LIBRARY_ID_LENGTH_MIN, library_id
|
|
lib = symuid.library.cmus.Cache(
|
|
lib = symuid.library.cmus.Cache(
|
|
path=os.path.expanduser(cache_path),
|
|
path=os.path.expanduser(cache_path),
|
|
)
|
|
)
|
|
for cmus_track in lib.get_tracks():
|
|
for cmus_track in lib.get_tracks():
|
|
if not os.path.exists(cmus_track.path):
|
|
if not os.path.exists(cmus_track.path):
|
|
sys.stderr.write('{!r}: not found\n'.format(cmus_track.path))
|
|
sys.stderr.write('{!r}: not found\n'.format(cmus_track.path))
|
|
- elif cmus_track.play_count > 0:
|
|
+ elif cmus_track.play_count > 0: # TODO play_count = 0
|
|
- print(cmus_track.play_count, cmus_track.path)
|
|
+ symuid_track = symuid.Track(path=cmus_track.path.decode())
|
|
|
|
+ symuid_track.register_play_count(
|
|
|
|
+ player='cmus',
|
|
|
|
+ library_id=library_id,
|
|
|
|
+ register_dt=dt.datetime.now(),
|
|
|
|
+ play_count=cmus_track.play_count,
|
|
|
|
+ tag_set_cb=lambda tr, tag:
|
|
|
|
+ print('{!r}: set tag {!r}'.format(tr.path, tag)),
|
|
|
|
+ )
|
|
|
|
|
|
|
|
|
|
def _init_argparser():
|
|
def _init_argparser():
|
|
import argparse
|
|
import argparse
|
|
argparser = argparse.ArgumentParser(description=None)
|
|
argparser = argparse.ArgumentParser(description=None)
|
|
|
|
+ argparser.add_argument('library_id')
|
|
argparser.add_argument(
|
|
argparser.add_argument(
|
|
'cache_path',
|
|
'cache_path',
|
|
nargs='?',
|
|
nargs='?',
|