diff --git a/docker-compose.redis.yml b/docker-compose.redis.yml index fdbcda8..6f3a9d5 100644 --- a/docker-compose.redis.yml +++ b/docker-compose.redis.yml @@ -3,7 +3,7 @@ version: '3.8' services: # KatelyaTV 应用服务 katelyatv: - image: katelyatv:fixed17 + image: katelyatv:fixed18 container_name: katelyatv ports: - "3030:3000" diff --git a/patches/patch-home-hkdrama.py b/patches/patch-home-hkdrama.py new file mode 100644 index 0000000..f646709 --- /dev/null +++ b/patches/patch-home-hkdrama.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python3 +"""首页注入「最新港剧」板块(热门电影上方,5条,聚合接口t=902 by=time) +并移除顶部导航「直播」菜单项。幂等可重跑。""" +import subprocess, tempfile, os + +PC = "/app/.next/static/chunks/app/page-1a01a64271e1f47e.js" +NC = "/app/.next/static/chunks/402-42ae253cc67eee98.js" + +def read(p): + return subprocess.run(["docker","exec","katelyatv","cat",p],capture_output=True,check=True).stdout.decode() + +def write(p, data): + r=subprocess.run(["docker","exec","-i","katelyatv","sh","-c",f"cat > {p}"],input=data.encode(),capture_output=True) + assert r.returncode==0, r.stderr.decode()[:300] + +def check(src, tag): + with tempfile.NamedTemporaryFile('w', suffix='.js', delete=False) as f: + f.write(src); tmp=f.name + r=subprocess.run(['node','--check',tmp],capture_output=True,text=True) + os.unlink(tmp) + assert r.returncode==0, f"{tag}: {r.stderr[:500]}" + +COMPONENT = r'''var __HKDrama__=function(){var R=o,useState=R.useState,useEffect=R.useEffect; +var st=useState([]),d=st[0],setD=st[1]; +var img=(window.RUNTIME_CONFIG&&window.RUNTIME_CONFIG.IMAGE_PROXY)||""; +useEffect(function(){ +fetch("/api/tvbox/all?ac=videolist&t=902&pg=1&by=time").then(function(r){return r.json()}).then(function(j){setD(((j&&j.list)||[]).slice(0,5))}).catch(function(){})},[]); +if(!d.length)return null; +return(0,s.jsxs)("section",{className:"mb-8",children:[ +(0,s.jsxs)("div",{className:"mb-4 flex items-center justify-between",children:[ +(0,s.jsx)("h2",{className:"text-xl font-bold text-gray-800 dark:text-gray-200",children:"最新港剧"}), +(0,s.jsxs)(i.default,{href:"/douban?type=tv",className:"flex items-center text-sm text-gray-500 hover:text-purple-700 dark:text-gray-400 dark:hover:text-purple-300 transition-colors",children:["查看更多",(0,s.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-chevron-right w-4 h-4 ml-1",children:(0,s.jsx)("path",{d:"m9 18 6-6-6-6"})})]}) +]}), +(0,s.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4 relative",children:d.map(function(v){ +var key=String(v.vod_id||""),sep=key.indexOf(":"),ks=sep>0?key.slice(0,sep):"",kid=sep>0?key.slice(sep+1):key; +var pic=v.vod_pic?(img+encodeURIComponent(v.vod_pic)):""; +return(0,s.jsxs)(i.default,{href:"/play?source="+encodeURIComponent(ks)+"&id="+encodeURIComponent(kid)+"&stitle="+encodeURIComponent(v.vod_name||"")+"&stype=tv",className:"group block",children:[ +(0,s.jsxs)("div",{className:"relative aspect-[2/3] w-full overflow-hidden rounded-lg bg-gray-200 dark:bg-gray-800",children:[ +pic?(0,s.jsx)("img",{src:pic,alt:v.vod_name||"",loading:"lazy",className:"absolute inset-0 w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):null, +v.vod_remarks?(0,s.jsx)("span",{className:"absolute bottom-1 right-1 px-1.5 py-0.5 text-xs bg-black/65 text-white rounded",children:v.vod_remarks}):null +]}), +(0,s.jsx)("div",{className:"mt-2 text-sm font-medium text-gray-800 dark:text-gray-200 truncate",children:v.vod_name}) +]},key)})}) +]})};''' + +# ---- 1) page chunk:组件定义 + 使用点 ---- +pc = read(PC) +if "__HKDrama__" not in pc: + anchor = 'a.d(t,{default:function(){return j}});' + assert pc.count(anchor)==1, "def anchor" + pc = pc.replace(anchor, anchor + COMPONENT, 1) + use = '(0,s.jsx)(p,{}),' + assert pc.count(use)==1, "use anchor" + pc = pc.replace(use, use + '(0,s.jsx)(__HKDrama__,{}),', 1) + check(pc, "page chunk") + write(PC, pc) + print("HKDrama injected") +else: + print("HKDrama exists") + +# ---- 2) nav chunk:去掉直播菜单项 ---- +nc = read(NC) +MENU = ',{icon:o.Z,label:"直播",href:"/live"}' +if '"直播"' in nc: + assert MENU in nc, "menu anchor" + nc = nc.replace(MENU, "") + check(nc, "nav chunk") + write(NC, nc) + print("menu item removed") +else: + print("menu clean") + +print("DONE - restart to apply")