diff --git a/package-lock.json b/package-lock.json index fab4c96..6e3adcd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,17 +1,16 @@ { "name": "damonjs", - "version": "1.5.1", + "version": "1.5.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "damonjs", - "version": "1.5.1", + "version": "1.5.5", "license": "MIT", "dependencies": { "events": "^3.3.0", - "shoukaku": "^4.0.1", - "string-similarity": "^4.0.4" + "shoukaku": "^4.0.1" }, "devDependencies": { "@types/events": "^3.0.0", @@ -659,12 +658,6 @@ "safe-buffer": "~5.2.0" } }, - "node_modules/string-similarity": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/string-similarity/-/string-similarity-4.0.4.tgz", - "integrity": "sha512-/q/8Q4Bl4ZKAPjj8WerIBJWALKkaPRfrvhfF8k/B23i4nzrlRj2/go1m90In7nG/3XDSbOo0+pu6RvCTM9RGMQ==", - "deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info." - }, "node_modules/strtok3": { "version": "7.0.0", "dev": true, diff --git a/package.json b/package.json index 1ef6015..c0b077c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "damonjs", - "version": "1.5.4", + "version": "1.5.5", "preview": false, "description": "A modified Shoukaku wrapper with enhanced queue support.", "main": "dist/Index.js", @@ -49,8 +49,7 @@ }, "dependencies": { "events": "^3.3.0", - "shoukaku": "^4.0.1", - "string-similarity": "^4.0.4" + "shoukaku": "^4.0.1" }, "repository": { "type": "git", diff --git a/src/Index.ts b/src/Index.ts index 23a97dc..559568f 100644 --- a/src/Index.ts +++ b/src/Index.ts @@ -8,4 +8,4 @@ export * from './DamonJs'; export { DamonJsTrack, DamonJsQueue, DamonJsPlayer, Plugins }; export * from './Modules/Interfaces'; -export const version = '1.5.4'; +export const version = '1.5.5'; diff --git a/src/Managers/Supports/DamonJsTrack.ts b/src/Managers/Supports/DamonJsTrack.ts index 8f235eb..62d7f5f 100644 --- a/src/Managers/Supports/DamonJsTrack.ts +++ b/src/Managers/Supports/DamonJsTrack.ts @@ -12,7 +12,6 @@ import { Track } from 'shoukaku'; import { DamonJsPlayer } from '../DamonJsPlayer'; import { DamonJsUtils } from '../../Modules/Utils'; import { Utils } from 'discord.js'; -import stringSimilarity from 'string-similarity'; export class DamonJsTrack { /** * DamonJs Instance @@ -176,52 +175,14 @@ export class DamonJsTrack { } return this; } - private fixTitle(title: string) { - const target = title - .replace(/\[.*?\]/g, '') // Remove content within square brackets - .replace(/\(.*?\)/g, '') // Remove content within parentheses - .replace(/- .*? -/g, '') // Remove content within hyphens - .replace(/:.*/, '') // Remove content after colon - .replace(/\|.*$/, '') // Remove content after the first occurrence of | - .replace(/\s+/g, ' ') // Replace multiple spaces with single space - .trim(); - - // Trim excess spaces - return target.trim(); - } private async getTrack(player: DamonJsPlayer): Promise { if (!this.damonjs) throw new DamonJsError(1, 'DamonJs is not set'); const defaultSearchEngine = this.damonjs.DamonJsOptions.defaultSearchEngine; const source = (SourceIDs as any)[defaultSearchEngine || 'youtube'] || 'yt'; const query = [this.author, this.title].filter((x) => !!x).join(' - '); const result = await player.search(`${query}`, { requester: this.requester, engine: source }); - const threshold = this.damonjs.DamonJsOptions.trackResolveThreshold || 0.4; if (!result || !result.tracks.length) throw new DamonJsError(2, 'No results found'); const shoukakUTracks = result.tracks.map((track) => DamonJsUtils.convertDamonJsTrackToTrack(track)); - const matchedSongs: { threshold: number; track: Track }[] = []; - for (const track of shoukakUTracks) { - const titleScore = stringSimilarity.compareTwoStrings( - this.title, - [track.info.author, this.fixTitle(track.info.title)].filter((x) => !!x).join(' - '), - ); - const authorScore = stringSimilarity.compareTwoStrings(this.author, track.info.author); - const duration = this.length ? this.length : 0; - const durationScore = track.info.length >= duration - 2000 && track.info.length <= duration + 2000 ? 1 : 0; - - const totalScore = (titleScore + durationScore + authorScore) / 3; - matchedSongs.push({ - threshold: totalScore || 0, - track, - }); - } - const matchedSong = matchedSongs - .filter((val) => val.threshold >= threshold) - .map((val) => { - return val.track; - }) - .at(0); - if (!matchedSong) throw new DamonJsError(2, 'No results found'); - - return matchedSong; + return shoukakUTracks[0]; } } diff --git a/src/Modules/Interfaces.ts b/src/Modules/Interfaces.ts index 9dd6742..ac27f67 100644 --- a/src/Modules/Interfaces.ts +++ b/src/Modules/Interfaces.ts @@ -12,10 +12,6 @@ export interface DamonJsOptions { sourceForceResolve?: string[]; /** The track resolver. Make sure you set .track for it to work. (I'm not responsible for any error during playback if you don't set it right) */ trackResolver?: (this: DamonJsTrack, options?: ResolveOptions) => Promise; - /** - * The track resolve threshold. - */ - trackResolveThreshold?: number; /** The default youtube thumbnail's size */ defaultYoutubeThumbnail?: YoutubeThumbnail; /** Extend some of the Structures */