深色模式
自定义通知模板
NanShare 的通知模板集中使用 Jinja2 风格变量。文件整理 TG 通知和 Emby 通知使用结构化模板;订阅通知使用纯文本模板。示例中的链接和 ID 都是占位符。
模板类型
| 场景 | 配置位置 | 模板结构 |
|---|---|---|
| 文件整理 TG 通知模板 | 文件整理基础配置 | title、text、image、link |
| 订阅通知模板 | 订阅配置 | 纯文本 Jinja2 |
| Emby 通知模板 | 工具箱 / Emby 通知 | title、text、image |
Jinja2 常用写法
条件:
text
{% if year %} ({{ year }}){% endif %}默认值:
text
{{ releaseGroup or release_group or "未知制作组" }}循环:
text
{% for file in strm_files %}
- {{ file }}
{% endfor %}格式化:
text
S{{ "%02d"|format(season|int) }}E{{ "%02d"|format(episode|int) }}文件整理 TG 通知模板
文件整理通知模板支持 JSON/YAML 对象格式,也兼容 Python 字典字面量格式。结构键为:
| 键 | 说明 |
|---|---|
title | 通知标题 |
text | 通知正文 |
image | 图片 URL,可留空,留空时会尝试使用海报或背景图 |
link | 查看详情链接,可留空 |
默认模板
text
{
"title": "🎬 {{ title_year }} {{ season_episode if season_episode else '' }} 已入库\n\n",
"text": (
"✨ 质量:{{ resource_quality }}\n"
"{% if vote_average %}"
"🌟 评分:{{ vote_average }}/10\n"
"{% endif %}"
"{% if media_type or category %}"
"🎞 类型:{{ media_type }} · 🏷 类别:{{ category }}\n"
"{% endif %}"
"📂 数量:{{ file_count }} 个 · 💾 大小:{{ total_size }}\n"
"{% if release_group %}"
"👥 小组:{{ release_group }}\n"
"{% endif %}"
"⚡ 用时:{{ time_usage if time_usage else '未知' }}\n\n"
"🔗 :[TMDB](https://www.themoviedb.org/{% if '电视' in media_type %}tv{% else %}movie{% endif %}/{{ tmdbid }}) · [豆瓣](https://m.douban.com/search/?query={{ title }}) · [IMDB](https://www.imdb.com/title/{{ imdbid }}) · [TVDB](https://thetvdb.com/?id={{ tvdbid }}&tab=series)\n"
"{% if overview %}\n"
"📝 简介:\n{{ overview | truncate(50, True, '...') }}"
"{% endif %}"
)
}支持字段
| 字段 | 说明 |
|---|---|
title_year | 标题和年份,例如 年会不能停! (2023) |
title | 媒体标题 |
year | 年份 |
season_episode | 季集,电影为空 |
media_type | 媒体类型,例如 电影、电视剧 |
category | 整理后的二级分类 |
resource_quality | 质量组合,例如 WEB-DL HDR10 2160p |
releaseGroup | 制作组 |
release_group | 制作组兼容别名 |
resource_term | 资源类型、特效、分辨率组合 |
webSource | 解析结果中的平台字段;存在时可用于通知 |
audioCodec | 音频编码 |
vote_average | TMDB/豆瓣评分 |
overview | 简介 |
time_usage | 整理耗时 |
total_size | 总大小 |
file_count | 文件数量 |
tmdbid | TMDB ID |
imdbid | IMDb ID |
tvdbid | TVDB ID |
doubanid | 豆瓣 ID |
简洁示例
text
title: "{{ title_year }}{% if season_episode %} {{ season_episode }}{% endif %} 已入库"
text: |
类型:{{ media_type }}
分类:{{ category }}
质量:{{ resource_quality }}
制作组:{{ releaseGroup or release_group }}
文件:{{ file_count }} 个
大小:{{ total_size }}
用时:{{ time_usage or "未知" }}
image: ""
link: "https://www.themoviedb.org/{% if '电视' in media_type %}tv{% else %}movie{% endif %}/{{ tmdbid }}"剧集示例
text
title: "📺 {{ title_year }} {{ season_episode }} 已整理"
text: |
分类:{{ category }}
规格:{{ resource_quality }}
音频:{{ audioCodec }}
小组:{{ release_group or "未知" }}
大小:{{ total_size }}
{% if overview %}简介:{{ overview | truncate(80, True, "...") }}{% endif %}
image: ""
link: ""订阅通知模板
订阅通知模板是纯文本 Jinja2。NanShare 会把订阅、选中资源、处理结果、完成集数等上下文传入模板。
默认模板
text
🎬 订阅追更通知
📌 {{ name }}{% if year %} ({{ year }}){% endif %}
{% if season_ep %}📺 {{ season_ep }}
{% endif %}📋 {{ mode_text }}
{% if version %}🏷️ {{ version }}
{% endif %}{% if strm_result %}
📁 {{ strm_result }}
{% endif %}{% if ep_progress %}
📊 {{ ep_progress }}
{% endif %}支持字段
| 字段 | 说明 |
|---|---|
sub | 当前订阅对象完整数据 |
selected | 本次选中的资源项 |
all_items | 本次处理的所有资源项 |
media_type | movie 或 tv |
name | 订阅名称 |
year | 年份 |
season_ep | 季集范围,例如 S02 E01-03 |
mode | 策略值,例如 transfer 或分享策略 |
mode_text | 策略中文名,例如 订阅转存、分享追更 |
version | 版本信息组合 |
ep_progress | 剧集进度文本 |
strm_result | STRM 生成结果摘要 |
strm_files | 本次生成的 STRM 文件列表 |
share_link | 使用的分享链接 |
done_eps | 本次完成的集数列表 |
completed_episodes | 当前已完成集数列表 |
resolution | 分辨率 |
effect | 特效 |
resource_type | 资源类型 |
release_group | 制作组 |
video_codec | 视频编码 |
audio_codec | 音频编码 |
电影示例
text
🎬 {{ name }}{% if year %} ({{ year }}){% endif %}
策略:{{ mode_text }}
版本:{{ version or "未识别" }}
分辨率:{{ resolution or "未知" }}
特效:{{ effect or "无" }}
制作组:{{ release_group or "未知" }}
{% if strm_result %}结果:{{ strm_result }}{% endif %}
{% if share_link %}分享:{{ share_link }}{% endif %}剧集示例
text
📺 {{ name }} {{ season_ep }}
策略:{{ mode_text }}
完成:{{ ep_progress }}
本次集数:{% for ep in done_eps %}E{{ "%02d"|format(ep) }} {% endfor %}
版本:{{ resolution }} {{ effect }} {{ resource_type }}
{% if strm_files %}
文件:
{% for file in strm_files %}- {{ file }}
{% endfor %}
{% endif %}Emby 通知模板
Emby 通知模板位于 工具箱 / Emby 通知。结构键为:
| 键 | 说明 |
|---|---|
title | 通知标题 |
text | 通知正文 |
image | 图片 URL;留空时会尝试使用 image_url |
Webhook 地址:
text
http://你的IP:8115/api/emby_notify/webhook?token=nanshare默认模板
下面是 NanShare Emby 通知的完整默认模板,可直接复制到 Emby 通知页面使用:
text
{
"title": "{% if action == '新入库' and media_type == '电影' %}🎬 {% elif action == '新入库' and media_type == '剧集' %}📺 {% elif action == '新入库' and media_type == '有声书' %}📚 {% elif action == '新入库' %}🆕 {% elif action == '测试' %}🧪 {% elif action == '开始播放' %}▶️ {% elif action == '停止播放' %}⏹️ {% elif action == '登录成功' %}✅ {% elif action == '登录失败' %}❌ {% elif action == '标记了' %}🏷️ {% endif %}{% if user_name %}【{{ user_name }}】{% endif %}{{ action }}{% if media_type %} {{media_type}} {% endif %}{{ item_name }}{% if mark_status %} {{ mark_status }}{% endif %}",
"text":
"{% set va = vote_average|default(0)|float(0) %}"
"{% set mt_lower = media_type|default('', true)|lower %}"
"{% set action_lower = action|default('', true)|lower %}"
"{% set is_new_content = '新入库' in action %}"
"{% set is_playing = '开始播放' in action %}"
"{% set is_stopped = '停止播放' in action %}"
"{% set is_login_success = '登录成功' in action %}"
"{% set is_login_failed = '登录失败' in action %}"
"{% set is_marked = '标记了' in action %}"
"{% set progress_num = percentage|default(0)|int(0) %}"
"{% set time_str = now_time|default('12:00:00') %}"
"{% if ' ' in time_str %}{% set time_part = time_str.split(' ')[1] %}{% else %}{% set time_part = time_str %}{% endif %}"
"{% set hour = time_part.split(':')[0]|int if ':' in time_part else 12 %}"
"{% set is_late_night = hour >= 23 or hour < 6 %}"
"{% set is_early_morning = hour >= 6 and hour < 9 %}"
"{% set is_morning = hour >= 9 and hour < 12 %}"
"{% set is_noon = hour >= 12 and hour < 14 %}"
"{% set is_afternoon = hour >= 14 and hour < 18 %}"
"{% set is_evening = hour >= 18 and hour < 23 %}"
"{% if vote_average %}⭐️ 评分:{{ vote_average }}/10\n{% endif %}"
"{% if media_type == '电影' %}🎦{% elif media_type == '剧集' %}📺{% elif media_type == '有声书' %}📚{% else %}📱{% endif %} 媒体类型:{{ media_type }}\n"
"{% if percentage %}🔄 播放进度:{{ percentage }}%\n{% endif %}"
"{% if ip_address %}🌐 来源IP:{{ ip_address }}\n{% endif %}"
"{% if device_name %}📱 播放设备:{{ client }} {{ device_name }}\n{% endif %}"
"{% if user_name and not is_new_content %}👤 用户:{{ user_name }}\n{% endif %}"
"{% if tmdbid %}🍿 TMDB ID:{{ tmdbid }}\n{% endif %}"
"{% if imdbid %}🌟 IMDB ID:{{ imdbid }}\n{% endif %}"
"🕒 操作时间:{{ now_time }}\n"
"{% if overview and is_new_content %}"
"\n📝 简介:{{ overview[:100] }}…\n"
"{% elif overview and not is_new_content %}\n📝 剧情:{{ overview }}{% endif %}"
"{% if tmdbid or imdbid or item_name %}"
"\n\n{% set has_links = false %}"
"{% if tmdbid %}🔗 [TMDB](https://www.themoviedb.org/{% if media_type == '电影' %}movie{% elif media_type == '剧集' %}tv{% else %}movie{% endif %}/{{ tmdbid }}){% set has_links = true %}{% endif %}"
"{% set douban_search_possible = imdbid or item_name %}"
"{% if has_links and douban_search_possible %} | {% endif %}"
"{% if douban_search_possible %}✳️ {% if imdbid %}[豆瓣](https://www.douban.com/search?cat=1002&q={{ imdbid }}){% else %}[豆瓣](https://www.douban.com/search?cat=1002&q={{ item_name | urlencode }}){% endif %}{% set has_links = true %}{% endif %}"
"{% if imdbid %}{% if has_links %} | {% endif %}🌟 [IMDb](https://www.imdb.com/title/{{ imdbid }}/){% set has_links = true %}{% endif %}"
"{% if has_links %}\n{% endif %}"
"{% endif %}"
"\n"
"{% if is_new_content %}"
"{% if va >= 9.8 %}👑🔥 这TM才是真·封神榜!跪着看就完事了,建议全体起立!"
"{% elif va >= 9.5 %}💥 卧槽这分是充了多少钱?但有一说一确实能打,建议申遗!"
"{% elif va >= 9.0 %}🤙 这波在大气层!年度装逼必备作品,不看不是社会人!"
"{% elif va >= 8.5 %}👍 这分对得起你熬的夜!建议搭配炸鸡啤酒食用更佳~"
"{% elif va >= 8.0 %}🍺 中规中矩电子榨菜,拉屎时看刚刚好!"
"{% elif va >= 7.5 %}🤏 也就图一乐,建议开2倍速别浪费生命!"
"{% elif va >= 7.0 %}🙄 这分是刷的吧?建议下载反诈APP!"
"{% elif va >= 6.0 %}😅 6分保底神作,建议配合弹幕护体食用!"
"{% elif va >= 5.0 %}💩 卧槽这答辩也敢入库?建议申报金扫帚奖!"
"{% elif va >= 4.0 %}🤮 导演是喝高了拍的?建议众筹给编剧寄刀片!"
"{% elif va > 0 %}👻 这分是来搞行为艺术的?建议配合降压药观看!"
"{% elif media_type == '电影' %}🎬 新片到货!是骡子是马拉出来溜溜~"
"{% elif media_type == '剧集' %}📺 新剧上架!建议备好瓜子板凳开喷!"
"{% else %}🆕 新货到仓!是惊喜还是惊吓你说了算!{% endif %}"
"{% elif is_playing %}"
"{% if va > 0 %}"
"{% if va >= 9.8 %}🤯 全体注意!前方高能!建议暂停呼吸!"
"{% elif va >= 9.5 %}🚨 这不是演习!请系好安全带准备起飞!"
"{% elif va >= 9.0 %}💥 前方名场面预警!建议录屏反复观看!"
"{% elif va >= 8.5 %}🎇 建议关闭手机!错过镜头血亏一个亿!"
"{% elif va >= 8.0 %}🍿 瓜子饮料准备好,这个能下三碗饭!"
"{% elif va >= 7.5 %}📱 建议开弹幕,没网友吐槽根本看不下去!"
"{% elif va >= 7.0 %}😑 就当听个响,建议边刷抖音边看!"
"{% elif va >= 6.0 %}🤏 建议2倍速观看,时间就是金钱!"
"{% elif va >= 5.0 %}💣 勇士拔剑吧!建议呼叫沙雕网友陪看!"
"{% elif va >= 4.0 %}⚠️ 非战斗人员请撤离!辣眼睛预警!"
"{% else %}☢️ 注意这不是演习!烂片核爆倒计时!"
"{% endif %}"
"{% else %}"
"{% if is_late_night %}"
"{% if progress_num <= 5 %}🌙 大半夜不睡觉是吧?年轻人就是肝!"
"{% elif progress_num <= 20 %}🌃 夜猫子认证!建议来包辣条提神!"
"{% elif progress_num <= 50 %}🌌 这是要决战到天亮?瑞思拜!"
"{% elif progress_num <= 80 %}🌅 看到这个点?明天上班等着摸鱼吧!"
"{% else %}😴 好家伙直接看到天亮?建议申遗!{% endif %}"
"{% else %}"
"{% if progress_num <= 5 %}🚀 刚开局就想跑?给导演个面子!"
"{% elif progress_num <= 20 %}👀 前戏还没完!精彩的在后面!"
"{% elif progress_num <= 50 %}🎢 过山车开到半山腰!坐稳了!"
"{% elif progress_num <= 80 %}🔥 高潮要来了!纸巾备好!"
"{% else %}🏁 最后冲刺!憋住别上厕所!{% endif %}"
"{% endif %}"
"{% endif %}"
"{% elif is_stopped %}"
"{% if va > 0 %}"
"{% if va >= 9.8 %}⏹️ 暂停神片?建议立即续播否则浑身蚂蚁爬!"
"{% elif va >= 9.5 %}⏸️ 看到一半暂停?你是真能忍!"
"{% elif va >= 9.0 %}🚫 暂停装逼现场?建议立即恢复!"
"{% elif va >= 8.5 %}🛑 看到高潮刹车?兄弟你好狠!"
"{% elif va >= 8.0 %}⏸️ 暂停干饭?建议边吃边看!"
"{% elif va >= 7.5 %}⏹️ 弃剧保平安!这波我站你!"
"{% elif va >= 7.0 %}🛌 暂停得好!建议换隔壁小姐姐直播!"
"{% elif va >= 6.0 %}⏸️ 明智选择!建议转战王者峡谷!"
"{% elif va >= 5.0 %}🗑️ 暂停得好!建议永久删除!"
"{% elif va >= 4.0 %}💢 暂停看这玩意?建议立即洗眼睛!"
"{% else %}☠️ 暂停保命!建议领取抗烂片补助!"
"{% endif %}"
"{% else %}"
"{% if is_late_night %}"
"{% if progress_num >= 90 %}🌙 看到最后才停?是个狼灭!"
"{% elif progress_num >= 70 %}😴 看到这程度可以了,梦里啥都有!"
"{% elif progress_num >= 30 %}🌃 暂停在这?你是懂吊胃口的!"
"{% else %}👋 才看这点就停?建议直接右上角!{% endif %}"
"{% else %}"
"{% if progress_num >= 90 %}🎉 看到最后都是勇士!建议申请吉尼斯纪录!"
"{% elif progress_num >= 70 %}🛋️ 看到这程度,算对得起导演了!"
"{% elif progress_num >= 30 %}⏸️ 暂停在这?你是懂吊胃口的!"
"{% else %}👋 才看这点?建议转行当影评人!{% endif %}"
"{% endif %}"
"{% endif %}"
"{% elif is_login_success %}"
"{% if is_late_night %}🌙 夜猫子登录!建议开启隐身模式!"
"{% elif is_early_morning %}🌅 早起的鸟儿被抓包!建议装睡!"
"{% else %}🎉 欢迎老铁!建议备好肥宅快乐水!{% endif %}"
"{% elif is_login_failed %}⚠️ 密码不对还想白嫖?建议充值智商!"
"{% elif is_marked %}🏷️ 标记成功!建议同步发朋友圈装逼!"
"{% else %}📱 系统诈尸!建议立即截图发贴吧!{% endif %}\n"
"image": "{{ image_url }}"
}支持事件
| 动作 | Webhook 事件别名 |
|---|---|
| 新入库 | library.new、item.added、ItemAdded |
| 开始播放 | playback.start、media.play、PlaybackStart |
| 停止播放 | playback.stop、media.stop、PlaybackStop |
| 登录成功 | user.authenticated、UserAuthenticated、UserLoggedIn |
| 登录失败 | user.authenticationfailed、UserAuthenticationFailed、UserLoginFailed、UserLockedOut |
| 标记了 | item.rate、ItemRated、ItemMarkedPlayed、ItemMarkedFavorite 等 |
支持字段
| 字段 | 说明 |
|---|---|
action | 映射后的中文动作 |
mark_status | 标记事件状态,例如已观看、已收藏 |
action_detail | 动作补充说明 |
media_type | 媒体类型 |
item_name | 媒体名称 |
user_name | Emby 用户 |
client | 客户端 |
device_name | 设备名称 |
ip_address | 来源 IP |
percentage | 播放进度 |
vote_average | 评分 |
overview | 简介 |
tmdbid | TMDB ID |
imdbid | IMDb ID |
now_time | 操作时间 |
event | 原始事件 |
item_id | Emby Item ID |
series_id | 剧集 ID |
season_id | 季 ID |
episode_id | 集 ID |
server_name | Emby 服务器名称 |
image_url | NanShare 生成的图片地址 |
raw_json | 解析后的 Webhook JSON 文本 |
简洁播放通知
text
title: "{{ action }} - {{ item_name }}"
text: |
用户:{{ user_name }}
客户端:{{ client }} / {{ device_name }}
进度:{{ percentage }}%
时间:{{ now_time }}
image: "{{ image_url }}"新入库通知
text
title: "🆕 {{ media_type }} {{ item_name }} 已入库"
text: |
评分:{{ vote_average or "暂无" }}
TMDB:{{ tmdbid }}
IMDb:{{ imdbid }}
{% if overview %}简介:{{ overview[:120] }}{% endif %}
image: "{{ image_url }}"