first commit
This commit is contained in:
commit
f5f1c0928f
39 changed files with 4478 additions and 0 deletions
35
scripts/plex_fixture.py
Normal file
35
scripts/plex_fixture.py
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Local integration fixture, never used by the shipping launcher.
|
||||
Serve on loopback and use `adb reverse tcp:8765 tcp:8765` for TV integration QA.
|
||||
"""
|
||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||
from pathlib import Path
|
||||
import json
|
||||
|
||||
ART = Path(__file__).resolve().parents[1]/'app/src/main/assets/alpine.jpg'
|
||||
|
||||
class Fixture(BaseHTTPRequestHandler):
|
||||
def log_message(self, *args): pass
|
||||
def do_GET(self):
|
||||
if self.headers.get('X-Plex-Token') != 'luma-test-fixture':
|
||||
self.send_response(401); self.end_headers(); return
|
||||
if self.path.startswith('/photo/'):
|
||||
data=ART.read_bytes(); mime='image/jpeg'
|
||||
elif self.path.startswith('/hubs'):
|
||||
def item(key,title,progress=0):
|
||||
return dict(ratingKey=str(key), title=title, type='movie', year=2026,
|
||||
duration=600000, viewOffset=progress, art='/library/art/alpine',
|
||||
summary='Local integration test artwork. Not connected to a real Plex library.')
|
||||
data=json.dumps({'MediaContainer':{'Hub':[
|
||||
{'hubIdentifier':'home.continueWatching', 'title':'Continue Watching',
|
||||
'Metadata':[item(1,'Alpine at dusk',240000),item(2,'The quiet shore',80000)]},
|
||||
{'hubIdentifier':'movie.recentlyAdded', 'title':'Recently Added',
|
||||
'Metadata':[item(3,'Beyond the ridge'),item(4,'Blue hour')]}
|
||||
]}}).encode(); mime='application/json'
|
||||
else:
|
||||
data=json.dumps({'MediaContainer':{'machineIdentifier':'luma-local-fixture'}}).encode();mime='application/json'
|
||||
self.send_response(200);self.send_header('Content-Type',mime);self.send_header('Content-Length',str(len(data)));self.end_headers();self.wfile.write(data)
|
||||
|
||||
if __name__=='__main__':
|
||||
print('Plex test fixture on 127.0.0.1:8765',flush=True)
|
||||
HTTPServer(('127.0.0.1',8765),Fixture).serve_forever()
|
||||
Loading…
Add table
Add a link
Reference in a new issue