forked from hyunchel/alfred-melon-youtube
-
Notifications
You must be signed in to change notification settings - Fork 0
/
actions.js
36 lines (33 loc) · 979 Bytes
/
actions.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
const alfy = require('alfy');
const { refreshAccessTokenPromise } = require('./auth');
const {
getQueries,
getVideoIds,
getPlaylistId,
insertIntoPlaylist,
deletePlaylist,
} = require('./helpers');
const createAction = (date, cutLine) => {
const data = { date, cutLine, store: alfy.config };
refreshAccessTokenPromise(data)
.then(getQueries)
.then(getVideoIds)
.then(getPlaylistId)
.then(insertIntoPlaylist)
.catch(err => console.error(err));
};
const deleteAction = (date, cutLine) => {
const data = { date, cutLine, store: alfy.config };
refreshAccessTokenPromise(data)
.then(getQueries)
.then(getVideoIds)
.then(getPlaylistId)
.then(deletePlaylist)
.catch(err => console.error(err));
};
const input = JSON.parse(alfy.input);
if (input.action == 'create') {
createAction(input.date, input.cutLine);
} else {
deleteAction(input.date, input.cutLine);
};