From 694b2daec50ff2aa428c32aa57fde376f470f827 Mon Sep 17 00:00:00 2001 From: Dermot Duffy Date: Fri, 10 Jun 2022 17:11:54 -0700 Subject: [PATCH] Fix downloads from the timeline. --- src/card.ts | 14 ++++++++++++-- src/types.ts | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/card.ts b/src/card.ts index 2aca0e41..2e919b03 100644 --- a/src/card.ts +++ b/src/card.ts @@ -61,6 +61,8 @@ import { FrigateCardView, FRIGATE_CARD_VIEWS_USER_SPECIFIED, MediaShowInfo, + MEDIA_TYPE_IMAGE, + MEDIA_TYPE_VIDEO, MenuButton, Message, RawFrigateCardConfig @@ -1127,7 +1129,11 @@ export class FrigateCard extends LitElement { return; } - if (!this._view.media) { + if ( + !this._view.media || + (this._view.media.media_content_type !== MEDIA_TYPE_VIDEO && + this._view.media.media_content_type !== MEDIA_TYPE_IMAGE) + ) { this._setMessageAndUpdate({ message: localize('error.download_no_media'), type: 'error', @@ -1151,7 +1157,11 @@ export class FrigateCard extends LitElement { const path = `/api/frigate/${cameraConfig.frigate.client_id}` + `/notifications/${event_id}/` + - `${this._view.isClipRelatedView() ? 'clip.mp4' : 'snapshot.jpg'}` + + `${ + this._view.media.media_content_type === MEDIA_TYPE_VIDEO + ? 'clip.mp4' + : 'snapshot.jpg' + }` + `?download=true`; let response: string | null | undefined; try { diff --git a/src/types.ts b/src/types.ts index cf0ea7a5..6aab3318 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1233,6 +1233,7 @@ export interface CardHelpers { export const MEDIA_CLASS_PLAYLIST = 'playlist' as const; export const MEDIA_CLASS_VIDEO = 'video' as const; export const MEDIA_TYPE_PLAYLIST = 'playlist' as const; +export const MEDIA_TYPE_IMAGE = 'image' as const; export const MEDIA_TYPE_VIDEO = 'video' as const; // Recursive type, cannot use type interference: