Skip to content

Instantly share code, notes, and snippets.

@napcae
Last active October 24, 2022 16:35
Show Gist options
  • Save napcae/bb74c2dab54b8e15babc3952e7ffbd07 to your computer and use it in GitHub Desktop.
Save napcae/bb74c2dab54b8e15babc3952e7ffbd07 to your computer and use it in GitHub Desktop.
Download Media from Snapchat Backup
# give your files a creation date so Photos on macOS sorts them correctly
find -f $FILE | xargs -I {} exiftool -CreateDate={} -MediaCreateDate={} {}
#!/bin/bash
###
# Snapchat exporter
#
# You to download your memories from Snapchat with this neat little importer.
# All you need to do is go to https://accounts.snapchat.com/accounts/downloadmydata and request your data
# You will receive an email with your zipped data, copy inside json/memories_history.json to this dir
MEMORIES_FILE="./memories_history.json"
API_ENDPOINT="https://app.snapchat.com/dmd/memories"
NumberOfMemories=$(jq '.[] | length' "$MEMORIES_FILE")
for (( c=0; c<"$NumberOfMemories"; c++))
do
echo $c
# get date for sorting downloaded files
DATE=$(jq -r '.[] | .['"$c"'].Date' "$MEMORIES_FILE" | sed 's/ /_/g')
# get full download url from memories file
POST_DATA=$(jq '.[] | .['"$c"']."Download Link"' "$MEMORIES_FILE" | gsed 's/.*?//' | gsed 's/"//' )
# create download link out of post data
DOWNLOAD_LINK=$(curl -s -d "$POST_DATA" "$API_ENDPOINT")
FILENAME=$(echo $DOWNLOAD_LINK | grep -Eo "(\w+-\w+-\w+-\w+-\w+)\.(\w{3})")
echo "DOWNLOADING: "
echo $DOWNLOAD_LINK
echo "TO: "
echo "$DATE"-"$FILENAME"
#curl -s "$DOWNLOAD_LINK" > data/"$DATE"-"$FILENAME"
wget -nc -O data/"$DATE"-"$FILENAME" "$DOWNLOAD_LINK"
done
#➤ find -f * | xargs -I {} exiftool -CreateDate={} {}
@aldogg94
Copy link

Okay but like I have literally no idea what I am doing? Could you decide this for me and show me what it is before I go insane???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment