Create custom comparison function
This commit is contained in:
parent
dafa8087ec
commit
a2ce16a2c3
1 changed files with 6 additions and 2 deletions
8
index.js
8
index.js
|
@ -11,6 +11,10 @@ const io = require('socket.io-client');
|
||||||
const NodeID3 = require('node-id3');
|
const NodeID3 = require('node-id3');
|
||||||
const { JSDOM } = require("jsdom");
|
const { JSDOM } = require("jsdom");
|
||||||
|
|
||||||
|
function compareCase(string) {
|
||||||
|
return string.toLowerCase().replace(/\w/gm, "");
|
||||||
|
}
|
||||||
|
|
||||||
function pathGenerator({ url, name, channelName }) {
|
function pathGenerator({ url, name, channelName }) {
|
||||||
return `${url}-${skewered(`${name} - ${channelName}`)}.mp3`;
|
return `${url}-${skewered(`${name} - ${channelName}`)}.mp3`;
|
||||||
}
|
}
|
||||||
|
@ -90,8 +94,8 @@ async function getVideo() {
|
||||||
const musicList = await searchMusics(`${trackData.artist.name} - ${trackData.name}`);
|
const musicList = await searchMusics(`${trackData.artist.name} - ${trackData.name}`);
|
||||||
|
|
||||||
const youtubeMusicVideo = musicList.find((song) => {
|
const youtubeMusicVideo = musicList.find((song) => {
|
||||||
return skewered(song.title).includes(skewered(trackData.name))
|
return compareCase(song.title).includes(compareCase(trackData.name))
|
||||||
&& song.artists.some(artist => skewered(trackData.artist.name).includes(skewered(artist.name)));
|
&& song.artists.some(artist => compareCase(trackData.artist.name).includes(compareCase(artist.name)));
|
||||||
});
|
});
|
||||||
|
|
||||||
if (youtubeMusicVideo == null) {
|
if (youtubeMusicVideo == null) {
|
||||||
|
|
Loading…
Reference in a new issue