mirror of
https://github.com/chickenflyshigh/meta-exif.git
synced 2026-02-20 10:28:19 +11:00
Initial commit
This commit is contained in:
commit
0b5791cae8
41
edit_exif_move_media
Executable file
41
edit_exif_move_media
Executable file
@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
# example usage: edit_exif_move_media -O /home/James/Penguin/@media/Social\ Media/exif_media/ -f /home/James/Penguin/@media/Social\ Media/metadata.txt
|
||||
IFS=$'\n'
|
||||
# set -eo pipefail
|
||||
usage() { echo "Usage: $0 [-a <audio output directory>] [-v <audio output directory>] [-p <photo output directory>] [-f <input file>]" 1>&2; exit 1; }
|
||||
|
||||
while getopts ":a:v:p:f:" o; do
|
||||
case "${o}" in
|
||||
a) a="${OPTARG}" ;; # audio output folder
|
||||
v) v="${OPTARG}" ;; # video output folder
|
||||
p) p="${OPTARG}" ;; # photo output folder
|
||||
f) f="${OPTARG}" ;; # metadata.txt file location
|
||||
*) usage;;
|
||||
esac
|
||||
done
|
||||
# while IFS=';' read -r ts media msg_dir filepath media_ts people; do
|
||||
# exifunix -d "$people" -n "$filepath" -t "$media_ts" -O "$O"
|
||||
# echo "exifunix -d $people -n $filepath -t $media_ts -O $O"
|
||||
# done < "$f"
|
||||
|
||||
process_line() {
|
||||
record="$1"
|
||||
audio_output="$2"
|
||||
video_output="$3"
|
||||
photo_output="$4"
|
||||
IFS=';' read ts media msg_dir filepath media_ts people <<< "$record"
|
||||
if [[ $media == "audio" ]]; then
|
||||
echo "Executing: exifunix -d \"$people\" -n \"$filepath\" -t \"$media_ts\" -O \"$audio_output\""
|
||||
exifunix -d "$people" -n "$filepath" -t "$media_ts" -O "$audio_output"
|
||||
elif [[ $media == "video" ]]; then
|
||||
echo "Executing: exifunix -d \"$people\" -n \"$filepath\" -t \"$media_ts\" -O \"$video_output\""
|
||||
exifunix -d "$people" -n "$filepath" -t "$media_ts" -O "$video_output"
|
||||
elif [[ $media == "photo" ]]; then
|
||||
echo "Executing: exifunix -d \"$people\" -n \"$filepath\" -t \"$media_ts\" -O \"$photo_output\""
|
||||
exifunix -d "$people" -n "$filepath" -t "$media_ts" -O "$photo_output"
|
||||
fi
|
||||
}
|
||||
|
||||
export -f process_line
|
||||
|
||||
cat "$f" | parallel -P 12 -n 1 -d '\n' "process_line {} \"$a\" \"$v\" \"$p\" 2>/dev/null"
|
||||
35
exifunix
Executable file
35
exifunix
Executable file
@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
usage() { echo "Usage: $0 [-n <filename>] [-t <unix timestamp in seconds>] [-d <description>] [-O <output directory>]" 1>&2; exit 1; }
|
||||
|
||||
while getopts ":n:t:O:d:" o; do
|
||||
case "${o}" in
|
||||
n)
|
||||
n="${OPTARG}"
|
||||
[ -f "${n}" ] || ( echo "Bad filename $n" && usage )
|
||||
;;
|
||||
t)
|
||||
t=${OPTARG}
|
||||
[[ ${t} =~ ^[0-9]+$ ]] || ( echo "Bad time $t" && usage )
|
||||
;;
|
||||
O)
|
||||
O="${OPTARG}"
|
||||
;;
|
||||
d) d="${OPTARG}"
|
||||
;;
|
||||
*) usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
formatted_date=$(date -d @${t} '+%Y:%m:%d %H:%M:%S')
|
||||
|
||||
exiftool -Artist="Messenger" -Description="$d" -CreateDate="$formatted_date" -DateTimeOriginal="$formatted_date" "$n" -o "$O"
|
||||
|
||||
|
||||
|
||||
61
meta-exif-media
Executable file
61
meta-exif-media
Executable file
@ -0,0 +1,61 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
usage() { echo "Usage: $0 [-d <input directory containing your_facebook_activity etc>] [-O <output directory >]" 1>&2; exit 1; }
|
||||
|
||||
while getopts ":O:d:" o; do
|
||||
case "${o}" in
|
||||
O)
|
||||
O="${OPTARG}"
|
||||
( [ -d "${O}" ] && echo "No output directory specified, outputting in the directory specified by -d flag.") || (echo "Not a directory ${d}" && usage )
|
||||
;;
|
||||
d) d="${OPTARG}"
|
||||
[ -d "${d}" ] || (echo "Not a directory ${d}" && usage)
|
||||
;;
|
||||
*) usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "$d" ]; then
|
||||
echo "Missing -d." >&2
|
||||
usage && exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$O" ]; then
|
||||
O="$d"
|
||||
fi
|
||||
|
||||
# cleaning pathnames
|
||||
O="${O%/}"
|
||||
d="${d%/}"
|
||||
! [ -f "$d/metadata.txt" ] || (echo "metadata.txt already exists in the input directory, exiting for now." && exit 1)
|
||||
|
||||
|
||||
if [ -d "${d}/your_instagram_activity" ] || [ -d "${d}/your_facebook_activity" ]; then
|
||||
m="$(find "${d}" -maxdepth 1 -name "your_*_activity" -exec basename '{}' ';' | cut -d '_' -f 2)"
|
||||
else
|
||||
echo "Please ensure the input directory specified by -d contains the \"your_{platform}_activity\" folder." && usage
|
||||
fi
|
||||
|
||||
echo "Wrapping aac files in mp4 containers. Placing it in the same directory as the original file."
|
||||
|
||||
fd '' -e 'aac' "$d" | parallel -n 1 -P $(nproc) 'filename={} && ffmpeg -i ${filename: -4}.aac -c:a copy ${filename: -4}.mp4'
|
||||
|
||||
echo "aac to mp4 conversion complete. Proceeding to create folders under $d/exif_media."
|
||||
mkdir -p "$O/exif_media/"{audio,photo,video}
|
||||
echo "Folders successfully created."
|
||||
echo "Extracting information and metadata from all media and outputting into \"${d}/metadata.txt\" file."
|
||||
for folder in inbox e2ee_cutover archived_threads filtered_threads;
|
||||
do
|
||||
if [ -d "${d}/your_${m}_activity/messages/$folder" ]; then
|
||||
echo "$(dirname "$0")/smmdo" "$m" "$folder" "${d}/metadata.txt"
|
||||
"$(dirname "$0")/smmdo" "$d" "$m" "$folder" "${d}/metadata.txt"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Adding metadata to media files and outputting the editted files in \"$O/exif_media\"."
|
||||
"$(dirname "$0")/edit_exif_move_media" -f "${d}/metadata.txt" -a "$O/exif_media/audio" -v "$O/exif_media/video" -p "$O/exif_media/photo"
|
||||
|
||||
echo "EXIF data successfully added and outputted in \"$O/exif_media\"."
|
||||
23
smmdo
Executable file
23
smmdo
Executable file
@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
# for producing a CSV file that clearly displays the locations of the media files from facebook messenger and respective timestamps of creation.
|
||||
# E.g. Usage smmdo "/home/James/Penguin/@media/Social Media/facebook-2024-10-11" facebook archived_threads "/tmp/test.txt"
|
||||
root_dir=$1 # right before the point of your_facebook_activity/...
|
||||
msg_dir=$3 # inbox, message_requests, e2ee_cutover
|
||||
dest_file=$4 # destination file in the csv format with ';' as delimiter which goes: date_data_added;format;msg_dir;timestamp;absolute_datapath;participants
|
||||
platform=$2 #facebook or instagram
|
||||
file_dir="$root_dir/your_${platform}_activity/messages/$msg_dir"
|
||||
|
||||
mapfile -t jsonfiles < <(fd \.json "$file_dir")
|
||||
|
||||
for jsonfile in "${jsonfiles[@]}"; do
|
||||
if [ -f "$jsonfile" ]; then
|
||||
timestamp=$(date '+%Y:%m:%d %H:%M:%S')
|
||||
people=$(jq '.participants[].name' "$jsonfile" | tr -d \" | paste -sd'/' )
|
||||
jq -r --arg timestamp "$timestamp" --arg msg_dir "$msg_dir" --arg root "$root_dir" --arg people "$people" '.messages[] | select(has("photos")) | "\($timestamp);photo;\($msg_dir);\($root)/\(.photos[].uri);\(.timestamp_ms | tostring | .[:-3]);\($people)"' "$jsonfile" >> "$dest_file"
|
||||
jq -r --arg timestamp "$timestamp" --arg msg_dir "$msg_dir" --arg root "$root_dir" --arg people "$people" '.messages[] | select(has("videos")) | "\($timestamp);video;\($msg_dir);\($root)/\(.videos[].uri);\(.timestamp_ms | tostring | .[:-3]);\($people)"' "$jsonfile" >> "$dest_file"
|
||||
jq -r --arg timestamp "$timestamp" --arg msg_dir "$msg_dir" --arg root "$root_dir" --arg people "$people" '.messages[] | select(has("audio_files")) | "\($timestamp);audio;\($msg_dir);\($root)/\(.audio_files[].uri);\(.timestamp_ms | tostring | .[:-3]);\($people)"' "$jsonfile" >> "$dest_file"
|
||||
fi
|
||||
done
|
||||
|
||||
sed -i 's/\.aac/\.mp4/g' "$dest_file"
|
||||
Loading…
Reference in New Issue
Block a user