https://github.com/instaloader/instaloader
https://instaloader.github.io/installation.html
$ pip3 install instaloader
$ doas pkg_add python py3-pip
$ python3.xx /usr/local/bin/pip3.xx install instaloader
$ pip3 install --upgrade instaloader
$ python3.xx /usr/local/bin/pip3.xx install --upgrade instaloader
$ instaloader --no-video-thumbnails --no-compress-json --sanitize-paths --filename-pattern={profile}_{date_utc}_UTC --dirname-pattern={profile} --comments --quiet -- -[POST_ID]
$ instaloader PROFILE_NAME [PROFILE_NAME...] --filename-pattern={profile}_{date_utc}_UTC --post-metadata-txt={caption} --storyitem-metadata-txt={caption} --comments --no-video-thumbnails --no-compress-json --sanitize-paths --no-iphone --quiet
$ instaloader --fast-update PROFILE_NAME [PROFILE_NAME...] --filename-pattern={profile}_{date_utc}_UTC --post-metadata-txt={caption} --storyitem-metadata-txt={caption} --comments --no-video-thumbnails --no-compress-json --sanitize-paths --no-iphone --quiet
or
$ instaloader --latest-stamps PROFILE_NAME [PROFILE_NAME...] --filename-pattern={profile}_{date_utc}_UTC --post-metadata-txt={caption} --storyitem-metadata-txt={caption} --comments --no-video-thumbnails --no-compress-json --sanitize-paths --no-iphone --quiet
$ for FILE in *.mp4; do basename_file="$(basename $FILE .mp4)" && json_file="$(echo ${basename_file} | sed 's/UTC_[0-9]*$/UTC/').json" && username=$(cat $json_file | jq ".node.owner.username" | tr -d '"') && mv $FILE ${username}-$FILE; done
$ for FILE in *.jpg; do basename_file="$(basename $FILE .jpg)" && json_file="$(echo ${basename_file} | sed 's/UTC_[0-9]*$/UTC/').json" && username=$(cat $json_file | jq ".node.owner.username" | tr -d '"') && mv $FILE ${username}-$FILE; done
$ for FILE in *.txt; do basename_file="$(basename $FILE .txt)" && json_file="$(echo ${basename_file} | sed 's/UTC_[0-9]*$/UTC/').json" && username=$(cat $json_file | jq ".node.owner.username" | tr -d '"') && mv $FILE ${username}-$FILE; done
$ for FILE in *.json; do basename_file="$(basename $FILE .json)" && json_file="$(echo ${basename_file} | sed 's/UTC_[0-9]*$/UTC/').json" && username=$(cat $json_file | jq ".node.owner.username" | tr -d '"') && mv $FILE ${username}-$FILE; done
$ for FILE in *.xz; do xz -d $FILE; done