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/
|
node_modules/
|
||||||
data/credentials.json
|
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 StealthPlugin = require('puppeteer-extra-plugin-stealth');
|
||||||
const AdBlockerPlugin = require('puppeteer-extra-plugin-adblocker');
|
const AdBlockerPlugin = require('puppeteer-extra-plugin-adblocker');
|
||||||
const ArgsParser = require('./classes/utils/ArgsParser');
|
const ArgsParser = require('./classes/utils/ArgsParser');
|
||||||
|
const MediaLinksFile = require('./classes/filesystem/MediaLinksFile');
|
||||||
const KissAsianScraper = require('./classes/scraping/KissAsianScraper');
|
const KissAsianScraper = require('./classes/scraping/KissAsianScraper');
|
||||||
const JDownloaderClient = require('./classes/download/JDownloaderClient');
|
const JDownloaderClient = require('./classes/download/JDownloaderClient');
|
||||||
|
const Utils = require('./classes/utils/Utils');
|
||||||
const credentials = require('../data/credentials.json');
|
const credentials = require('../data/credentials.json');
|
||||||
|
|
||||||
const args = new ArgsParser().parse(process.argv.slice(2));
|
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(StealthPlugin());
|
||||||
puppeteer.use(AdBlockerPlugin({ blockTrackers: true }));
|
puppeteer.use(AdBlockerPlugin({ blockTrackers: true }));
|
||||||
|
|
||||||
const main = async() => {
|
const singleMediaProcedure = async(scraper, downloader, mediaURL) => {
|
||||||
const browser = await puppeteer.launch({ headless: !args.display, slowMo: 250 });
|
const media = await scraper.getMediaData(mediaURL);
|
||||||
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');
|
|
||||||
await scraper.populateMediaDownloadURLs(media);
|
await scraper.populateMediaDownloadURLs(media);
|
||||||
|
|
||||||
await downloader.addLinks(media);
|
await downloader.addLinks(media);
|
||||||
@ -34,4 +26,29 @@ const main = async() => {
|
|||||||
await downloader.startDownload(crawledLinks);
|
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();
|
main();
|
||||||
|
Loading…
Reference in New Issue
Block a user