diff options
Diffstat (limited to 'hel')
-rw-r--r-- | hel/recv-media.nix | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/hel/recv-media.nix b/hel/recv-media.nix new file mode 100644 index 00000000..f85598f4 --- /dev/null +++ b/hel/recv-media.nix | |||
@@ -0,0 +1,22 @@ | |||
1 | { stdenv, coreutils, ffmpeg-full writeScriptBin }: | ||
2 | |||
3 | writeScriptBin "recv-media" '' | ||
4 | #!${stdenv.shell} | ||
5 | |||
6 | PATH=${ffmpeg-full}/bin:${coreutils}/bin | ||
7 | |||
8 | dir=/var/media | ||
9 | |||
10 | file="''${dir}/.$(basename "$1")" | ||
11 | file2="''${dir}/.copy.$(basename "$1")" | ||
12 | nFile="''${dir}/$(basename "$1")" | ||
13 | cat > "''${file}" | ||
14 | if ! ffmpeg -v warning -i "''${file}" -c copy "''${file2}" 2>&1 </dev/null; then | ||
15 | echo "Download of ''${file} failed" | ||
16 | rm -f "''${nFile}" "''${file}" "''${file2}" | ||
17 | exit 1 | ||
18 | else | ||
19 | rm -f "''${file}" | ||
20 | mv "''${file2}" "''${nFile}" | ||
21 | fi | ||
22 | ''; | ||