import EightK from '@mui/icons-material/EightK' import FourK from '@mui/icons-material/FourK' import Hd from '@mui/icons-material/Hd' import Sd from '@mui/icons-material/Sd' import { Button, Card, CardActionArea, CardActions, CardContent, CardMedia, Chip, LinearProgress, Skeleton, Stack, Typography } from '@mui/material' import { useCallback } from 'react' import { RPCResult } from '../types' import { ellipsis, formatSpeedMiB, mapProcessStatus, roundMiB } from '../utils' type Props = { download: RPCResult onStop: () => void onCopy: () => void } const Resolution: React.FC<{ resolution?: string }> = ({ resolution }) => { if (!resolution) return null if (resolution.includes('4320')) return if (resolution.includes('2160')) return if (resolution.includes('1080')) return if (resolution.includes('720')) return return null } const DownloadCard: React.FC = ({ download, onStop, onCopy }) => { const isCompleted = useCallback( () => download.progress.percentage === '-1', [download.progress.percentage] ) const percentageToNumber = useCallback( () => isCompleted() ? 100 : Number(download.progress.percentage.replace('%', '')), [download.progress.percentage, isCompleted] ) return ( { navigator.clipboard.writeText(download.info.url) onCopy() }}> {download.info.thumbnail !== '' ? : } {download.info.title !== '' ? {ellipsis(download.info.title, 54)} : } {!isCompleted() ? download.progress.percentage : ''}   {!isCompleted() ? formatSpeedMiB(download.progress.speed) : ''} {roundMiB(download.info.filesize_approx ?? 0)} {download.progress.percentage ? : null } ) } export default DownloadCard