fix(match_series_to_tvdb): add new logging from serverlibrary, move files to series folder
This commit is contained in:
1 parent
64f2abcdd1
commit
2af4724093
1 file changed
+10
-37
@@ -10,29 +10,12 @@ import requests
|
||||
|
||||
weight_jaccard = 0.5
|
||||
weight_fuzzy = 1 - weight_jaccard
|
||||
|
||||
from serverlibrary import (
|
||||
combined_score,
|
||||
score_match_fuzzy,
|
||||
score_match_jaccard,
|
||||
score_match_recall_jaccard,
|
||||
tvdb_get,
|
||||
words,
|
||||
)
|
||||
|
||||
MATCH_THRESHOLD = 0.85
|
||||
|
||||
|
||||
class CustomLogger(logging.Logger):
|
||||
def trace(self, msg: str, *args, **kwargs) -> None:
|
||||
if self.isEnabledFor(TRACE):
|
||||
self._log(TRACE, msg, args, **kwargs)
|
||||
|
||||
|
||||
TRACE = 5
|
||||
from serverlibrary import *
|
||||
|
||||
logging.setLoggerClass(CustomLogger)
|
||||
logger: CustomLogger = logging.getLogger(__name__) # type: ignore[assignment]
|
||||
logger: CustomLogger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def normalize(text: str) -> str:
|
||||
@@ -191,10 +174,10 @@ def best_episode_match(filename, episodes):
|
||||
)
|
||||
score = max(score, recall_jaccard1, recall_jaccard2)
|
||||
|
||||
if "hyänen" in search_words and score > 0.6:
|
||||
logger.warning(
|
||||
f"SEARCH WORDS: {search_words}, CANDIDATE WORDS: {candidate_words}"
|
||||
)
|
||||
# if "hyänen" in search_words and score > 0.6:
|
||||
# logger.warning(
|
||||
# f"SEARCH WORDS: {search_words}, CANDIDATE WORDS: {candidate_words}"
|
||||
# )
|
||||
|
||||
if score > best_score:
|
||||
logger.trace(f"{search_words}:\t\t{candidate_words},\t\t{score}")
|
||||
@@ -266,14 +249,15 @@ def process_series(series_path: Path, dry_run: bool = False):
|
||||
f"{file.suffix}"
|
||||
)
|
||||
|
||||
target = file.with_name(new_name)
|
||||
target = file.parent / f"Season {episode['season']:02d}" / new_name
|
||||
if score < 1:
|
||||
logger.debug(f"{file.name} -> {new_name}, score={score:.3f}")
|
||||
elif score == 1:
|
||||
logger.trace(f"{file.name} -> {new_name}, score={score:.3f}")
|
||||
|
||||
if not dry_run:
|
||||
file.rename(target)
|
||||
logger.info(f"{file.name} -> {target}, score={score:.3f}")
|
||||
safe_rename(file, target)
|
||||
|
||||
|
||||
def main():
|
||||
@@ -300,19 +284,8 @@ def main():
|
||||
args = parser.parse_args()
|
||||
|
||||
dry_run = args.dry_run
|
||||
LOG_LEVELS = {
|
||||
"TRACE": TRACE,
|
||||
"DEBUG": logging.DEBUG,
|
||||
"INFO": logging.INFO,
|
||||
"WARNING": logging.WARNING,
|
||||
"ERROR": logging.ERROR,
|
||||
"CRITICAL": logging.CRITICAL,
|
||||
}
|
||||
|
||||
logging.basicConfig(
|
||||
level=LOG_LEVELS[args.log_level.upper()],
|
||||
format="%(asctime)s %(levelname)s %(message)s",
|
||||
)
|
||||
setup_logging(args.log_level)
|
||||
|
||||
input_path = Path(args.path).expanduser().resolve()
|
||||
|
||||
|
||||
Reference in new issue
Block a user