Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
ac10071990 | |||
bde4972a7f | |||
cc9b560484 |
|
@ -12,20 +12,27 @@ class Dedupe(Layer):
|
|||
def _process(self, left: Root):
|
||||
right = self.other
|
||||
existing_artists = right.by_name()
|
||||
pruned_artists = list()
|
||||
for artist in left:
|
||||
artist_name = artist.name
|
||||
if artist_name in existing_artists:
|
||||
self.prune_artist(artist, right[artist_name])
|
||||
pruned_albums = self.prune_artist(artist, right[artist_name])
|
||||
if len(artist.contents) == 0:
|
||||
left.prune(artist_name)
|
||||
pruned_artists.append(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:
|
||||
continue # todo: fuzzy matching
|
||||
[left.prune(artist) for artist in pruned_artists]
|
||||
|
||||
def prune_artist(self, left: Artist, right: Artist):
|
||||
@staticmethod
|
||||
def prune_artist(left: Artist, right: Artist):
|
||||
existing_albums = right.by_name()
|
||||
for album in left:
|
||||
album_name = album.name
|
||||
if album_name in existing_albums:
|
||||
pruned_albums = list()
|
||||
for album_name in existing_albums:
|
||||
if album_name in left.by_name():
|
||||
left.prune(album_name)
|
||||
self.log.info('PRN', f"Pruned album: {album_name}")
|
||||
pruned_albums.append(album_name)
|
||||
return pruned_albums
|
||||
|
|
|
@ -8,21 +8,22 @@ from layers import Dedupe, Transcoder
|
|||
def get_args():
|
||||
parser = argparse.ArgumentParser()
|
||||
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('encoder', type=Path, help='Location of encoder')
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def main(input_dir: Path, output_dir: Path, encoder: Path, out_extension: str = 'opus'):
|
||||
def main(input_dir: Path, compare_dir: Path, output_dir: Path, encoder: Path, out_extension: str = 'opus'):
|
||||
wd = Path(realpath(__file__)).parent.parent
|
||||
log_path = wd / "logs"
|
||||
if encoder.parts[-1] == "qaac64.exe":
|
||||
out_extension = "m4a"
|
||||
log = Log(log_path)
|
||||
input_root = Root(input_dir, log)
|
||||
output_root = Root(output_dir, log)
|
||||
compdir_root = Root(compare_dir, log)
|
||||
|
||||
dedupe = Dedupe(output_root, log)
|
||||
dedupe = Dedupe(compdir_root, log)
|
||||
dedupe.process(input_root)
|
||||
|
||||
transcoder = Transcoder(encoder, out_extension, output_dir, log, log_path)
|
||||
|
@ -32,4 +33,4 @@ def main(input_dir: Path, output_dir: Path, encoder: Path, out_extension: str =
|
|||
|
||||
if __name__ == '__main__':
|
||||
args = get_args()
|
||||
main(args.indir, args.outdir, args.encoder)
|
||||
main(args.indir, args.compdir, args.outdir, args.encoder)
|
||||
|
|
Loading…
Reference in New Issue
Block a user