Mercurial > code > home > repos > video
comparison video.py @ 49:1bd17c2e5517 default tip
video.py must sign video urls for serve-files.js to serve them
author | drewp@bigasterisk.com |
---|---|
date | Fri, 06 Dec 2024 17:13:51 -0800 |
parents | 882d0bb0f801 |
children |
comparison
equal
deleted
inserted
replaced
48:046673b1cc24 | 49:1bd17c2e5517 |
---|---|
13 from starlette.responses import HTMLResponse, JSONResponse, Response | 13 from starlette.responses import HTMLResponse, JSONResponse, Response |
14 from starlette.routing import Route | 14 from starlette.routing import Route |
15 from starlette_exporter import PrometheusMiddleware, handle_metrics | 15 from starlette_exporter import PrometheusMiddleware, handle_metrics |
16 | 16 |
17 import dl_queue | 17 import dl_queue |
18 from signature_gen import makePlaybackSig | |
18 import thumbnail | 19 import thumbnail |
19 from mongo_required import open_mongo_or_die | 20 from mongo_required import open_mongo_or_die |
20 from video_file_store import VideoFileStore | 21 from video_file_store import VideoFileStore |
21 from video_ingest import VideoIngest | 22 from video_ingest import VideoIngest |
22 | 23 |
31 | 32 |
32 | 33 |
33 async def videos(req: Request) -> JSONResponse: | 34 async def videos(req: Request) -> JSONResponse: |
34 # either like /dir1/dir2/ or /dir1/dir2/vid1 | 35 # either like /dir1/dir2/ or /dir1/dir2/vid1 |
35 subdir = req.query_params.get('subdir', '/') | 36 subdir = req.query_params.get('subdir', '/') |
37 user = req.headers.get('x-pomerium-email', '') | |
38 if not user: | |
39 raise ValueError('must be logged in') | |
40 log.info(f'videos for {user!r}') | |
36 | 41 |
37 subdir = unquote(subdir) | 42 subdir = unquote(subdir) |
38 webDirRelPath = subdir.rsplit('/', 1)[0] + '/' | 43 webDirRelPath = subdir.rsplit('/', 1)[0] + '/' |
39 autoplayRelPath = subdir if not subdir.endswith('/') else None | 44 autoplayRelPath = subdir if not subdir.endswith('/') else None |
40 | 45 |
61 for vf in vfInDir: | 66 for vf in vfInDir: |
62 if '/' + vf.webRelPath == autoplayRelPath: | 67 if '/' + vf.webRelPath == autoplayRelPath: |
63 resp['autoplay'] = { | 68 resp['autoplay'] = { |
64 'webRelPath': '/' + vf.webRelPath, | 69 'webRelPath': '/' + vf.webRelPath, |
65 'webDataPath': '/' + vf.webDataPath, | 70 'webDataPath': '/' + vf.webDataPath, |
66 'label': vf.label | 71 'label': vf.label, |
72 'sig': makePlaybackSig(user, '/' + vf.webDataPath), | |
67 } | 73 } |
68 break | 74 break |
69 else: | 75 else: |
70 raise ValueError(f'{autoplayRelPath=} not in dir') | 76 raise ValueError(f'{autoplayRelPath=} not in dir') |
71 | 77 |