Skip to content

Commit

Permalink
Add soundcloud regex (#1932)
Browse files Browse the repository at this point in the history
* Add soundcloud regex

* Update package.json

---------

Co-authored-by: Twilight <46562212+twlite@users.noreply.github.com>
  • Loading branch information
retrouser955 and twlite authored Aug 3, 2024
1 parent 16bd4e2 commit 5a5da80
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"build:web": "turbo run build --filter=website",
"start:web": "turbo run preview --filter=website",
"test": "turbo run test --color",
"bot": "yarn workspace music-bot start"
"start:bot": "yarn workspace music-bot start",
"build:bot": "yarn workspace music-bot build"
},
"repository": {
"type": "git",
Expand Down
6 changes: 6 additions & 0 deletions packages/discord-player/__test__/QueryResolver.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ describe('QueryResolver', () => {
expect(qr.resolve(query).type).toBe(QueryType.VIMEO);
});

it("should be soundcloud", async () => {
const query = "https://on.soundcloud.com/YVLyjzk2mmp5TJF99"
const rediected = await qr.preResolve(query)
expect(rediected).toMatch(qr.regex.soundcloudTrackRegex)
})

it('should be soundcloudTrack', () => {
const query = 'https://soundcloud.com/rick-astley-official/never-gonna-give-you-up-4';
expect(qr.resolve(query).type).toBe(QueryType.SOUNDCLOUD_TRACK);
Expand Down
3 changes: 2 additions & 1 deletion packages/discord-player/src/utils/QueryResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const DomainsMap = {
// prettier-ignore
const redirectDomains = new Set([
/^https?:\/\/spotify.link\/[A-Za-z0-9]+$/,
/^https:\/\/on\.soundcloud\.com\/[a-zA-Z1-9]{0,17}$/
]);

export interface ResolvedQuery {
Expand All @@ -58,7 +59,7 @@ class QueryResolver {
appleMusicSongRegex,
soundcloudTrackRegex,
soundcloudPlaylistRegex,
youtubePlaylistRegex
youtubePlaylistRegex,
};
}

Expand Down

0 comments on commit 5a5da80

Please sign in to comment.