[2026-09-27] eagle: personal/plans/music-artist-albumartist-repair.md personal/tech/music-tags-repair-truenas.md personal/tech/scripts/find_aa_hijack.py
This commit is contained in:
1 parent
042cac0216
commit
c0a76a56c9
3 files changed
+341
-6
No files matched your search
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Детектор класса «albumartist размножен от чужого файла в корне папки».
|
||||
|
||||
Сессия 6, 2026-09-27. Нашёл 7 испорченных папок из 11 подозреваемых
|
||||
(The Prodigy->DJ Feel, Банд Эрос->VIP77, Дискотека Авария, Жуки,
|
||||
Потап & Каменских, Король и Шут, Ленинград).
|
||||
|
||||
ПРИЗНАК ПОРЧИ:
|
||||
для папки, где new_albumartist ОДИН на всю папку:
|
||||
он не совпадает с top-артистом папки
|
||||
И не совпадает с именем папки
|
||||
И совпадает с МИНОРИТАРНЫМ артистом папки
|
||||
-> ПОДОЗРЕВАЕМЫЙ
|
||||
|
||||
ЗАПУСК: python3 find_aa_hijack.py
|
||||
Не меняет файлы. Только печатает.
|
||||
"""
|
||||
import csv
|
||||
import collections
|
||||
import os
|
||||
|
||||
P = '/Users/admin/Downloads/music-tags/APPLY-PLAN.csv'
|
||||
rows = list(csv.DictReader(open(P, encoding='utf-8-sig', newline='')))
|
||||
|
||||
|
||||
def s(v):
|
||||
return (v or '').strip()
|
||||
|
||||
|
||||
by_folder = collections.defaultdict(list)
|
||||
for r in rows:
|
||||
by_folder[r['folder']].append(r)
|
||||
|
||||
suspects = []
|
||||
for folder, rs in sorted(by_folder.items()):
|
||||
aa_vals = collections.Counter(s(r['new_albumartist']) for r in rs if s(r['new_albumartist']))
|
||||
if len(aa_vals) != 1:
|
||||
continue # смешанные папки — отдельный случай
|
||||
aa = next(iter(aa_vals))
|
||||
art = collections.Counter(s(r['new_artist']) for r in rs if s(r['new_artist']))
|
||||
if not art:
|
||||
continue
|
||||
top_artist, top_n = art.most_common(1)[0]
|
||||
folder_name = os.path.basename(folder)
|
||||
if aa != top_artist and aa != folder_name and aa in art:
|
||||
minority = art[aa]
|
||||
if minority < top_n:
|
||||
suspects.append((folder, aa, top_artist, top_n, minority, len(rs)))
|
||||
|
||||
print(f"ПОДОЗРЕВАЕМЫХ ПАПОК: {len(suspects)}")
|
||||
print()
|
||||
for folder, aa, top, tn, mn, tot in suspects:
|
||||
print(f" albumartist={aa!r} (у {mn} из {tot})")
|
||||
print(f" должен быть {top!r} (у {tn})")
|
||||
print(f" {folder}")
|
||||
Reference in new issue
Block a user