https://pypi.org/project/correlate/
This was presented during PyCon US. It should do a better job than our hand-crafted fuzzy-matcher.
|
def get_match_ratio(session: Session, path: pathlib.Path) -> float: |
|
return fuzzywuzzy.fuzz.ratio(session.title, path.stem) |
|
|
|
|
|
def choose_video(session: Session, video_paths: list) -> pathlib.Path: |
|
"""Look through the file list and choose the one that "looks most like it".""" |
|
score, match = max((get_match_ratio(session, p), p) for p in video_paths) |
|
if score < 70: |
|
raise ValueError("no match") |
|
return match |
https://pypi.org/project/correlate/
This was presented during PyCon US. It should do a better job than our hand-crafted fuzzy-matcher.
session-video-publisher/vidpub/upload_video.py
Lines 86 to 95 in f56e1a5