This repository has been archived by the owner on Nov 1, 2019. It is now read-only.
Perf mode filter
Zhiming Wang edited this page Nov 30, 2018
·
6 revisions
Below is a more complete and more opinionated perf mode filter I use:
# This module is imported to preprocess and exclude filenames/filepaths
# of VODS in perf mode.
#
# A single function named `filter` with the signature
#
# (str,) -> Optional[str]
#
# is expected. The default filename/filepath derived from the title and
# subtitle of a VOD is passed to the `filter` function. If the return
# value is a string, it is used as the filename/filepath instead. If the
# return value is `None`, the VOD is considered excluded and
# automatically commented out (it can still be restored during
# interactive editing).
import re
RE = re.compile
IGNORES = [
RE(r"生日会"),
]
SUBS = [
# (pattern, repl)
(RE(r"(S|N|H|X)II"), r"\1Ⅱ"),
(RE(r"Team Ft", re.I), r"Team Ft"),
(RE(r"Team", re.I), r"Team"),
(RE(r"\s+"), r" "),
(RE(r"Team [^ ]+ ?剧场公演", re.I), r""),
(RE(r"》公演"), r"》"),
(RE(r"剧场公演"), r""),
(RE(r"星梦 ?Mini Live (本期|参加)成员:(?P<name>\w+)"), r"\g<name> 星梦Mini Live"),
(RE(r" +\.mp4$"), r".mp4"),
(RE(r"《N.E.W》"), r"Team NⅡ 《N.E.W》"),
(RE(r"《以爱之名》"), r"Team NⅡ 《以爱之名》"),
(RE(r"《双面偶像》"), r"Team Ft 《双面偶像》"),
(RE(r"《命运的X号》"), r"Team X 《命运的X号》"),
(RE(r"《头号新闻》"), r"Team HⅡ 《头号新闻》"),
(RE(r"《美丽48区》"), r"Team SⅡ 《美丽48区》"),
(RE(r"《第48区》"), r"Team SⅡ 《第48区》"),
(RE(r"《重生计划》"), r"Team SⅡ 《重生计划》"),
]
def filter(path):
for pattern in IGNORES:
if pattern.search(path):
return None
for pattern, repl in SUBS:
path = pattern.sub(repl, path)
return path
Apparently it should evolve over time.