Skip to content

Commit

Permalink
Capture artist and track separator to check "by"
Browse files Browse the repository at this point in the history
  • Loading branch information
PapiOphidian committed Nov 20, 2023
1 parent de489b5 commit 50dcb30
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/runtime-website/src/music/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const { sync, confprovider, lavalink, snow, queues, sql } = passthrough
const selectTimeout = 1000 * 60
const waitForClientVCJoinTimeout = 5000

const trackNameRegex = /(?:\w+ ? \| ?)?([^|[\]]+?) ?(?:[-–—|:]|\bby\b) ?([^()[\],|]+)?/ // (Toni Romiti) - (Switch Up )\(Ft. Big Rod\) | Non escaped () means cap group
const trackNameRegex = /(?:\w+ ? \| ?)?([^|[\]]+?) ?([-–—|:]|\bby\b) ?([^()[\],|]+)?/ // (Toni Romiti) - (Switch Up )\(Ft. Big Rod\) | Non escaped () means cap group
const knownGoodArtistRegex = /(.+?)(?:\b - Topic\b|VEVO)/
const hiddenEmbedRegex = /(^<|>$)/g
const searchShortRegex = /^\w+?search:/
Expand Down Expand Up @@ -88,8 +88,13 @@ const common = {
artist = authorNameMatch[1]?.trim()
confidence = 2
} else if (trackNameMatch) {
title = trackNameMatch[2]?.trim()
artist = trackNameMatch[1]?.trim()
if (trackNameMatch[2] === "by") {
title = trackNameMatch[1]?.trim()
artist = trackNameMatch[3]?.trim()
} else {
title = trackNameMatch[3]?.trim()
artist = trackNameMatch[1]?.trim()
}
confidence = 1 // mostly confident. Could just flip around
}
}
Expand Down

0 comments on commit 50dcb30

Please sign in to comment.