@@ -77,50 +77,64 @@ def refresh_after_task(job, status):
7777 # 组装需刷新基本路径
7878 base_paths = []
7979 name = remark
80- env_refresh = os .getenv ('REFRESH_TV_TARGETS' ) if is_tv else os .getenv ('REFRESH_MOV_TARGETS' )
81- if env_refresh :
82- raw = [p .strip () for p in re .split (r"[,;:]" , env_refresh ) if p and p .strip () != '' ]
83- tv_prefix = _select_latest_odc_prefix (client , 'tv' )
84- mov_prefix = _select_latest_odc_prefix (client , 'mov' )
85- for base in raw :
86- base = base .replace ('{odc_tv}' , tv_prefix ).replace ('{odc_mov}' , mov_prefix )
87- if not base .startswith ('/' ):
88- base = '/' + base
89- base = re .sub (r"/{2,}" , "/" , base )
90- base_paths .append (f"{ base .rstrip ('/' )} /{ category } /{ name } " )
80+ only_shanct = (is_tv and dsts and all (p .startswith ('/shanct/电视剧' ) for p in dsts ))
81+ if is_tv and only_shanct :
82+ # 仅同步到 /shanct 时,只刷新 /shanct 与 /videos
83+ base_paths = [
84+ f"/shanct/电视剧/{ name } " ,
85+ f"/videos/电视剧/{ name } "
86+ ]
9187 else :
92- if is_tv :
93- only_shanct = dsts and all (p .startswith ('/shanct/电视剧' ) for p in dsts )
94- if only_shanct :
95- base_paths = [
96- f"/shanct/电视剧/{ name } " ,
97- f"/videos/电视剧/{ name } "
98- ]
99- else :
88+ env_refresh = os .getenv ('REFRESH_TV_TARGETS' ) if is_tv else os .getenv ('REFRESH_MOV_TARGETS' )
89+ dedup = []
90+ seen = set ()
91+ if env_refresh :
92+ raw = [p .strip () for p in re .split (r"[,;:]" , env_refresh ) if p and p .strip () != '' ]
93+ tv_prefix = _select_latest_odc_prefix (client , 'tv' )
94+ mov_prefix = _select_latest_odc_prefix (client , 'mov' )
95+ for base in raw :
96+ base = base .replace ('{odc_tv}' , tv_prefix ).replace ('{odc_mov}' , mov_prefix )
97+ if not base .startswith ('/' ):
98+ base = '/' + base
99+ base = re .sub (r"/{2,}" , "/" , base ).rstrip ('/' )
100+ path = f"{ base } /{ category } /{ name } "
101+ if path not in seen :
102+ dedup .append (path )
103+ seen .add (path )
104+ else :
105+ # 默认回退逻辑
106+ if is_tv :
100107 for p in dsts :
101108 m = re .search (r"/ODC/(tv\d+)/电视剧/" , p )
102109 if m :
103110 odc_prefix = m .group (1 )
104111 break
105112 if odc_prefix is None :
106113 odc_prefix = _select_latest_odc_prefix (client , 'tv' )
107- base_paths = [
108- f"/115/videos/电视剧/{ name } " ,
109- f"/ODC/{ odc_prefix } /电视剧/{ name } " ,
110- f"/videos/电视剧/{ name } "
111- ]
112- else :
113- for p in dsts :
114- m = re .search (r"/ODC/(mov\d+)/电影/" , p )
115- if m :
116- odc_prefix = m .group (1 )
117- break
118- if odc_prefix is None :
119- odc_prefix = _select_latest_odc_prefix (client , 'mov' )
120- base_paths = [
121- f"/115/videos/电影/{ name } " ,
122- f"/ODC/{ odc_prefix } /电影/{ name } "
123- ]
114+ for base in [f"/115/videos/{ category } " , f"/ODC/{ odc_prefix } /{ category } " ]:
115+ path = f"{ base } /{ name } "
116+ if path not in seen :
117+ dedup .append (path )
118+ seen .add (path )
119+ else :
120+ for p in dsts :
121+ m = re .search (r"/ODC/(mov\d+)/电影/" , p )
122+ if m :
123+ odc_prefix = m .group (1 )
124+ break
125+ if odc_prefix is None :
126+ odc_prefix = _select_latest_odc_prefix (client , 'mov' )
127+ for base in [f"/115/videos/{ category } " , f"/ODC/{ odc_prefix } /{ category } " ]:
128+ path = f"{ base } /{ name } "
129+ if path not in seen :
130+ dedup .append (path )
131+ seen .add (path )
132+ # 始终追加 /videos 路径
133+ videos_path = f"/videos/{ category } /{ name } "
134+ if videos_path not in seen :
135+ dedup .append (videos_path )
136+ seen .add (videos_path )
137+ base_paths = dedup
124138 if not base_paths :
125139 return
126140 # 解析 Season 并刷新
0 commit comments