Skip to content

Commit

Permalink
feat(Bandcamp): Link to the full release of tracks from an album
Browse files Browse the repository at this point in the history
  • Loading branch information
kellnerd authored and mwiencek committed May 28, 2024
1 parent 8bec145 commit a44d3f0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions providers/Bandcamp/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,17 @@ export class BandcampReleaseLookup extends ReleaseLookup<BandcampProvider, Relea
const { tralbum: rawRelease } = albumPage;
const { current, packages } = rawRelease;

if (current.type === 'track' && current.album_id !== null) {
this.addMessage('Only standalone tracks released outside an album should be imported', 'warning');
}

// Main release URL might use a custom domain, fallback to URL of first package.
let releaseUrl = new URL(rawRelease.url);
if (!releaseUrl.hostname.endsWith('bandcamp.com') && packages?.length) {
releaseUrl = new URL(packages[0].url);
}

if (rawRelease.item_type === 'track' && rawRelease.album_url) {
const albumUrl = new URL(rawRelease.album_url, releaseUrl);
this.addMessage(`Please import the full release from ${albumUrl}`, 'warning');
}

// The "band" can be the artist or a label.
const bandName = albumPage.band.name;
const bandUrl = new URL(releaseUrl);
Expand Down

0 comments on commit a44d3f0

Please sign in to comment.