-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
74 lines (63 loc) · 2.07 KB
/
index.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import prompts from 'prompts'
import Vogue from './vogue.js'
import { configDotenv } from 'dotenv'
if (process.env.NODE_ENV !== 'production') {
configDotenv()
}
try {
const show = process.env.SHOW // Replace if no env
const rateLimit = process.env.RATE_LIMIT // Replace if no env
const designer = process.env.DESIGNER
} catch (error) {
console.log(error)
}
(async () => {
console.log(`Welcome to Vogue Runway Scraper`)
console.log(`v1.0.0`)
console.log(``)
console.log(``)
console.log(`If you are getting timed out or experiencing issues with downloads, try increasing the rate limit.`)
console.log(``)
console.log(`This program fetches from Vogue's GraphQL API for designers (brands) and seasons, it's been adapted to`)
console.log(`fetch and download all the images for each season and or brand season.`)
console.log(``)
console.log(`Respond to the questions below and things should get to work.`)
console.log(``)
console.log(``)
console.log(``)
console.log(``)
const questions = [
{
type: 'text',
name: 'designerBool',
message: 'Are you interested in adding only a designer to your collection? (yes or no)',
},
{
type: prev => prev.toLowerCase() == 'yes' ? 'text' : null,
name: 'designer',
message: 'Which designer would you like to collect? (lowercase with hypens)'
},
{
type: prev => prev == 'no' ? 'text' : null,
name: 'season',
message: 'Which season would you like to add to your collection? (lowercase with hypens)',
},
{
type: 'number',
name: 'rateLimit',
message: 'What would you like your rate limit to be? (in milliseconds)',
},
]
const onSubmit = (prompt, answer) => console.log(`Thanks I got ${answer} from ${prompt.name}`);
const response = await prompts(questions, { onSubmit });
let _designer = null
let _season = null
if (response.designerBool.toLowerCase() != 'no' && response.hasOwnProperty('designer')) {
_designer = response.designer
} else {
_season = response.season
}
let _rateLimit = response.rateLimit
const vogue = new Vogue(_rateLimit, _season, _designer)
vogue.run()
})();