From 1add7b3b52bfcc821625c7ccb9c4d4a7303827d4 Mon Sep 17 00:00:00 2001 From: Chaigidel Date: Mon, 24 Feb 2020 23:00:10 +0800 Subject: [PATCH] simplify --- README.md | 2 +- danmaku2ass.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b968a55..a1f7e10 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ optional arguments: -fl FILTER, --filter FILTER Regular expression to filter comments -flf FILTER_FILE, --filter-file FILTER_FILE - Regular expressions from json file (contain a regex list) to filter comments + Regular expressions from file (one line one regex) to filter comments -p HEIGHT, --protect HEIGHT Reserve blank on the bottom of the stage -r, --reduce Reduce the amount of comments if stage is full diff --git a/danmaku2ass.py b/danmaku2ass.py index e8f4ce0..f9043c2 100755 --- a/danmaku2ass.py +++ b/danmaku2ass.py @@ -735,7 +735,8 @@ def Danmaku2ASS(input_files, input_format, output_file, stage_width, stage_heigh comment_filters = [comment_filter] if comment_filters_json: with open(comment_filters_json, 'r') as f: - comment_filters.extend(json.load(f)) + d = f.readlines() + comment_filters.extend([i.strip() for i in d]) filters_regex = [] for comment_filter in comment_filters: try: @@ -809,7 +810,7 @@ def main(): parser.add_argument('-dm', '--duration-marquee', metavar=_('SECONDS'), help=_('Duration of scrolling comment display [default: %s]') % 5, type=float, default=5.0) parser.add_argument('-ds', '--duration-still', metavar=_('SECONDS'), help=_('Duration of still comment display [default: %s]') % 5, type=float, default=5.0) parser.add_argument('-fl', '--filter', help=_('Regular expression to filter comments')) - parser.add_argument('-flf', '--filter-file', help=_('Regular expressions from json file (contain a regex list) to filter comments')) + parser.add_argument('-flf', '--filter-file', help=_('Regular expressions from file (one line one regex) to filter comments')) parser.add_argument('-p', '--protect', metavar=_('HEIGHT'), help=_('Reserve blank on the bottom of the stage'), type=int, default=0) parser.add_argument('-r', '--reduce', action='store_true', help=_('Reduce the amount of comments if stage is full')) parser.add_argument('file', metavar=_('FILE'), nargs='+', help=_('Comment file to be processed'))