bandcamp-fetch
Advanced tools
Comparing version 0.2.1-b.20211020 to 0.2.1-b.20211020b
@@ -185,4 +185,16 @@ const fetch = require('node-fetch'); | ||
const _isInfoComplete = (data) => { | ||
return data.name !== '' && (data.type === 'label' || data.label !== null); | ||
return data.name !== null && data.url !== null && | ||
(data.type === 'label' || data.label !== null); | ||
} | ||
const _fillInfo = (toData, fromData) => { | ||
if (toData.name === null) { | ||
toData.name = fromData.name; | ||
} | ||
if (toData.url === null) { | ||
toData.url = fromData.url; | ||
} | ||
if (toData.label === null) { | ||
toData.label = fromData.label; | ||
} | ||
} | ||
@@ -201,8 +213,3 @@ let url = _getUrl(); | ||
let info = parser.parseArtistOrLabelInfo(html, opts); | ||
if (result.name === '') { | ||
result.name = info.name; | ||
} | ||
if (result.label === null) { | ||
result.label = info.label; | ||
} | ||
_fillInfo(result, info); | ||
// Return if result is complete | ||
@@ -220,10 +227,9 @@ if (_isInfoComplete(result)) { | ||
info = parser.parseArtistOrLabelInfo(html, opts); | ||
if (result.name === '') { | ||
result.name = info.name; | ||
} | ||
if (result.label === null) { | ||
result.label = info.label; | ||
} | ||
_fillInfo(result, info); | ||
} | ||
if (result.url === null) { | ||
result.url = artistOrLabelUrl; | ||
} | ||
return result; | ||
@@ -230,0 +236,0 @@ } |
@@ -460,6 +460,6 @@ const cheerio = require('cheerio'); | ||
type: isLabel ? 'label' : 'artist', | ||
name: bandData.name, | ||
url: bandData.url, | ||
name: bandData.name || null, | ||
url: bandData.url || null, | ||
description: description, | ||
location: $('#band-name-location').find('.location').text(), | ||
location: $('#band-name-location').find('.location').text() || '', | ||
imageUrl: utils.reformatImageUrl($('img.band-photo').attr('src'), opts.imageFormat) | ||
@@ -466,0 +466,0 @@ }; |
{ | ||
"name": "bandcamp-fetch", | ||
"version": "0.2.1-b.20211020", | ||
"version": "0.2.1-b.20211020b", | ||
"description": "JS library for scraping Bandcamp content", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -345,2 +345,5 @@ # bandcamp-fetch | ||
0.2.1-b.20211020b | ||
- Fix URL sometimes null in result of `getArtistOrLabelInfo()` | ||
0.2.1-b.20211020 | ||
@@ -347,0 +350,0 @@ - Improve data fetching in `getArtistOrLabelInfo()` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
415027
2219
361