Skip to content

Commit e499509

Browse files
committed
feat(bandcamp): handle subscriber only releases
1 parent 57de2f6 commit e499509

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

providers/Bandcamp/__snapshots__/mod.test.ts.snap

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ snapshot[`Bandcamp provider > release lookup > subscriber-only release 1`] = `
161161
{
162162
types: [
163163
"paid download",
164-
"free streaming",
165164
],
166165
url: "https://arbee.bandcamp.com/album/des-papiers-ii",
167166
},
@@ -207,7 +206,6 @@ snapshot[`Bandcamp provider > release lookup > subscriber-only release 1`] = `
207206
{
208207
id: "arbee/des-papiers-ii",
209208
linkTypes: [
210-
"free streaming",
211209
"paid download",
212210
],
213211
provider: "bandcamp",
@@ -257,7 +255,6 @@ All the things, Steve. Cover model: Flapjack.",
257255
{
258256
types: [
259257
"paid download",
260-
"free streaming",
261258
],
262259
url: "https://stevelawson.bandcamp.com/album/ambiguous-hands",
263260
},
@@ -309,7 +306,6 @@ All the things, Steve. Cover model: Flapjack.",
309306
{
310307
id: "stevelawson/ambiguous-hands",
311308
linkTypes: [
312-
"free streaming",
313309
"paid download",
314310
],
315311
provider: "bandcamp",

providers/Bandcamp/json_types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ interface TrAlbum {
5151
licensed_version_ids: null;
5252
package_associated_license_id: null;
5353
has_video: null;
54+
/** Indicates whether the release is for paid subscribers only */
5455
tralbum_subscriber_only: boolean;
5556
/** Indicates whether the release is currently available for pre-order (`null` for standalone tracks). */
5657
album_is_preorder: boolean | null;

providers/Bandcamp/mod.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export default class BandcampProvider extends MetadataProvider {
123123
getTrackLinkTypes(track: TrackInfo): LinkType[] {
124124
const linkTypes: LinkType[] = [];
125125

126-
if (track.streaming === 1) {
126+
if (this.isFreeStreamingTrack(track)) {
127127
linkTypes.push('free streaming');
128128
}
129129

@@ -180,6 +180,10 @@ export default class BandcampProvider extends MetadataProvider {
180180
},
181181
});
182182
}
183+
184+
isFreeStreamingTrack(track: TrackInfo): boolean {
185+
return track.streaming === 1 && !!track.file;
186+
}
183187
}
184188

185189
export class BandcampReleaseLookup extends ReleaseLookup<BandcampProvider, ReleasePage> {
@@ -314,7 +318,10 @@ export class BandcampReleaseLookup extends ReleaseLookup<BandcampProvider, Relea
314318
if (rawRelease.freeDownloadPage || (current.minimum_price === 0.0 && !current.is_set_price)) {
315319
linkTypes.push('free download');
316320
}
317-
if (rawRelease.trackinfo.every((track) => track.streaming)) {
321+
if (
322+
!rawRelease.tralbum_subscriber_only &&
323+
rawRelease.trackinfo.every((track) => this.provider.isFreeStreamingTrack(track))
324+
) {
318325
linkTypes.push('free streaming');
319326
}
320327

0 commit comments

Comments
 (0)