Neon-AI commited on
Commit
9f95ccf
·
verified ·
1 Parent(s): 62325dd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -38
app.py CHANGED
@@ -1,40 +1,11 @@
1
- from fastapi import FastAPI
2
- from playwright.sync_api import sync_playwright
3
 
4
- app = FastAPI()
 
5
 
6
- @app.get("/chat")
7
- async def chat(query: str):
8
- with sync_playwright() as p:
9
- # Launch the Chromium browser
10
- browser = p.chromium.launch(headless=True) # Set to False to see the browser
11
- page = browser.new_page()
12
-
13
- # Navigate to ChatGPT page
14
- page.goto("https://chatgpt.com")
15
-
16
- # Wait for the chat input area to load
17
- page.wait_for_selector('textarea[placeholder="Type a message…"]')
18
-
19
- # Type a message into the chat input
20
- page.fill('textarea[placeholder="Type a message…"]', query)
21
-
22
- # Press Enter to send the message
23
- page.press('textarea[placeholder="Type a message…"]', 'Enter')
24
-
25
- # Wait for the response (adjust the wait time as necessary)
26
- page.wait_for_selector('div[class*="message-response-class"]') # Adjust the class name
27
-
28
- # Extract the response text
29
- response = page.query_selector('div[class*="message-response-class"]') # Adjust the class name
30
- message = response.inner_text() if response else "No response found."
31
-
32
- # Close the browser
33
- browser.close()
34
-
35
- return {"response": message}
36
-
37
- if __name__ == "__main__":
38
- import uvicorn
39
- port = int(os.environ.get("PORT", 7860)) # HF Spaces sets this automatically
40
- uvicorn.run(app, host="0.0.0.0", port=port)
 
1
+ import subprocess
 
2
 
3
+ url = "https://hlsx3cdn.echovideo.to/naruto/1/master.m3u8"
4
+ output = "/tmp/video.mp4" # HF Spaces usually allow writing in /tmp
5
 
6
+ subprocess.run([
7
+ "ffmpeg",
8
+ "-i", url,
9
+ "-c", "copy",
10
+ output
11
+ ])