-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
30 lines (25 loc) · 861 Bytes
/
app.js
File metadata and controls
30 lines (25 loc) · 861 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
27
28
29
30
import config from './config';
import Instapaper from 'instapaper';
import moment from 'moment';
const client = new Instapaper(config.instapaper.key, config.instapaper.secret);
client.setUserCredentials(config.instapaper.username, config.instapaper.password);
const limit = moment().subtract(1, 'months');
client.bookmarks.list().then((res)=> {
return res
.filter((result)=> result.type === 'bookmark')
.map((bookmark)=> {
bookmark.date = moment(bookmark.time * 1000);
return bookmark;
});
}).then((bookmarks)=> {
const deletePromise = [];
bookmarks.forEach((bookmark)=> {
if (bookmark.date.isBefore(limit)) {
console.log('Remove: ', bookmark.title);
deletePromise.push(client.bookmarks.delete(bookmark.bookmark_id));
}
});
return Promise.all(deletePromise);
}).then(()=> {
console.log('Done!');
});