@@ -94,7 +94,33 @@ def _trigger():
9494 except Exception :
9595 pass
9696 return
97- openlistId = int (openlists [0 ]['id' ])
97+
98+ openlistId = None
99+ webhook_engine_name = os .getenv ('WEBHOOK_OPENLIST_NAME' )
100+
101+ if webhook_engine_name :
102+ webhook_engine_name = webhook_engine_name .strip ()
103+ target_op = next ((op for op in openlists if op .get ('remark' ) == webhook_engine_name ), None )
104+ if target_op :
105+ openlistId = int (target_op ['id' ])
106+ else :
107+ # 如果指定了引擎但未找到,发送通知并停止
108+ try :
109+ lg .error (f"Webhook configured engine '{ webhook_engine_name } ' not found" )
110+ notify_list = notifyService .getNotifyList (True )
111+ if notify_list :
112+ for n in notify_list :
113+ try :
114+ notifyService .sendNotify (n , 'Webhook 错误' , f"未找到名称为 '{ webhook_engine_name } ' 的OpenList引擎" , False )
115+ except Exception :
116+ pass
117+ except Exception :
118+ pass
119+ return
120+ else :
121+ # 默认使用第一个引擎
122+ openlistId = int (openlists [0 ]['id' ])
123+
98124 from service .openlist import openlistService
99125 client = None
100126 try :
@@ -189,19 +215,15 @@ def max_replacer(match):
189215
190216 return re .sub (r"(^|.*?/)([^/]*)\{max\}" , max_replacer , path_str )
191217
192- odc_prefix = _pick ('tv' if tv_flag else 'mov' )
193218 srcPath = f"{ media_root .rstrip ('/' )} /{ remark } /"
194219 dst_env = os .getenv ('DST_TV_TARGETS' ) if tv_flag else os .getenv ('DST_MOV_TARGETS' )
195220 dsts = []
196221 if dst_env and client is not None :
197222 try :
198223 raw_dst = [p .strip () for p in re .split (r"[,;:]" , dst_env ) if p and p .strip () != '' ]
199- tv_prefix = _pick ('tv' )
200- mov_prefix = _pick ('mov' )
201224 for base in raw_dst :
202225 # 支持 {max} 语法
203226 base = _resolve_max_placeholder (base )
204- base = base .replace ('{odc_tv}' , tv_prefix ).replace ('{odc_mov}' , mov_prefix )
205227 if not base .startswith ('/' ):
206228 base = '/' + base
207229 base = re .sub (r"/{2,}" , "/" , base ).rstrip ('/' )
@@ -216,12 +238,9 @@ def max_replacer(match):
216238 sync_env = os .getenv ('SYNC_TV_TARGETS' ) if tv_flag else os .getenv ('SYNC_MOV_TARGETS' )
217239 if sync_env :
218240 raw = [p .strip () for p in re .split (r"[,;:]" , sync_env ) if p and p .strip () != '' ]
219- tv_prefix = _pick ('tv' )
220- mov_prefix = _pick ('mov' )
221241 for base in raw :
222242 # 支持 {max} 语法
223243 base = _resolve_max_placeholder (base )
224- base = base .replace ('{odc_tv}' , tv_prefix ).replace ('{odc_mov}' , mov_prefix )
225244 if not base .startswith ('/' ):
226245 base = '/' + base
227246 base = re .sub (r"/{2,}" , "/" , base ).rstrip ('/' )
0 commit comments