File tree 6 files changed +14
-3
lines changed
6 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ node_modules/
9
9
dotenv
10
10
* .proxies
11
11
success- * .png
12
+ screenshots /
12
13
13
14
* .wav
14
15
* .mp3
Original file line number Diff line number Diff line change 20
20
| ` PROXY_PORT ` | TCP Port number on which the proxy is listening for connections. Default: ` 80 ` |
21
21
| ` RESTART_TIME ` | Restarts chrome after defined milliseconds. ` 0 ` for never, default: ` 0 ` |
22
22
| ` SCREENSHOT ` | Capture screenshot of page if a card is found. Default: ` true ` |
23
+ | ` SCREENSHOT_DIR ` | The directory for saving the screenshots. Default: ` screenshots ` |
23
24
| ` WEB_PORT ` | Starts a webserver to be able to control the bot while it is running. Setting this value starts this service. |
24
25
25
26
???+ info
Original file line number Diff line number Diff line change @@ -114,6 +114,7 @@ PUSHOVER_TOKEN=
114
114
PUSHOVER_USER=
115
115
RESTART_TIME=
116
116
SCREENSHOT=
117
+ SCREENSHOT_DIR=
117
118
SHOW_ONLY_BRANDS=
118
119
SHOW_ONLY_MODELS=
119
120
SHOW_ONLY_SERIES=
Original file line number Diff line number Diff line change @@ -383,6 +383,7 @@ const page = {
383
383
height : 1080 ,
384
384
inStockWaitTime : envOrNumber ( process . env . IN_STOCK_WAIT_TIME ) ,
385
385
screenshot : envOrBoolean ( process . env . SCREENSHOT ) ,
386
+ screenshotDir : envOrString ( process . env . SCREENSHOT_DIR , 'screenshots' ) ,
386
387
timeout : envOrNumber ( process . env . PAGE_TIMEOUT , 30000 ) ,
387
388
width : 1920 ,
388
389
} ;
Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ import {processBackoffDelay} from './model/helpers/backoff';
26
26
import { sendNotification } from '../messaging' ;
27
27
import { handleCaptchaAsync } from './captcha-handler' ;
28
28
import useProxy from '@doridian/puppeteer-page-proxy' ;
29
+ import { promises as fs } from 'fs' ;
30
+ import path from 'path' ;
29
31
30
32
const inStock : Record < string , boolean > = { } ;
31
33
@@ -343,7 +345,11 @@ async function lookupIem(
343
345
if ( config . page . screenshot ) {
344
346
logger . debug ( 'ℹ saving screenshot' ) ;
345
347
346
- link . screenshot = `success-${ Date . now ( ) } .png` ;
348
+ await fs . mkdir ( config . page . screenshotDir , { recursive : true } ) ;
349
+ link . screenshot = path . join (
350
+ config . page . screenshotDir ,
351
+ `success-${ Date . now ( ) } .png`
352
+ ) ;
347
353
await page . screenshot ( { path : link . screenshot } ) ;
348
354
}
349
355
}
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import {logger} from '../logger';
13
13
14
14
const approot = join ( __dirname , '../../../' ) ;
15
15
const webroot = join ( approot , './web' ) ;
16
+ const screenshotDir = join ( approot , config . page . screenshotDir ) ;
16
17
17
18
const contentTypeMap : Record < string , string > = {
18
19
css : 'text/css' ,
@@ -141,11 +142,11 @@ function handleAPI(
141
142
return ;
142
143
}
143
144
144
- sendFile ( response , `../ success-${ timeStamp } .png` ) ;
145
+ sendFile ( response , `success-${ timeStamp } .png` , screenshotDir ) ;
145
146
return ;
146
147
}
147
148
148
- readdir ( approot , ( error , files ) => {
149
+ readdir ( screenshotDir , ( error , files ) => {
149
150
if ( error ) {
150
151
sendError ( response , error . message ) ;
151
152
return ;
You can’t perform that action at this time.
0 commit comments