Compare commits

..

No commits in common. "main" and "managed" have entirely different histories.

2 changed files with 11 additions and 19 deletions

View File

@ -12,27 +12,20 @@ class Dedupe(Layer):
def _process(self, left: Root): def _process(self, left: Root):
right = self.other right = self.other
existing_artists = right.by_name() existing_artists = right.by_name()
pruned_artists = list()
for artist in left: for artist in left:
artist_name = artist.name artist_name = artist.name
if artist_name in existing_artists: if artist_name in existing_artists:
pruned_albums = self.prune_artist(artist, right[artist_name]) self.prune_artist(artist, right[artist_name])
if len(artist.contents) == 0: if len(artist.contents) == 0:
pruned_artists.append(artist_name) left.prune(artist_name)
self.log.info('PRN', f"Pruned artist: {artist_name}") self.log.info('PRN', f"Pruned artist: {artist_name}")
else:
for album_name in pruned_albums:
self.log.info('PRN', f"Pruned album: {album_name}")
else: else:
continue # todo: fuzzy matching continue # todo: fuzzy matching
[left.prune(artist) for artist in pruned_artists]
@staticmethod def prune_artist(self, left: Artist, right: Artist):
def prune_artist(left: Artist, right: Artist):
existing_albums = right.by_name() existing_albums = right.by_name()
pruned_albums = list() for album in left:
for album_name in existing_albums: album_name = album.name
if album_name in left.by_name(): if album_name in existing_albums:
left.prune(album_name) left.prune(album_name)
pruned_albums.append(album_name) self.log.info('PRN', f"Pruned album: {album_name}")
return pruned_albums

View File

@ -8,22 +8,21 @@ from layers import Dedupe, Transcoder
def get_args(): def get_args():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('indir', type=Path, help='Directory containing artist directories') parser.add_argument('indir', type=Path, help='Directory containing artist directories')
parser.add_argument('compdir', type=Path, help='Directory to compare input')
parser.add_argument('outdir', type=Path, help='Empty directory where transcodes will be placed') parser.add_argument('outdir', type=Path, help='Empty directory where transcodes will be placed')
parser.add_argument('encoder', type=Path, help='Location of encoder') parser.add_argument('encoder', type=Path, help='Location of encoder')
return parser.parse_args() return parser.parse_args()
def main(input_dir: Path, compare_dir: Path, output_dir: Path, encoder: Path, out_extension: str = 'opus'): def main(input_dir: Path, output_dir: Path, encoder: Path, out_extension: str = 'opus'):
wd = Path(realpath(__file__)).parent.parent wd = Path(realpath(__file__)).parent.parent
log_path = wd / "logs" log_path = wd / "logs"
if encoder.parts[-1] == "qaac64.exe": if encoder.parts[-1] == "qaac64.exe":
out_extension = "m4a" out_extension = "m4a"
log = Log(log_path) log = Log(log_path)
input_root = Root(input_dir, log) input_root = Root(input_dir, log)
compdir_root = Root(compare_dir, log) output_root = Root(output_dir, log)
dedupe = Dedupe(compdir_root, log) dedupe = Dedupe(output_root, log)
dedupe.process(input_root) dedupe.process(input_root)
transcoder = Transcoder(encoder, out_extension, output_dir, log, log_path) transcoder = Transcoder(encoder, out_extension, output_dir, log, log_path)
@ -33,4 +32,4 @@ def main(input_dir: Path, compare_dir: Path, output_dir: Path, encoder: Path, ou
if __name__ == '__main__': if __name__ == '__main__':
args = get_args() args = get_args()
main(args.indir, args.compdir, args.outdir, args.encoder) main(args.indir, args.outdir, args.encoder)