Skip to content

Commit

Permalink
Suit for new website updates, update dependencies, fix vulnerabilitie…
Browse files Browse the repository at this point in the history
…s, upgrade to v0.0.3
  • Loading branch information
szekelymilan committed May 5, 2020
1 parent 2737c7f commit 67a5c3d
Show file tree
Hide file tree
Showing 3 changed files with 454 additions and 253 deletions.
12 changes: 6 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ const puppeteer = require('puppeteer-extra');

puppeteer.use(require('puppeteer-extra-plugin-stealth')());

function getAlbumName(string) {
function getAlbumNameFromTextContent(string) {
const txt = string.split('"');
return txt[txt.length - 2];
}

function getDistribution(string) {
function getDistributionFromTextContent(string) {
const txt = string.split('(');
const answer = [];

Expand Down Expand Up @@ -48,10 +48,10 @@ exports.getAlbumInfo = async input => {
await page.$('#main > div:nth-child(1) > h2:nth-child(2) > a:nth-child(1)'),
);

const albumName = getAlbumName(
const albumName = getAlbumNameFromTextContent(
await page.evaluate(
element => element.textContent,
await page.$('#main > div:nth-child(1) > div:nth-child(8) > h2:nth-child(26)'),
await page.$('#main > div:nth-child(1) > div:nth-child(8) > h2:nth-child(28)'),
),
);

Expand All @@ -65,10 +65,10 @@ exports.getAlbumInfo = async input => {
await page.$('#nbRatings_1'),
);

const distribution = getDistribution(
const distribution = getDistributionFromTextContent(
await page.evaluate(
element => element.textContent,
await page.$('#main > div:nth-child(1) > div:nth-child(8) > blockquote:nth-child(18)'),
await page.$('#main > div:nth-child(1) > div:nth-child(8) > blockquote:nth-child(20)'),
),
);

Expand Down
Loading

0 comments on commit 67a5c3d

Please sign in to comment.