Files
Auto_Bangumi/module/core/download_fliter.py
EstrellaXD b13fb66026 Fix re code
2023-03-05 18:25:52 +08:00

27 lines
685 B
Python

import re
import logging
from bs4 import BeautifulSoup
from module.conf import settings
from module.utils import json_config
logger = logging.getLogger(__name__)
class RSSFilter:
def __init__(self):
self.filter_rule = json_config.load(settings.filter_rule)
def filter(self, item: BeautifulSoup):
title = item.title.string
torrent = item.find("enclosure")
download = False
for rule in self.filter_rule:
if re.search(rule["include"], title):
if not re.search(rule["exclude"], title):
download = True
logger.debug(f"{title} added")
return download, torrent