Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions providers/Bandcamp/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ export default class BandcampProvider extends MetadataProvider {
}

export class BandcampReleaseLookup extends ReleaseLookup<BandcampProvider, ReleasePage> {
rawReleaseUrl: URL | undefined;

constructReleaseApiUrl(): URL | undefined {
return undefined;
}
Expand All @@ -140,6 +142,7 @@ export class BandcampReleaseLookup extends ReleaseLookup<BandcampProvider, Relea
}

const webUrl = this.constructReleaseUrl(this.lookup.value, this.lookup);
this.rawReleaseUrl = webUrl;
const { content: release, timestamp } = await this.provider.extractEmbeddedJson<ReleasePage>(
webUrl,
this.options.snapshotMaxTimestamp,
Expand All @@ -153,10 +156,10 @@ export class BandcampReleaseLookup extends ReleaseLookup<BandcampProvider, Relea
const { tralbum: rawRelease } = albumPage;
const { current, packages } = rawRelease;

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

if (rawRelease.item_type === 'track' && rawRelease.album_url) {
Expand Down