forked from hermanho/MMM-GooglePhotos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_uploadable_album.js
40 lines (37 loc) · 991 Bytes
/
create_uploadable_album.js
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"use strict";
const GP = require("./GPhotos.js");
const authOption = require("./google_auth.json");
let GPhotos = new GP({
authOption: authOption,
debug: true,
});
let args = process.argv.slice(2)[0];
if (!args) {
console.log("Give an album name. (e.g:> node create_uploadable_album.js MagicMirrorAlbum )");
process.exit();
}
const steps = async () => {
try {
let albums = await GPhotos.getAlbums();
let matched = albums.find((a) => {
if (a.title === args) return true;
return false;
});
if (matched) {
console.log(`Album "${args}" is already existing.`);
//console.log(matched)
} else {
console.log(`Album "${args}" will be created.`);
let r = await GPhotos.createAlbum(args);
//console.log(r)
let s = await GPhotos.shareAlbum(r.id);
//console.log(s)
console.log(`Album "${args}" is created.`);
}
process.exit();
} catch (err) {
console.log(err);
process.exit();
}
};
steps();