From 49a82d7a48f3e74c5e3e9bc7ba9f340175367f8a Mon Sep 17 00:00:00 2001 From: jxxghp Date: Sat, 9 Mar 2024 09:53:15 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E6=96=B0=E5=A2=9E=E5=AE=98?= =?UTF-8?q?=E7=A7=8D=E4=BC=98=E5=85=88=E7=BA=A7=E8=A7=84=E5=88=99=20fix=20?= =?UTF-8?q?#1635=20feat=EF=BC=9A=E5=8A=A8=E6=BC=AB=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E4=BA=8C=E7=BA=A7=E7=9B=AE=E5=BD=95=20fix=20#1633?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 33 +++++++++++++++++++++++------- app/chain/download.py | 2 +- app/core/config.py | 2 ++ app/helper/torrent.py | 10 +++++---- app/modules/filter/__init__.py | 29 +++++++++++++++++++++++--- app/modules/themoviedb/category.py | 17 ++++++++++++++- config/category.yaml | 9 ++++++++ 7 files changed, 86 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index da3749f5..f6a54fdd 100644 --- a/README.md +++ b/README.md @@ -185,13 +185,25 @@ MoviePilot需要配套下载器和媒体服务器配合使用。 ## 使用 -- 通过设置的超级管理员用户登录管理界面(默认用户:admin,默认端口:3000),**注意:初始密码为自动生成,需要在首次运行时的后台日志中查看!** -- 通过CookieCloud同步快速添加站点,不需要使用的站点可在WEB管理界面中禁用或删除,无法同步的站点可手动新增。 -- 通过打开下载器监控实现下载完成后自动整理入库并刮削媒体信息。 -- 通过`微信`/`Telegram`/`Slack`/`SynologyChat`/`VoceChat`远程管理,其中 微信/Telegram 将会自动添加操作菜单(微信菜单条数有限制,部分菜单不显示);微信回调地址、SynologyChat传入地址地址相对路径均为:`/api/v1/message/`;VoceChat的Webhook地址相对路径为:`/api/v1/message/?token=moviepilot`,其中moviepilot为设置的`API_TOKEN`。 -- 设置媒体服务器Webhook,通过MoviePilot发送播放通知等。Webhook回调相对路径为`/api/v1/webhook?token=moviepilot`,其中`moviepilot`为设置的`API_TOKEN`。 -- 将MoviePilot做为Radarr或Sonarr服务器添加到Overseerr或Jellyseerr,可使用Overseerr/Jellyseerr浏览订阅。 -- 映射宿主机docker.sock文件到容器`/var/run/docker.sock`,以支持内建重启操作。实例:`-v /var/run/docker.sock:/var/run/docker.sock:ro`。 +### 1. **WEB后台管理** +- 通过设置的超级管理员用户登录后台管理界面(`SUPERUSER`配置项,默认用户:admin,默认端口:3000) +> ❗**注意:超级管理员用户初始密码为自动生成,需要在首次运行时的后台日志中查看!** 如首次运行日志丢失,则需要删除配置文件目录下的`user.db`文件,然后重启服务。 +### 2. **站点维护** +- 通过CookieCloud同步快速添加站点,不需要使用的站点可在WEB管理界面中禁用或删除,无法同步的站点也可手动新增。 +- 需要通过环境变量设置用户认证信息且认证成功后才能使用站点相关功能,未认证通过时站点相关的插件也会无法显示。 +### 3. **文件整理** +- 默认通过监控下载器实现下载完成后自动整理入库并刮削媒体信息,需要后台打开`下载器监控`开关,且仅会处理通过MoviePilot添加下载的任务。 +- 使用`目录监控`等插件实现更灵活的自动整理。 +### 4. **通知交互** +- 支持通过`微信`/`Telegram`/`Slack`/`SynologyChat`/`VoceChat`等渠道远程管理和订阅下载,其中 微信/Telegram 将会自动添加操作菜单(微信菜单条数有限制,部分菜单不显示)。 +- `微信`回调地址、`SynologyChat`传入地址地址相对路径均为:`/api/v1/message/`;`VoceChat`的Webhook地址相对路径为:`/api/v1/message/?token=moviepilot`,其中moviepilot为设置的`API_TOKEN`。 +### 5. **订阅与搜索** +- 通过MoviePilot管理后台搜索和订阅。 +- 将MoviePilot做为`Radarr`或`Sonarr`服务器添加到`Overseerr`或`Jellyseerr`,可使用`Overseerr/Jellyseerr`浏览和添加订阅。 +- 安装`豆瓣榜单订阅`、`猫眼订阅`等插件,实现自动订阅豆瓣榜单、猫眼榜单等。 +### 6. **其他** +- 通过设置媒体服务器Webhook指向MoviePilot(相对路径为`/api/v1/webhook?token=moviepilot`,其中`moviepilot`为设置的`API_TOKEN`),可实现通过MoviePilot发送播放通知,以及配合各类插件实现播放限速等功能。 +- 映射宿主机`docker.sock`文件到容器`/var/run/docker.sock`,可支持应用内建重启操作。实例:`-v /var/run/docker.sock:/var/run/docker.sock:ro`。 - 将WEB页面添加到手机桌面图标可获得与App一样的使用体验。 ### **注意** @@ -219,6 +231,13 @@ location /cgi-bin/menu/create { } ``` +- 部分插件功能基于文件系统监控实现(如`目录监控`等),需在宿主机上(不是docker容器内)执行以下命令并重启: +```shell +echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf +echo fs.inotify.max_user_instances=524288 | sudo tee -a /etc/sysctl.conf +sudo sysctl -p +``` + ![image](https://github.com/jxxghp/MoviePilot/assets/51039935/f2654b09-26f3-464f-a0af-1de3f97832ee) ![image](https://github.com/jxxghp/MoviePilot/assets/51039935/fcb87529-56dd-43df-8337-6e34b8582819) diff --git a/app/chain/download.py b/app/chain/download.py index 599b3189..161405c0 100644 --- a/app/chain/download.py +++ b/app/chain/download.py @@ -212,7 +212,7 @@ class DownloadChain(ChainBase): if _media.genre_ids \ and set(_media.genre_ids).intersection(set(settings.ANIME_GENREIDS)): # 动漫 - download_dir = settings.SAVE_ANIME_PATH + download_dir = settings.SAVE_ANIME_PATH / _media.category else: # 电视剧 download_dir = settings.SAVE_TV_PATH / _media.category diff --git a/app/core/config.py b/app/core/config.py index 7f0ac4d6..7286b0a6 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -69,6 +69,8 @@ class Settings(BaseSettings): '.tp'] # 支持的字幕文件后缀格式 RMT_SUBEXT: list = ['.srt', '.ass', '.ssa', '.sup'] + # 下载器临时文件后缀 + DOWNLOAD_TMPEXT: list = ['.!qB', '.part'] # 支持的音轨文件后缀格式 RMT_AUDIO_TRACK_EXT: list = ['.mka'] # 索引器 diff --git a/app/helper/torrent.py b/app/helper/torrent.py index ae662022..c70244b3 100644 --- a/app/helper/torrent.py +++ b/app/helper/torrent.py @@ -324,24 +324,26 @@ class TorrentHelper(metaclass=Singleton): if not filter_rule: return True + + # 匹配内容 + content = f"{torrent_info.title} {torrent_info.description} {' '.join(torrent_info.labels or [])}" # 最少做种人数 min_seeders = filter_rule.get("min_seeders") if min_seeders and torrent_info.seeders < int(min_seeders): logger.info(f"{torrent_info.title} 做种人数不足 {min_seeders}") return False + # 包含 include = filter_rule.get("include") if include: - if not re.search(r"%s" % include, - f"{torrent_info.title} {torrent_info.description}", re.I): + if not re.search(r"%s" % include, content, re.I): logger.info(f"{torrent_info.title} 不匹配包含规则 {include}") return False # 排除 exclude = filter_rule.get("exclude") if exclude: - if re.search(r"%s" % exclude, - f"{torrent_info.title} {torrent_info.description}", re.I): + if re.search(r"%s" % exclude, content, re.I): logger.info(f"{torrent_info.title} 匹配排除规则 {exclude}") return False # 质量 diff --git a/app/modules/filter/__init__.py b/app/modules/filter/__init__.py index 1f77e5d1..1b01759f 100644 --- a/app/modules/filter/__init__.py +++ b/app/modules/filter/__init__.py @@ -39,12 +39,19 @@ class FilterModule(_ModuleBase): # 中字 "CNSUB": { "include": [ - r'[中国國繁简](/|\s|\\|\|)?[繁简英粤]|[英简繁](/|\s|\\|\|)?[中繁简]|繁體|简体|[中国國][字配]|国语|國語|中文|中字|简日|繁日|简繁|繁体|([\s,.-\[])(CHT|CHS|cht|chs)(|[\s,.-\]])'], + r'[中国國繁简](/|\s|\\|\|)?[繁简英粤]|[英简繁](/|\s|\\|\|)?[中繁简]' + r'|繁體|简体|[中国國][字配]|国语|國語|中文|中字|简日|繁日|简繁|繁体' + r'|([\s,.-\[])(CHT|CHS|cht|chs)(|[\s,.-\]])'], "exclude": [], "tmdb": { "original_language": "zh,cn" } }, + # 官种 + "GZ": { + "include": [r'官方', r'官种'], + "match": ["labels"] + }, # 特效字幕 "SPECSUB": { "include": [r'特效'], @@ -256,14 +263,30 @@ class FilterModule(_ModuleBase): # 符合TMDB规则的直接返回True,即不过滤 if tmdb and self.__match_tmdb(tmdb): return True + # 匹配项:标题、副标题、标签 + content = f"{torrent.title} {torrent.description} {' '.join(torrent.labels or [])}" + # 只匹配指定关键字 + match_content = [] + matchs = self.rule_set[rule_name].get("match") or [] + if matchs: + for match in matchs: + if not hasattr(torrent, match): + continue + match_value = getattr(torrent, match) + if not match_value: + continue + if isinstance(match_value, list): + match_content.extend(match_value) + else: + match_content.append(match_value) + if match_content: + content = " ".join(match_content) # 包含规则项 includes = self.rule_set[rule_name].get("include") or [] # 排除规则项 excludes = self.rule_set[rule_name].get("exclude") or [] # FREE规则 downloadvolumefactor = self.rule_set[rule_name].get("downloadvolumefactor") - # 匹配项 - content = f"{torrent.title} {torrent.description} {' '.join(torrent.labels or [])}" for include in includes: if not re.search(r"%s" % include, content, re.IGNORECASE): # 未发现包含项 diff --git a/app/modules/themoviedb/category.py b/app/modules/themoviedb/category.py index 4b31a5a0..daf2f091 100644 --- a/app/modules/themoviedb/category.py +++ b/app/modules/themoviedb/category.py @@ -15,6 +15,7 @@ class CategoryHelper(metaclass=Singleton): _categorys = {} _movie_categorys = {} _tv_categorys = {} + _anime_categorys = {} def __init__(self): self._category_path: Path = settings.CONFIG_PATH / "category.yaml" @@ -43,6 +44,7 @@ class CategoryHelper(metaclass=Singleton): if self._categorys: self._movie_categorys = self._categorys.get('movie') self._tv_categorys = self._categorys.get('tv') + self._anime_categorys = self._categorys.get('anime') logger.info(f"已加载二级分类策略 category.yaml") @property @@ -81,6 +83,15 @@ class CategoryHelper(metaclass=Singleton): return [] return self._tv_categorys.keys() + @property + def anime_categorys(self) -> list: + """ + 获取动漫分类清单 + """ + if not self._anime_categorys: + return [] + return self._anime_categorys.keys() + def get_movie_category(self, tmdb_info) -> str: """ 判断电影的分类 @@ -91,10 +102,14 @@ class CategoryHelper(metaclass=Singleton): def get_tv_category(self, tmdb_info) -> str: """ - 判断电视剧的分类 + 判断电视剧的分类,包括动漫 :param tmdb_info: 识别的TMDB中的信息 :return: 二级分类的名称 """ + genre_ids = tmdb_info.get("genre_ids") or [] + if genre_ids \ + and set(genre_ids).intersection(set(settings.ANIME_GENREIDS)): + return self.get_category(self._anime_categorys, tmdb_info) return self.get_category(self._tv_categorys, tmdb_info) @staticmethod diff --git a/config/category.yaml b/config/category.yaml index 2e897dcc..51104c00 100644 --- a/config/category.yaml +++ b/config/category.yaml @@ -47,6 +47,15 @@ tv: # 未匹配以上分类,则命名为未分类 未分类: +# 配置动漫的分类策略 +anime: + 国漫: + # 匹配 origin_country 国家,CN是中国大陆,TW是中国台湾,HK是中国香港 + origin_country: 'CN,TW,HK' + 日番: + # 匹配 origin_country 国家,JP是日本 + origin_country: 'JP' + 未分类: ## genre_ids 内容类型 字典,注意部分中英文是不一样的 # 28 Action