Finished main execution code.
This commit is contained in:
parent
11aa6ba14f
commit
a2a81651ec
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
node_modules/
|
||||
data/credentials.json
|
||||
*.txt
|
41
src/index.js
41
src/index.js
@ -2,8 +2,10 @@ const puppeteer = require('puppeteer-extra');
|
||||
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
|
||||
const AdBlockerPlugin = require('puppeteer-extra-plugin-adblocker');
|
||||
const ArgsParser = require('./classes/utils/ArgsParser');
|
||||
const MediaLinksFile = require('./classes/filesystem/MediaLinksFile');
|
||||
const KissAsianScraper = require('./classes/scraping/KissAsianScraper');
|
||||
const JDownloaderClient = require('./classes/download/JDownloaderClient');
|
||||
const Utils = require('./classes/utils/Utils');
|
||||
const credentials = require('../data/credentials.json');
|
||||
|
||||
const args = new ArgsParser().parse(process.argv.slice(2));
|
||||
@ -11,18 +13,8 @@ const args = new ArgsParser().parse(process.argv.slice(2));
|
||||
puppeteer.use(StealthPlugin());
|
||||
puppeteer.use(AdBlockerPlugin({ blockTrackers: true }));
|
||||
|
||||
const main = async() => {
|
||||
const browser = await puppeteer.launch({ headless: !args.display, slowMo: 250 });
|
||||
const page = await browser.newPage();
|
||||
|
||||
const scraper = new KissAsianScraper(page);
|
||||
const downloader = new JDownloaderClient(credentials.jdownloader);
|
||||
|
||||
await downloader.load();
|
||||
await scraper.load();
|
||||
await scraper.authenticate(credentials.kissasian);
|
||||
|
||||
const media = await scraper.getMediaData('https://kissasian.li/Drama/My-Roommate-is-a-Gumiho');
|
||||
const singleMediaProcedure = async(scraper, downloader, mediaURL) => {
|
||||
const media = await scraper.getMediaData(mediaURL);
|
||||
await scraper.populateMediaDownloadURLs(media);
|
||||
|
||||
await downloader.addLinks(media);
|
||||
@ -34,4 +26,29 @@ const main = async() => {
|
||||
await downloader.startDownload(crawledLinks);
|
||||
};
|
||||
|
||||
const main = async() => {
|
||||
const browser = await puppeteer.launch({ headless: !args.display, slowMo: 250 });
|
||||
const page = await browser.newPage();
|
||||
|
||||
const file = new MediaLinksFile(args.directory);
|
||||
const mediaToDownload = await file.read();
|
||||
|
||||
const scraper = new KissAsianScraper(page);
|
||||
const downloader = new JDownloaderClient(credentials.jdownloader);
|
||||
|
||||
await downloader.load();
|
||||
await scraper.load();
|
||||
await scraper.authenticate(credentials.kissasian);
|
||||
|
||||
await Utils.mapSeries(mediaToDownload, async(url) => {
|
||||
await singleMediaProcedure(scraper, downloader, url);
|
||||
await file.removeFirstLink();
|
||||
});
|
||||
|
||||
await file.remove();
|
||||
await downloader.finish();
|
||||
await scraper.finish(browser);
|
||||
process.exit(0);
|
||||
};
|
||||
|
||||
main();
|
||||
|
Loading…
Reference in New Issue
Block a user