feat: implement cnl-bridge service for handling crawljob requests in JDownloader
This commit is contained in:
parent
054d7470cf
commit
2bccbc14ef
@ -23,7 +23,6 @@ spec:
|
||||
image: jlesage/jdownloader-2:latest
|
||||
ports:
|
||||
- containerPort: 5800
|
||||
- containerPort: 9666
|
||||
env:
|
||||
- name: USER_ID
|
||||
value: "1000"
|
||||
@ -36,6 +35,40 @@ spec:
|
||||
mountPath: /config
|
||||
- name: dl
|
||||
mountPath: /output
|
||||
- name: cnl-bridge
|
||||
image: python:3.12-alpine
|
||||
ports:
|
||||
- containerPort: 9666
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /config
|
||||
command:
|
||||
- python3
|
||||
- -c
|
||||
- |
|
||||
import http.server, urllib.parse, os, time
|
||||
|
||||
WATCH_DIR = '/config/folderwatch'
|
||||
os.makedirs(WATCH_DIR, exist_ok=True)
|
||||
|
||||
class Handler(http.server.BaseHTTPRequestHandler):
|
||||
def do_POST(self):
|
||||
if self.path != '/add':
|
||||
self.send_response(404); self.end_headers(); return
|
||||
length = int(self.headers.get('Content-Length', 0))
|
||||
body = self.rfile.read(length).decode()
|
||||
params = urllib.parse.parse_qs(body)
|
||||
urls = params.get('urls', [])
|
||||
if not urls:
|
||||
self.send_response(400); self.end_headers(); return
|
||||
fname = f'{WATCH_DIR}/{int(time.time()*1000)}.crawljob'
|
||||
with open(fname, 'w') as f:
|
||||
f.write(f'url={urls[0]}\nautoStart=TRUE\npackageName=subyshare\n')
|
||||
self.send_response(200); self.end_headers()
|
||||
self.wfile.write(b'Ok.')
|
||||
def log_message(self, *a): pass
|
||||
|
||||
http.server.HTTPServer(('0.0.0.0', 9666), Handler).serve_forever()
|
||||
volumes:
|
||||
- name: config
|
||||
hostPath:
|
||||
@ -58,7 +91,7 @@ spec:
|
||||
- name: web
|
||||
port: 80
|
||||
targetPort: 5800
|
||||
- name: clicknload
|
||||
- name: cnl-bridge
|
||||
port: 9666
|
||||
targetPort: 9666
|
||||
---
|
||||
@ -111,7 +144,7 @@ spec:
|
||||
entryPoints:
|
||||
- websecure
|
||||
routes:
|
||||
- match: Host(`jdownloader.home.arpa`) && PathPrefix(`/flash`)
|
||||
- match: Host(`jdownloader.home.arpa`) && PathPrefix(`/add`)
|
||||
kind: Rule
|
||||
services:
|
||||
- name: jdownloader
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user