2024-08-20 20:01:07 +00:00
|
|
|
{ pkgs, username, ... }:
|
2024-08-20 18:30:13 +00:00
|
|
|
{
|
|
|
|
name = "export-video-list";
|
|
|
|
|
|
|
|
runtimeInputs = with pkgs; [
|
|
|
|
jq
|
|
|
|
tree
|
|
|
|
udisks
|
|
|
|
];
|
|
|
|
|
|
|
|
text = ''
|
|
|
|
device_name="/dev/sda2"
|
|
|
|
device_label="UNTITLED"
|
|
|
|
|
2024-08-20 20:01:07 +00:00
|
|
|
source_path="/run/media/${username}/$device_label"
|
2024-08-20 18:30:13 +00:00
|
|
|
|
|
|
|
# If the source path doesn't exist, try mounting the device.
|
|
|
|
if [[ ! -d "$source_path" ]]; then
|
|
|
|
${pkgs.udisks}/bin/udisksctl mount -b "$device_name"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Exit early if the source path still doesn't exist.
|
|
|
|
if [[ ! -d "$source_path" ]]; then
|
|
|
|
echo "Error: $source_path not found."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-12-16 17:58:54 +00:00
|
|
|
output_file="''${DOCUMENTS}/videos.json"
|
2024-08-20 18:30:13 +00:00
|
|
|
|
2024-08-20 20:51:15 +00:00
|
|
|
${pkgs.tree}/bin/tree -J "$source_path/Videos" | ${pkgs.jq}/bin/jq . > "$output_file"
|
2024-08-20 18:30:13 +00:00
|
|
|
${pkgs.jq}/bin/jq . < "$output_file"
|
|
|
|
'';
|
|
|
|
}
|