bandcamp-fetch
Version:
Scrape Bandcamp content
29 lines • 1.25 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const cheerio_1 = require("cheerio");
const Parse_js_1 = require("../utils/Parse.js");
class LabelArtistsParser {
static parseLabelArtists(html, opts) {
const $ = (0, cheerio_1.load)(html);
const artistsList = $('li.featured-item, li.artists-grid-item');
const results = [];
artistsList.each((i, artistListItem) => {
artistListItem = $(artistListItem);
const img = artistListItem.find('img');
const imgSrc = img.attr('data-original') || img.attr('src');
const imageUrl = (0, Parse_js_1.reformatImageUrl)(imgSrc, opts.imageFormat);
const artist = {
name: artistListItem.find('.featured-grid-name, .artists-grid-name').text(),
url: (0, Parse_js_1.splitUrl)(artistListItem.find('a').attr('href')).base,
location: artistListItem.find('.artists-grid-location').text()
};
if (imageUrl) {
artist.imageUrl = imageUrl;
}
results.push(artist);
});
return results;
}
}
exports.default = LabelArtistsParser;
//# sourceMappingURL=LabelArtistsParser.js.map