-
Notifications
You must be signed in to change notification settings - Fork 6
/
linewebtoon-th.js
36 lines (32 loc) · 1.17 KB
/
linewebtoon-th.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 IO = require('./_io.js');
const Logger = require('@logtrine/logtrine').FileLogger;
const Scraper = require('@hakuneko/scrapers').LineWebtoon;
const id = 'linewebtoon-th';
var pageFrom = ( process.argv.length > 2 ? process.argv[2] : 1 );
var pageTo = ( process.argv.length > 3 ? process.argv[3] : 9999 );
var pageFrom = parseInt( pageFrom ) || 1;
var pageTo = parseInt( pageTo ) || 9999;
/************
*** MAIN ***
************/
var logger = new Logger(`./${id}.log`, Logger.LEVEL.All);
logger.clear();
var io = new IO(logger);
var scraper = new Scraper(logger);
scraper.language = 'th';
scraper.getMangaList(pageFrom, pageTo)
.then(mangaListWeb => {
if(!mangaListWeb || !mangaListWeb.length) {
throw new Error('Invalid manga list!');
}
logger.debug(`Web: ${mangaListWeb.length} mangas`);
let mangaListLocal = io.loadFileJSON(`./${id}/mangas.json`);
logger.debug(`Local: ${mangaListLocal.length} mangas`);
let mangaList = mangaListLocal.concat(mangaListWeb);
mangaList = io.unique(mangaList);
logger.debug(`Merged: ${mangaList.length} mangas`);
io.saveFileJSON(`./${id}/mangas.json`, mangaList);
})
.catch(error => {
logger.error(error);
});