@@ -448,6 +448,7 @@ def is_keepable(self, this: MediaFile, that: MediaFile) -> MediaFile:
448
448
449
449
"""
450
450
PU .note (f"Compare { SU .gray (this .path )} <=> { SU .gray (that .path )} " , 0 )
451
+ PU .note (f"This folder: { SU .gray (this .folder )} , That folder: { SU .gray (that .folder )} " )
451
452
452
453
# Real album folder files are keepable over files in root, artist or dump folders
453
454
left : Folder = this .folder
@@ -456,23 +457,31 @@ def is_keepable(self, this: MediaFile, that: MediaFile) -> MediaFile:
456
457
PU .log (f"Compare if file is in album folder: { left .type } || { right .type } " , 1 )
457
458
if left .type != right .type :
458
459
if left .type == Folder .Type .ALBUM :
459
- PU .log (f"This is an album folder: { SU .gray (this .folder .beets_path )} " , 2 )
460
+ msg = f"Other is an album folder: { SU .gray (this .folder .beets_path )} "
461
+ PU .log (msg , 2 )
462
+ that .delete_reason = msg
460
463
return this
461
464
elif right .type == Folder .Type .ALBUM :
462
- PU .log (f"That is an album folder: { SU .gray (that .folder .beets_path )} " , 2 )
465
+ msg = f"Other is an album folder: { SU .gray (that .folder .beets_path )} "
466
+ PU .log (msg , 2 )
467
+ this .delete_reason = msg
463
468
return that
464
469
# Skip if both are of the same path and type
465
470
466
471
# Check for dirty folders
467
472
left = this .folder .is_dirty
468
473
right = that .folder .is_dirty
469
474
PU .log (f"Compare dirty folders: { left } || { right } " , 1 )
470
- if left and (left > 0 ) or right and (right > 0 ):
471
- if left < right :
472
- PU .log (f"This folder is dirty: { SU .gray (this .folder .beets_path )} " , 2 )
475
+ if left != right :
476
+ if left :
477
+ msg = f"This folder is dirty: { SU .gray (this .folder .beets_path )} "
478
+ PU .log (msg , 2 )
479
+ this .delete_reason = msg
473
480
return that
474
- elif left > right :
475
- PU .log (f"That folder is dirty: { SU .gray (that .folder .beets_path )} " , 2 )
481
+ elif right :
482
+ msg = f"That folder is dirty: { SU .gray (that .folder .beets_path )} "
483
+ PU .log (msg , 2 )
484
+ that .delete_reason = msg
476
485
return this
477
486
# Skip if both are incomplete
478
487
@@ -482,23 +491,29 @@ def is_keepable(self, this: MediaFile, that: MediaFile) -> MediaFile:
482
491
if left .missing is not None and right .missing is not None :
483
492
PU .log (f"Compare missing tracks: { left .missing } /{ left .total } || { right .missing } /{ right .total } " , 1 )
484
493
if (left .missing != right .missing ) and (left .missing > 0 or right .missing > 0 ):
485
- if left .missing < right .missing :
486
- PU .log (f"This folder is more complete ({ left .missing } /{ left .total } ): { SU .gray (this .path )} " , 2 )
494
+ if (left .missing < right .missing ) and not left .is_dirty :
495
+ msg = f"Other folder is more complete ({ left .missing } /{ left .total } ): { SU .gray (this .path )} "
496
+ PU .log (msg , 2 )
497
+ that .delete_reason = msg
487
498
return this
488
- elif left .missing > right .missing :
489
- PU .log (f"That folder is more complete ({ right .missing } /{ right .total } ): { SU .gray (that .path )} " , 2 )
499
+ elif (left .missing > right .missing ) and not right .is_dirty :
500
+ msg = f"Other folder is more complete ({ right .missing } /{ right .total } ): { SU .gray (that .path )} "
501
+ PU .log (msg , 2 )
502
+ this .delete_reason = msg
490
503
return that
491
504
# Skip if both are incomplete, none has missing tracks or have no information on missing tracks
492
505
493
- # If the album folder already contains a keepable, we wanna keep all the items
506
+ # If the album folder already contains a keepable, we wanna keep all the items, except for dirty folders
494
507
left = this .folder and this .folder .has_keepable
508
+ l_dirty = this .folder and this .folder .is_dirty
495
509
right = that .folder and that .folder .has_keepable
496
- PU .log (f"Compare if album folder contain a keepable: { left } || { right } " , 1 )
510
+ r_dirty = that .folder and that .folder .is_dirty
511
+ PU .log (f"Compare if album folder contain a keepable: { left } +dirty: { l_dirty } || { right } +dirty: { r_dirty } " , 1 )
497
512
if left != right :
498
- if left :
513
+ if left and not l_dirty :
499
514
that .delete_reason = f"Other album folder already contains a keepable | { SU .gray (this .path )} "
500
515
return this
501
- elif right :
516
+ elif right and not r_dirty :
502
517
this .delete_reason = f"Other album folder already contains a keepable | { SU .gray (that .path )} "
503
518
return that
504
519
# Skip, if they are the same
@@ -652,6 +667,8 @@ def is_keepable(self, this: MediaFile, that: MediaFile) -> MediaFile:
652
667
sys .exit (1 )
653
668
654
669
processor = DuplicateProcessor (config )
670
+ # client = BeetsClient(config)
671
+ # print("BEETS CLIENT: " + client._query1())
655
672
656
673
if action == "remove-unsupported" :
657
674
FileTools .move_by_extension (config .music_dir , config .data_dir , config .remove_extensions , ToolboxConfig .dry_run )
0 commit comments