Skip to content

Commit 9309d70

Browse files
ThermosporeROpdebee
authored andcommitted
refactor: fix SoundCloud capitalization
1 parent f4d91a1 commit 9309d70

File tree

5 files changed

+24
-24
lines changed

5 files changed

+24
-24
lines changed

Diff for: src/mb_enhanced_cover_art_uploads/docs/supported_providers.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ The following table describes the types of links supported by MB: Upload to CAA
2929
| Qobuz | ✔️ | ✔️ | Goodies are grabbed whenever possible. Back covers might not be supported at this time, if you have a release with a back cover, please let me know. Maximised to original source image. |
3030
| RateYourMusic | ✔️ | ✔️ | Requires being logged in to RYM. |
3131
| Rockipedia | ✔️ ||
32-
| Soundcloud | ✔️ | ✔️ | Grabs custom track images. |
32+
| SoundCloud | ✔️ | ✔️ | Grabs custom track images. |
3333
| Spotify | ✔️ | ✔️ |
3434
| Tidal | ✔️ | ✔️ | listen.tidal.com/store.tidal.com are converted to tidal.com prior to fetching |
3535
| Traxsource | ✔️ | ✔️ | Limited to 600x600. |

Diff for: src/mb_enhanced_cover_art_uploads/providers/base.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export abstract class ProviderWithTrackImages extends CoverArtProvider {
163163
// Providers that provide track images which need to be deduplicated. The
164164
// base class supports deduping by URL and thumbnail content.
165165
//
166-
// Some providers, like Soundcloud and sometimes Bandcamp, use unique URLs
166+
// Some providers, like SoundCloud and sometimes Bandcamp, use unique URLs
167167
// for each track image, so deduplicating based on URL won't work. They may
168168
// also not return any headers that uniquely identify the image (like a
169169
// Digest or an ETag), so we need to load the image and compare its data

Diff for: src/mb_enhanced_cover_art_uploads/providers/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { NetEaseProvider } from './netease';
2525
import { QobuzProvider } from './qobuz';
2626
import { RateYourMusicProvider } from './rateyourmusic';
2727
import { RockipediaProvider } from './rockipedia';
28-
import { SoundcloudProvider } from './soundcloud';
28+
import { SoundCloudProvider } from './soundcloud';
2929
import { SpotifyProvider } from './spotify';
3030
import { TidalProvider } from './tidal';
3131
import { TraxsourceProvider } from './traxsource';
@@ -68,7 +68,7 @@ addProvider(new QobuzProvider());
6868
addProvider(new RateYourMusicProvider());
6969
addProvider(new RockipediaProvider());
7070
addProvider(new SevenDigitalProvider());
71-
addProvider(new SoundcloudProvider());
71+
addProvider(new SoundCloudProvider());
7272
addProvider(new SpotifyProvider());
7373
addProvider(new TidalProvider());
7474
addProvider(new TraxsourceProvider());

Diff for: src/mb_enhanced_cover_art_uploads/providers/soundcloud.ts

+16-16
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ const SC_CLIENT_ID_REGEX = /client_id\s*:\s*"([a-zA-Z\d]{32})"/;
5151
const SC_CLIENT_ID_CACHE_KEY = 'ROpdebee_ECAU_SC_ID';
5252
const SC_HOMEPAGE = 'https://soundcloud.com/';
5353

54-
export class SoundcloudProvider extends ProviderWithTrackImages {
54+
export class SoundCloudProvider extends ProviderWithTrackImages {
5555
public readonly supportedDomains = ['soundcloud.com'];
5656
public readonly favicon = 'https://a-v2.sndcdn.com/assets/images/sc-icons/favicon-2cadd14bdb.ico';
57-
public readonly name = 'Soundcloud';
58-
// Soundcloud's URL scheme is a bit complicated, so instead of creating overly
57+
public readonly name = 'SoundCloud';
58+
// SoundCloud's URL scheme is a bit complicated, so instead of creating overly
5959
// complex regular expressions, we'll match URLs programmatically. However,
6060
// we still need to define this field, even though it'll never be used.
6161
protected readonly urlRegex = [];
@@ -88,7 +88,7 @@ export class SoundcloudProvider extends ProviderWithTrackImages {
8888
}
8989
}
9090

91-
throw new Error('Could not extract Soundcloud Client ID');
91+
throw new Error('Could not extract SoundCloud Client ID');
9292
}
9393

9494
private static async getClientID(): Promise<string> {
@@ -106,7 +106,7 @@ export class SoundcloudProvider extends ProviderWithTrackImages {
106106
const oldId = await this.getClientID();
107107
const newId = await this.loadClientID();
108108

109-
assert(oldId !== newId, 'Attempted to refresh Soundcloud Client ID but retrieved the same one.');
109+
assert(oldId !== newId, 'Attempted to refresh SoundCloud Client ID but retrieved the same one.');
110110
localStorage.setItem(SC_CLIENT_ID_CACHE_KEY, newId);
111111
}
112112

@@ -120,10 +120,10 @@ export class SoundcloudProvider extends ProviderWithTrackImages {
120120
.split('/');
121121

122122
return (pathParts.length > 0
123-
&& !SoundcloudProvider.badArtistIDs.has(artistId)
123+
&& !SoundCloudProvider.badArtistIDs.has(artistId)
124124
// artist/likes, artist/track/recommended, artist/sets, ...
125125
// but not artist/sets/setname!
126-
&& !SoundcloudProvider.badSubpaths.has(urlBasename(url)));
126+
&& !SoundCloudProvider.badSubpaths.has(urlBasename(url)));
127127
}
128128

129129
public override extractId(url: URL): string | undefined {
@@ -141,7 +141,7 @@ export class SoundcloudProvider extends ProviderWithTrackImages {
141141
const metadata = this.extractMetadataFromJS(pageContent)
142142
?.find((data) => ['sound', 'playlist'].includes(data.hydratable));
143143
if (!metadata) {
144-
throw new Error('Could not extract metadata from Soundcloud page. The release may have been removed.');
144+
throw new Error('Could not extract metadata from SoundCloud page. The release may have been removed.');
145145
}
146146

147147
if (metadata.hydratable === 'sound') {
@@ -175,7 +175,7 @@ export class SoundcloudProvider extends ProviderWithTrackImages {
175175
covers.push(...backdrops.map((backdropUrl) => ({
176176
url: new URL(backdropUrl),
177177
types: [ArtworkTypeIDs.Other],
178-
comment: 'Soundcloud backdrop',
178+
comment: 'SoundCloud backdrop',
179179
})));
180180
}
181181

@@ -195,7 +195,7 @@ export class SoundcloudProvider extends ProviderWithTrackImages {
195195
// Don't bother extracting track covers if they won't be used anyway
196196
if (onlyFront) return covers;
197197

198-
// Soundcloud page only contains data for the first 5 tracks at first,
198+
// SoundCloud page only contains data for the first 5 tracks at first,
199199
// we need to load the rest of the tracks.
200200
const tracks = await this.lazyLoadTracks(metadata.data.tracks);
201201

@@ -215,7 +215,7 @@ export class SoundcloudProvider extends ProviderWithTrackImages {
215215
trackImages.push(...visuals.map((visualUrl) => ({
216216
url: visualUrl,
217217
trackNumber: (trackNumber + 1).toString(),
218-
customCommentPrefix: ['Soundcloud backdrop for track', 'Soundcloud backdrop for tracks'] as [string, string],
218+
customCommentPrefix: ['SoundCloud backdrop for track', 'SoundCloud backdrop for tracks'] as [string, string],
219219
})));
220220

221221
return trackImages;
@@ -235,7 +235,7 @@ export class SoundcloudProvider extends ProviderWithTrackImages {
235235
try {
236236
trackData = await this.getTrackData(lazyTrackIDs);
237237
} catch (error) {
238-
LOGGER.error('Failed to load Soundcloud track data, some track images may be missed', error);
238+
LOGGER.error('Failed to load SoundCloud track data, some track images may be missed', error);
239239
// We'll still return the tracks that we couldn't load, otherwise
240240
// the track indices will be wrong.
241241
return tracks;
@@ -260,8 +260,8 @@ export class SoundcloudProvider extends ProviderWithTrackImages {
260260
}
261261

262262
private async getTrackData(lazyTrackIDs: number[], firstTry = true): Promise<SCHydrationTrack[]> {
263-
LOGGER.info('Loading Soundcloud track data');
264-
const clientId = await SoundcloudProvider.getClientID();
263+
LOGGER.info('Loading SoundCloud track data');
264+
const clientId = await SoundCloudProvider.getClientID();
265265

266266
// TODO: Does this work still work if we pass a large list of IDs?
267267
const parameters = new URLSearchParams({
@@ -278,11 +278,11 @@ export class SoundcloudProvider extends ProviderWithTrackImages {
278278
}
279279

280280
LOGGER.debug('Attempting to refresh client ID');
281-
await SoundcloudProvider.refreshClientID();
281+
await SoundCloudProvider.refreshClientID();
282282
return this.getTrackData(lazyTrackIDs, firstTry = false);
283283
}
284284

285-
return safeParseJSON<LoadedAPITrack[]>(trackDataResponse.text, 'Failed to parse Soundcloud API response');
285+
return safeParseJSON<LoadedAPITrack[]>(trackDataResponse.text, 'Failed to parse SoundCloud API response');
286286
}
287287

288288
private extractVisuals(track: SCHydrationTrack): string[] {

Diff for: tests/unit/mb_enhanced_cover_art_uploads/providers/soundcloud.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { LOGGER } from '@lib/logging/logger';
22
import { ArtworkTypeIDs } from '@lib/MB/cover-art';
3-
import { SoundcloudProvider } from '@src/mb_enhanced_cover_art_uploads/providers/soundcloud';
3+
import { SoundCloudProvider } from '@src/mb_enhanced_cover_art_uploads/providers/soundcloud';
44
import { setupPolly } from '@test-utils/pollyjs';
55
import { itBehavesLike } from '@test-utils/shared-behaviour';
66

@@ -16,7 +16,7 @@ afterEach(() => {
1616
});
1717

1818
describe('soundcloud provider', () => {
19-
const provider = new SoundcloudProvider();
19+
const provider = new SoundCloudProvider();
2020
const pollyContext = setupPolly();
2121

2222
describe('url matching', () => {
@@ -113,7 +113,7 @@ describe('soundcloud provider', () => {
113113
index: 3,
114114
urlPart: '9b0d4395-cc72-4aa9-84e1-17b807264e2f',
115115
types: [ArtworkTypeIDs.Track],
116-
comment: 'Soundcloud backdrop for tracks 2, 4, 6, 8, 10, 18, 20',
116+
comment: 'SoundCloud backdrop for tracks 2, 4, 6, 8, 10, 18, 20',
117117
}],
118118
}];
119119

@@ -168,7 +168,7 @@ describe('soundcloud provider', () => {
168168
const covers = await provider.findImages(new URL('https://soundcloud.com/soundcloud/sets/i-am-other-vol-2'));
169169

170170
expect(covers).toBeArrayOfSize(6);
171-
expect(mockLoggerError).toHaveBeenCalledWith('Failed to load Soundcloud track data, some track images may be missed', expect.any(Error));
171+
expect(mockLoggerError).toHaveBeenCalledWith('Failed to load SoundCloud track data, some track images may be missed', expect.any(Error));
172172
});
173173

174174
it('attempts to refresh client ID', async () => {

0 commit comments

Comments
 (0)