Fix URLs in albums and tracks
This commit is contained in:
parent
e81ecca731
commit
b0970c79fe
|
@ -158,31 +158,22 @@ function parseAlbumInfo(html, opts) {
|
||||||
};
|
};
|
||||||
if (Array.isArray(basic.albumRelease)) {
|
if (Array.isArray(basic.albumRelease)) {
|
||||||
basic.albumRelease.forEach( release => {
|
basic.albumRelease.forEach( release => {
|
||||||
album.releases.push({
|
const releaseItem = {
|
||||||
name: release.name,
|
name: release.name,
|
||||||
url: release.url,
|
url: null,
|
||||||
format: release.musicReleaseFormat,
|
format: release.musicReleaseFormat,
|
||||||
description: release.description || '',
|
description: release.description || '',
|
||||||
imageUrl: utils.reformatImageUrl(release.image, opts.albumImageFormat)
|
imageUrl: utils.reformatImageUrl(release.image, opts.albumImageFormat)
|
||||||
});
|
}
|
||||||
|
if (release.url) {
|
||||||
|
releaseItem.url = !utils.isAbsoluteUrl(release.url) ? utils.getUrl(release.url, album.url) : release.url;
|
||||||
|
}
|
||||||
|
album.releases.push(releaseItem);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (Array.isArray(basic.track.itemListElement)) {
|
if (Array.isArray(basic.track.itemListElement)) {
|
||||||
const _getStreamUrl = (url) => {
|
|
||||||
let file = null;
|
|
||||||
if (Array.isArray(extra.trackinfo)) {
|
|
||||||
extra.trackinfo.every( track => {
|
|
||||||
if (url.endsWith(track.title_link)) {
|
|
||||||
file = track.file && track.file['mp3-128'] ? track.file['mp3-128'] : null;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return file;
|
|
||||||
}
|
|
||||||
basic.track.itemListElement.forEach( track => {
|
basic.track.itemListElement.forEach( track => {
|
||||||
let trackUrl = track.item.url;
|
let trackUrl = track.item['@id'];
|
||||||
if (!utils.isAbsoluteUrl(trackUrl)) {
|
if (!utils.isAbsoluteUrl(trackUrl)) {
|
||||||
trackUrl = utils.getUrl(trackUrl, album.url);
|
trackUrl = utils.getUrl(trackUrl, album.url);
|
||||||
}
|
}
|
||||||
|
@ -231,7 +222,7 @@ function parseTrackInfo(html, opts) {
|
||||||
const track = {
|
const track = {
|
||||||
type: 'track',
|
type: 'track',
|
||||||
name: basic.name,
|
name: basic.name,
|
||||||
url: basic.url,
|
url: basic['@id'],
|
||||||
imageUrl: opts.imageBaseUrl + '/img/a' + extra.art_id + '_' + opts.albumImageFormat.id + '.jpg',
|
imageUrl: opts.imageBaseUrl + '/img/a' + extra.art_id + '_' + opts.albumImageFormat.id + '.jpg',
|
||||||
releaseDate: extra.current.release_date,
|
releaseDate: extra.current.release_date,
|
||||||
duration: getAdditionalPropertyValue(basic, 'duration_secs'),
|
duration: getAdditionalPropertyValue(basic, 'duration_secs'),
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "bandcamp-fetch",
|
"name": "bandcamp-fetch",
|
||||||
"version": "0.1.0a-20210213.2",
|
"version": "0.1.0a-20210213.3",
|
||||||
"description": "JS library for scraping Bandcamp content",
|
"description": "JS library for scraping Bandcamp content",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user