diff --git a/commands/2hdp.py b/commands/2hdp.py index 45ba756..9f13ee4 100755 --- a/commands/2hdp.py +++ b/commands/2hdp.py @@ -13,6 +13,12 @@ parser = ArgumentParser() parser.add_argument( "--keyword", action="append", default=["mhdgz"], help="Prefered words to search on names" ) +parser.add_argument( + "--exclude", + action="append", + default=["3d", "dvd", "iso", "av1", "zza"], + help="Excluded words to search on names", +) parser.add_argument("--cookie", required=True, help="Cookies to bypass CloudFlare") parser.add_argument("--user-agent", required=True, help="User Agent to bypass CloudFlare") parser.add_argument( @@ -52,8 +58,13 @@ def parse_size(size): return int(float(number) * units[unit]) -def is_valid(id: int, size: int, completed: int): - return size < parse_size("10Go") and completed > 100 and nb_files(id) +def is_valid(id: int, name: str, size: int, completed: int): + return ( + size < parse_size("10Go") + and completed > 100 + and not any(exclude.lower() in name.lower() for exclude in args.exclude) + and nb_files(id) + ) writer = DictWriter(stdout, fieldnames=["title", "season", "episode", "name", "link"]) @@ -101,6 +112,7 @@ for feed in args.feed: if any(keyword.lower() in columns[1].text.strip().lower() for keyword in args.keyword): if is_valid( int(columns[2].a["target"]), + columns[1].text.strip(), parse_size(columns[5].text.strip()), int(columns[6].text.strip()), ): @@ -117,6 +129,7 @@ for feed in args.feed: if "multi" in columns[1].text.strip().lower(): if is_valid( int(columns[2].a["target"]), + columns[1].text.strip(), parse_size(columns[5].text.strip()), int(columns[6].text.strip()), ):