blob: d8192e0f6fd9d5267c253b10f052a7cc20dd5dd3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
{ stdenv, coreutils, ffmpeg-full, writeScriptBin }:
writeScriptBin "recv-media" ''
#!${stdenv.shell}
[[ -z "$1" ]] && exit 2
PATH=${ffmpeg-full}/bin:${coreutils}/bin
dir=/var/media
file="''${dir}/.$(basename "$1")"
file2="''${dir}/.copy.$(basename "$1")"
nFile="''${dir}/$(basename "$1")"
cat > "''${file}"
if ! ffmpeg -v warning -i "''${file}" -c copy "''${file2}" 2>&1 </dev/null; then
echo "Download of ''${file} failed"
rm -f "''${nFile}" "''${file}" "''${file2}"
exit 1
else
rm -f "''${file}"
mv "''${file2}" "''${nFile}"
fi
''
|