Copy ffprobe in output

This commit is contained in:
Nick Mowen 2022-11-09 14:47:03 -07:00
parent 3077ff07fc
commit 1ccc9bd6b7
2 changed files with 18 additions and 7 deletions

View File

@ -630,7 +630,7 @@ def ffprobe(camera_name):
else: else:
output += "error getting stream\n" output += "error getting stream\n"
return output return jsonify(output, "200")
else: else:
# user has single stream # user has single stream
ffprobe = ffprobe_stream(config.ffmpeg.inputs[0].path) ffprobe = ffprobe_stream(config.ffmpeg.inputs[0].path)
@ -643,9 +643,7 @@ def ffprobe(camera_name):
"500", "500",
) )
else: else:
return jsonify( return jsonify(ffprobe, "200")
{"success": True, "message": ffprobe}, "200"
)
@bp.route("/<camera_name>") @bp.route("/<camera_name>")

View File

@ -5,6 +5,7 @@ import Heading from '../components/Heading';
import Link from '../components/Link'; import Link from '../components/Link';
import { useMqtt } from '../api/mqtt'; import { useMqtt } from '../api/mqtt';
import useSWR from 'swr'; import useSWR from 'swr';
import axios from 'axios';
import { Table, Tbody, Thead, Tr, Th, Td } from '../components/Table'; import { Table, Tbody, Thead, Tr, Th, Td } from '../components/Table';
import { useCallback } from 'preact/hooks'; import { useCallback } from 'preact/hooks';
@ -32,6 +33,18 @@ export default function Debug() {
copy(); copy();
}, [config]); }, [config]);
const onCopyFfprobe = async (camera, e) => {
if (e) {
e.stopPropagation();
}
const response = await axios.get(`${camera}/ffprobe`);
if (response.status === 200) {
await window.navigator.clipboard.writeText(JSON.stringify(response.data, null, 2));
}
};
return ( return (
<div className="space-y-4 p-2 px-4"> <div className="space-y-4 p-2 px-4">
<Heading> <Heading>
@ -76,9 +89,9 @@ export default function Debug() {
<div className='dark:bg-gray-800 shadow-md hover:shadow-lg rounded-lg transition-shadow p-4 m-2'> <div className='dark:bg-gray-800 shadow-md hover:shadow-lg rounded-lg transition-shadow p-4 m-2'>
<div className='text-lg flex justify-between'> <div className='text-lg flex justify-between'>
<Link href={`/cameras/${camera}`}>{camera.replaceAll('_', ' ')}</Link> <Link href={`/cameras/${camera}`}>{camera.replaceAll('_', ' ')}</Link>
<div className='text-sm'> <Button onClick={(e) => onCopyFfprobe(camera, e)}>
ffprobe copy ffprobe
</div> </Button>
</div> </div>
<div className='p-4'> <div className='p-4'>
<Table className='w-full'> <Table className='w-full'>