Skip to content
This repository was archived by the owner on Mar 23, 2025. It is now read-only.

Commit 0b23e88

Browse files
committed
First version (Initial commit)
0 parents  commit 0b23e88

File tree

6 files changed

+261
-0
lines changed

6 files changed

+261
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.DS_Store
2+
3+
node_modules
4+
memories
5+
memories_history.json

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v17.1.0

README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Download Snapchat Memories
2+
3+
Have you ever wanted to stop using the social media platform, Snapchat, but you remember that you have hundreds or even thousands of photos and videos stored in your memories?
4+
5+
This simple JavaScript application allows you to say goodbye to the service by downloading all of your memories to your computer (in regular `jpg` and `mp4` formats).
6+
7+
### System requirements
8+
9+
1. [NodeJS](http://nodejs.org) (v17.1.0)
10+
2. [npm](http://npmjs.com)
11+
3. [nvm](http://nvm.sh/)
12+
13+
### Steps
14+
<!-- no toc -->
15+
1. [Download this program](#download-this-program)
16+
2. [Download your Snapchat data](#download-your-snapchat-data)
17+
3. [Copy your memory data into the program](#copy-your-memory-data-into-the-program)
18+
4. [Run the program](#run-the-program)
19+
5. Enjoy access to your memories!
20+
21+
## Download this program
22+
23+
In order to run the program, you must clone this repository onto your computer. [Learn more about cloning a repository](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository#cloning-a-repository).
24+
25+
Once the repository is cloned on your computer, navigate to the repository folder, `memory-download`.
26+
27+
Ensure that you are using the correct version of `node` with `nvm`:
28+
29+
```bash
30+
nvm use
31+
```
32+
33+
Install the required node modules using `npm`:
34+
35+
```bash
36+
npm i
37+
```
38+
39+
## Download your Snapchat data
40+
41+
Snapchat makes downloading your data very simple!
42+
43+
1. Sign into your Snapchat account at [accounts.snapchat.com](https://accounts.snapchat.com/)
44+
2. Click **My Data**
45+
3. Click **Submit Request** at the bottom of the page
46+
4. Wait for an email from Snapchat with a link to your data archive. (This may take as long as a day)
47+
5. Follow the link found in your email and follow the given instructions to download your data.
48+
49+
For additional help, view the official [Download My Data](https://support.snapchat.com/en-US/a/download-my-data) Snapchat support page.
50+
51+
## Copy your memory data into the program
52+
53+
Find the file `memories_history.json` from within the zip file downloaded from the last step. Copy or move this file to the `memory-download` folder.
54+
55+
## Run the program
56+
57+
58+
Start the program with `npm`:
59+
60+
```bash
61+
npm start
62+
```
63+
64+
Wait for the program to terminate. You will now find a copy of your memories in the folder `memory-download/memories/`.

app.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import fetch from 'node-fetch';
2+
import fs from 'fs';
3+
4+
const inputFile = './memories_history.json';
5+
const outputDirectory = './memories';
6+
7+
if (!fs.existsSync(inputFile))
8+
throw new Error(`JSON file "${inputFile}" not found`);
9+
10+
if (!fs.existsSync(outputDirectory))
11+
fs.mkdirSync(outputDirectory);
12+
13+
const data = JSON.parse(fs.readFileSync(inputFile));
14+
const memories = data["Saved Media"].reverse();
15+
16+
const getFileName = async (memory) => {
17+
const extension = memory['Media Type'] === 'PHOTO' ? 'jpg' : 'mp4';
18+
const filename = memory['Date'].substr(0, 10);
19+
20+
let i = 1;
21+
let confirmedFilename = filename;
22+
while (fs.existsSync(`${outputDirectory}/${confirmedFilename}.${extension}`)) {
23+
confirmedFilename = `${filename}(${i++})`;
24+
}
25+
26+
return `${outputDirectory}/${confirmedFilename}.${extension}`;
27+
};
28+
29+
console.log("Downloading your memories. This will probably take a while...");
30+
31+
for (const memory of memories) {
32+
await fetch((memory['Download Link']), {
33+
method: 'POST'
34+
})
35+
.then(async (res) => {
36+
const url = await res.text();
37+
38+
// download file from url
39+
const download = await fetch(url);
40+
const fileStream = fs.createWriteStream(await getFileName(memory));
41+
42+
await new Promise((resolve, reject) => {
43+
download.body.pipe(fileStream);
44+
download.body.on("error", reject);
45+
fileStream.on("finish", resolve);
46+
});
47+
});
48+
}
49+
50+
console.log(`Memories downloaded successfully!\nYour memories are stored in ${outputDirectory}`);

package-lock.json

Lines changed: 129 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "memory-download",
3+
"version": "1.0.0",
4+
"scripts": {
5+
"start": "node app.js"
6+
},
7+
"dependencies": {
8+
"fs": "^0.0.1-security",
9+
"node-fetch": "^3.1.0"
10+
},
11+
"type": "module"
12+
}

0 commit comments

Comments
 (0)