-
Notifications
You must be signed in to change notification settings - Fork 8
/
app.js
executable file
·47 lines (40 loc) · 1.38 KB
/
app.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
41
42
43
44
45
46
47
#!/usr/bin/env node
const path = require('path')
const package = require('./package.json')
const program = require('commander')
const login = require('./login')
const photo = require('./photo')
const keyword = require('./keyword')
program
.version(package.version)
.option('-l, --login', 'login renren')
.option('-d, --download', 'download album')
.option('-u, --username [string]', 'append username')
.option('-p, --password [string]', 'append password')
.option('-k, --keyword [string]', 'append keyword')
.option('-n, --number [number]', 'the number of keyword images you want to download, default 10')
.option('-i, --userid [string]', 'specify download someone\'s album by user id')
.parse(process.argv)
async function run() {
if (program.login) {
if (program.username === undefined) {
console.log('必须输入用户名: 参考 -u')
} else if (program.password === undefined) {
console.log('必须输入密码: 参考 -p')
} else {
await login(program.username, program.password)
}
} else if (program.download) {
if (program.userid === undefined) {
await photo.getSelfAlbum()
} else {
await photo.getAlbum(program.userid)
}
} else if (program.keyword) {
await keyword.getPhoto(program.keyword, program.number || 10)
}
}
run()
process.on('unhandledRejection', err => {
console.log('unhandledRejection', err)
})