spotify-to-ytmusic
Advanced tools
Comparing version 1.0.8 to 1.1.0
18
index.js
@@ -56,10 +56,24 @@ const YoutubeMusic = require('node-youtube-music') | ||
// Replace Title | ||
async function replaceTitle(title) { | ||
let toCut = title.slice(title.indexOf(' ('), title.length) | ||
if (title.indexOf(' (') < 0) toCut = '' | ||
let title_ = title.replace(toCut, '') | ||
toCut = title.slice(title.indexOf(' - '), title.length) | ||
if (title.indexOf(' - ') < 0) toCut = '' | ||
title_ = title_.replace(toCut, '') | ||
return title_ | ||
} | ||
// Search on YouTube Music | ||
let track = tracks[i] | ||
let content = await YoutubeMusic.searchMusics(`name: ${track.name}, artists: ${track.artists.map(artist => artist.name).join(', ')}`) | ||
let content = await YoutubeMusic.searchMusics(`${await replaceTitle(track.name)} ${track.artists.map(artist => artist.name).join(' ')}`) | ||
// Select Song | ||
content.length < 1 ? ytList.push(null) : ytList.push(`https://www.youtube.com/watch?v=${content[0].youtubeId}`) | ||
content = content.filter(async (song) => await replaceTitle(song.title) === await replaceTitle(track.name)) | ||
content = content.filter(song => song.artists.map(artist => artist.name).join(', ') === track.artists.map(artist => artist.name).join(', ')) | ||
content.length < 1 ? ytList.push(null) : ytList.push(content[0]) | ||
} | ||
@@ -66,0 +80,0 @@ |
{ | ||
"name": "spotify-to-ytmusic", | ||
"version": "1.0.8", | ||
"version": "1.1.0", | ||
"description": "Convert songs from Spotify to YouTube Music!", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -9,2 +9,3 @@ # Spotify to YouTube Music | ||
> - **spotify-to-ytmusic** is now much faster. | ||
> - The **YouTube Music** results are now much more accurate. | ||
@@ -11,0 +12,0 @@ ## Installation |
5498
57
60