fix: Download recordings with a video file extension (#2712)
- Closes: #2711
This commit is contained in:
@@ -128,7 +128,7 @@ export class ViewItemManager {
|
|||||||
(cameraID ? toFilename(cameraID) : 'media') +
|
(cameraID ? toFilename(cameraID) : 'media') +
|
||||||
(id ? `_${toFilename(id)}` : '') +
|
(id ? `_${toFilename(id)}` : '') +
|
||||||
(startTime ? `_${format(startTime, `yyyy-MM-dd-HH-mm-ss`)}` : '') +
|
(startTime ? `_${format(startTime, `yyyy-MM-dd-HH-mm-ss`)}` : '') +
|
||||||
('.' + (item.getMediaType() === 'clip' ? 'mp4' : 'jpg'))
|
('.' + (ViewItemClassifier.isVideo(item) ? 'mp4' : 'jpg'))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -238,6 +238,22 @@ describe('ViewItemManager', () => {
|
|||||||
expect(downloadURL).toHaveBeenCalledWith('foo', 'camera_id.jpg');
|
expect(downloadURL).toHaveBeenCalledWith('foo', 'camera_id.jpg');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should generate filename for recording', async () => {
|
||||||
|
const api = createCardAPI();
|
||||||
|
vi.mocked(api.getHASSManager().getHASS).mockReturnValue(createHASS());
|
||||||
|
|
||||||
|
const manager = new ViewItemManager(api);
|
||||||
|
const item = new TestViewMedia({ mediaType: ViewMediaType.Recording });
|
||||||
|
|
||||||
|
vi.mocked(api.getCameraManager().getMediaDownloadPath).mockResolvedValue({
|
||||||
|
sign: false,
|
||||||
|
endpoint: 'foo',
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(await manager.download(item)).toBe(true);
|
||||||
|
expect(downloadURL).toHaveBeenCalledWith('foo', 'camera_id.mp4');
|
||||||
|
});
|
||||||
|
|
||||||
it('should generate filename for folder without title', async () => {
|
it('should generate filename for folder without title', async () => {
|
||||||
const api = createCardAPI();
|
const api = createCardAPI();
|
||||||
vi.mocked(api.getHASSManager().getHASS).mockReturnValue(createHASS());
|
vi.mocked(api.getHASSManager().getHASS).mockReturnValue(createHASS());
|
||||||
|
|||||||
Reference in New Issue
Block a user