mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-04 23:09:34 +00:00
Fix video and audio streams can be undefined (#997)
This commit is contained in:
@@ -6,6 +6,11 @@ import humanFileSize from '../functions/humanFileSize';
|
|||||||
import { FileSizeUnits } from '../api/actions/updateUserConfig';
|
import { FileSizeUnits } from '../api/actions/updateUserConfig';
|
||||||
import { useUserConfigStore } from '../stores/UserConfigStore';
|
import { useUserConfigStore } from '../stores/UserConfigStore';
|
||||||
|
|
||||||
|
const StreamsTypeEmun = {
|
||||||
|
Video: 'video',
|
||||||
|
Audio: 'audio',
|
||||||
|
};
|
||||||
|
|
||||||
type VideoListItemProps = {
|
type VideoListItemProps = {
|
||||||
videoList: VideoType[] | undefined;
|
videoList: VideoType[] | undefined;
|
||||||
viewStyle: ViewStylesType;
|
viewStyle: ViewStylesType;
|
||||||
@@ -35,7 +40,8 @@ const VideoListItemTable = ({ videoList, viewStyle }: VideoListItemProps) => {
|
|||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
{videoList?.map(({ youtube_id, title, channel, vid_type, media_size, streams }) => {
|
{videoList?.map(({ youtube_id, title, channel, vid_type, media_size, streams }) => {
|
||||||
const [videoStream, audioStream] = streams;
|
const videoStream = streams?.find(s => s.type === StreamsTypeEmun.Video);
|
||||||
|
const audioStream = streams?.find(s => s.type === StreamsTypeEmun.Audio);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<tr key={youtube_id}>
|
<tr key={youtube_id}>
|
||||||
@@ -46,12 +52,12 @@ const VideoListItemTable = ({ videoList, viewStyle }: VideoListItemProps) => {
|
|||||||
<Link to={Routes.Video(youtube_id)}>{title}</Link>
|
<Link to={Routes.Video(youtube_id)}>{title}</Link>
|
||||||
</td>
|
</td>
|
||||||
<td>{vid_type}</td>
|
<td>{vid_type}</td>
|
||||||
<td>{`${videoStream.width}x${videoStream.height}`}</td>
|
<td>{`${videoStream?.width || '-'}x${videoStream?.height || '-'}`}</td>
|
||||||
<td>{humanFileSize(media_size, useSiUnits)}</td>
|
<td>{humanFileSize(media_size, useSiUnits)}</td>
|
||||||
<td>{videoStream.codec || 'unknown'}</td>
|
<td>{videoStream?.codec || '-'}</td>
|
||||||
<td>{humanFileSize(videoStream.bitrate, useSiUnits)}</td>
|
<td>{humanFileSize(videoStream?.bitrate || 0, useSiUnits)}</td>
|
||||||
<td>{audioStream.codec || 'unknown'}</td>
|
<td>{audioStream?.codec || '-'}</td>
|
||||||
<td>{humanFileSize(audioStream.bitrate, useSiUnits)}</td>
|
<td>{humanFileSize(audioStream?.bitrate || 0, useSiUnits)}</td>
|
||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ export type VideoType = {
|
|||||||
sponsorblock?: SponsorBlockType;
|
sponsorblock?: SponsorBlockType;
|
||||||
playlist: string[];
|
playlist: string[];
|
||||||
stats: StatsType;
|
stats: StatsType;
|
||||||
streams: StreamType[];
|
streams: StreamType[] | undefined;
|
||||||
subtitles: Subtitles[];
|
subtitles: Subtitles[];
|
||||||
tags: string[];
|
tags: string[];
|
||||||
title: string;
|
title: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user