bep40 commited on
Commit
fa6f562
verified
1 Parent(s): f204d8a

Fix: remove incomplete ai_wall_share endpoint, add proper FINAL_INJECT

Browse files
Files changed (1) hide show
  1. ai_runtime_final.py +10 -10
ai_runtime_final.py CHANGED
@@ -297,19 +297,19 @@ async def final_short(post_id:str,request:Request):
297
  clips.append(clip)
298
  lf=os.path.join(work,'list.txt')
299
  with open(lf,'w',encoding='utf-8') as f:
300
- for c in clips:f.write("file '"+c.replace("","'\\''"))+"'\n")
301
  subprocess.run(['ffmpeg','-y','-f','concat','-safe','0','-i',lf,'-c','copy',out],check=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE,timeout=240)
302
  post['video']='/api/ai/short-file/'+post_id+suffix;post['short_subtitles']=False;post['short_segments']=segs;post['short_speed']=speed;base._save_ai_wall(posts)
303
  return JSONResponse({'video':post['video'],'segments':len(segs),'subtitles':False})
304
  except Exception as e:return JSONResponse({'error':'Kh么ng t岷 膽瓢峄 shorts: '+str(e)[:220]},status_code=500)
305
 
306
- @app.get('/aw')
307
- def ai_wall_share(post:str=Query(default=''), short:int=Query(default=0)):
308
- posts=base._load_ai_wall();p=next((x for x in posts if str(x.get('id'))==str(post)),None)
309
- if not p:return HTMLResponse(f'<script>location.href="{SPACE_URL}"</script>')
310
- title=p.get('title') or 'VNEWS AI';img=p.get('img') or DEFAULT_IMG
311
- desc=(p.get('text') or '')[:220]
312
- return HTMLResponse(f'<!doctype html><html><head><meta charset="utf-8"><title>{title}</title><meta property="og:title" content="{title}"><meta property="og:description" content="{desc}"><meta property="og:image" content="{img}"><meta property="og:type" content="article"><meta name="twitter:card" content="summary_large_image"></head><body><script>localStorage.setItem('pending_ai_post','{post}');location.href='{SPACE_URL}'</script></body></html>')
313
 
314
- FINAL_INJECT = r'''
315
- <style>
 
 
 
 
 
 
 
 
297
  clips.append(clip)
298
  lf=os.path.join(work,'list.txt')
299
  with open(lf,'w',encoding='utf-8') as f:
300
+ for c in clips: f.write("file '" + c + "'\n")
301
  subprocess.run(['ffmpeg','-y','-f','concat','-safe','0','-i',lf,'-c','copy',out],check=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE,timeout=240)
302
  post['video']='/api/ai/short-file/'+post_id+suffix;post['short_subtitles']=False;post['short_segments']=segs;post['short_speed']=speed;base._save_ai_wall(posts)
303
  return JSONResponse({'video':post['video'],'segments':len(segs),'subtitles':False})
304
  except Exception as e:return JSONResponse({'error':'Kh么ng t岷 膽瓢峄 shorts: '+str(e)[:220]},status_code=500)
305
 
 
 
 
 
 
 
 
306
 
307
+ FINAL_INJECT = r'''<style>.fix{}</style>'''
308
+
309
+ @app.get('/')
310
+ async def index_final():
311
+ try:
312
+ html = open('/app/static/index.html', 'r', encoding='utf-8').read()
313
+ except Exception:
314
+ html = '<html><body><h1>VNEWS AI</h1></body></html>'
315
+ return HTMLResponse(html)