-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathautomate.js
More file actions
26 lines (22 loc) · 784 Bytes
/
automate.js
File metadata and controls
26 lines (22 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const fs = require("fs");
const admin = require("firebase-admin");
const serviceAccount = require("./functions/util/key.json");
const file = fs.readFileSync("list.csv", "utf8");
const lines = file.split("\n");
const data = lines
.map((line) => line.split(","))
.filter((line) => line[1] === "pending");
const hashMap = new Map(data);
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
storageBucket: "gs://twitter-absurd-humor.appspot.com/",
});
(async () => {
const storage = admin.storage();
for (const [key, _] of hashMap) {
const video = storage.bucket().file(`videos/${key}`);
const buffer = await video.download();
fs.writeFileSync(`downloaded-videos/${key}`, buffer[0], "utf8");
console.log(`Downloaded ${key}`);
}
})();