/
playlist.ts
58 lines (54 loc) · 1.69 KB
/
playlist.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { Operation } from 'express-openapi';
import { RecordedModelInterface } from '../../../../Model/Api/RecordedModel';
import factory from '../../../../Model/ModelFactory';
import * as api from '../../../api';
export const get: Operation = async(req, res) => {
const recordeds = <RecordedModelInterface> factory.get('RecordedModel');
try {
const list = await recordeds.getM3u8(req.headers.host!, req.header('x-forwarded-proto') === 'https', req.params.id, req.query.encodedId);
api.responsePlayList(req, res, list);
} catch (err) {
if (err.message === RecordedModelInterface.NotFoundRecordedFileError) {
api.responseError(res, { code: 404, message: 'Recorded file is not Found' });
} else {
api.responseServerError(res, err.message);
}
}
};
get.apiDoc = {
summary: '録画済みファイルのプレイリストを取得',
tags: ['recorded'],
description: '録画済みファイルのプレイリストを取得する',
parameters: [
{
name: 'id',
in: 'path',
description: 'recorded id',
required: true,
type: 'integer',
},
{
name: 'encodedId',
in: 'query',
description: 'encoded id',
type: 'integer',
},
],
produces: [
'application/x-mpegURL',
],
responses: {
200: {
description: 'ok',
},
404: {
description: 'Not found',
},
default: {
description: '予期しないエラー',
schema: {
$ref: '#/definitions/Error',
},
},
},
};