|
@@ -26,18 +26,19 @@ class _SyncPosition:
|
|
|
self._tracks.add(track)
|
|
|
self._play_counts.update(track.get_play_counts())
|
|
|
|
|
|
- @property
|
|
|
- def play_counts(self) -> typing.Set[symuid.PlayCount]:
|
|
|
- return self._play_counts
|
|
|
-
|
|
|
- @property
|
|
|
- def tracks(self) -> typing.Set[symuid.Track]:
|
|
|
- return self._tracks
|
|
|
+ def sync(self, play_count_added_cb=None) -> None:
|
|
|
+ for track in self._tracks:
|
|
|
+ track_play_counts = set(track.get_play_counts())
|
|
|
+ for play_count in self._play_counts:
|
|
|
+ if play_count not in track_play_counts:
|
|
|
+ track.register_play_count(
|
|
|
+ play_count, tag_set_cb=play_count_added_cb)
|
|
|
|
|
|
def __repr__(self) -> str:
|
|
|
return repr(vars(self))
|
|
|
|
|
|
-def sync(path, path_ignore_regex, show_ignored=False):
|
|
|
+def sync(path, path_ignore_regex, show_ignored=False,
|
|
|
+ play_count_added_cb=None):
|
|
|
sync_positions = collections.defaultdict(_SyncPosition)
|
|
|
for track in symuid.Track.walk(
|
|
|
root_path=path,
|
|
@@ -52,11 +53,7 @@ def sync(path, path_ignore_regex, show_ignored=False):
|
|
|
track.get_uuid()))
|
|
|
sync_positions[track.get_uuid()].add_track(track)
|
|
|
for sync_position in sync_positions.values():
|
|
|
- for track in sync_position.tracks:
|
|
|
- track_play_counts = set(track.get_play_counts())
|
|
|
- for play_count in sync_position.play_counts:
|
|
|
- if play_count not in track_play_counts:
|
|
|
- track.register_play_count(play_count)
|
|
|
+ sync_position.sync(play_count_added_cb=play_count_added_cb)
|
|
|
|
|
|
|
|
|
def _init_argparser():
|