-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
63 lines (46 loc) · 1.98 KB
/
app.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
import puppeteer from 'puppeteer';
import { getTableInfoIn, getAnchorsIn, getTorrentRows, getTorrentInfo } from './functions.js';
import { insertFile, getLastIdFiles, insertEpisodes } from './database.js';
(async () => {
const totalPages = 104;
const browser = await puppeteer.launch({
headless: "new",
});
const page = await browser.newPage();
await page.setViewport({width: 1920, height: 1080});
let cookiesAccepted = false;
for (let currentPage = 1; currentPage <= totalPages; currentPage++) {
await page.goto(`https://dontorrent.party/documentales/letra-./page/${currentPage}`);
console.log(currentPage);
if (!cookiesAccepted) {
await page.click('#Close_fa');
cookiesAccepted = true;
}
const anchorsIn = await getAnchorsIn(page);
for (const anchor of anchorsIn) {
await page.goto(anchor);
const tableInfoIn = await getTableInfoIn(page);
if (tableInfoIn!==0) {
const torrentInfo = await getTorrentInfo(page);
const torrentRows = await getTorrentRows(page);
console.log(torrentInfo[0]);
console.log(torrentRows[0]);
await insertFile(
torrentInfo[0].title,
torrentInfo[0].description,
'DOCUMENTARY',
torrentInfo[0].formato,
torrentInfo[0].imgSrc,
1
);
const file_id = await getLastIdFiles();
for (let i = 0; i < torrentRows.length; i++) {
const episode = torrentRows[i].tdTextClean[0];
const date = torrentRows[i].tdTextClean[1];
const ext_file_route = torrentRows[i].aText;
await insertEpisodes(episode, ext_file_route, date, file_id);
}
}
}
}
})();