Skip to content

Commit

Permalink
Fixed some songs returning "null"
Browse files Browse the repository at this point in the history
  • Loading branch information
itsgox committed May 2, 2023
1 parent b6984bc commit f39f744
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ async function SpotifyToYouTubeMusic({ clientID, clientSecret, accessToken, ytMu

// Replace Title

function replaceTitle(title) {
let toCut = title.slice(title.indexOf(' ('), title.length)
if (title.indexOf(' (') < 0) toCut = ''
function replaceTitle(title, symbol) {
let toCut = title.slice(title.indexOf(` ${symbol}`), title.length)
if (title.indexOf(` ${symbol}`) < 0) toCut = ''
let title_ = title.replace(toCut, '')
toCut = title.slice(title.indexOf(' - '), title.length)
if (title.indexOf(' - ') < 0) toCut = ''
Expand All @@ -68,11 +68,11 @@ async function SpotifyToYouTubeMusic({ clientID, clientSecret, accessToken, ytMu
// Search on YouTube Music

let track = tracks[i]
let content = await YouTubeMusic.searchMusics(`${replaceTitle(track.name)} ${track.artists.map(artist => artist.name).join(' ')}`)
let content = await YouTubeMusic.searchMusics(`${replaceTitle(replaceTitle(track.name, '('), '[')} ${track.artists.map(artist => artist.name).join(' ')}`)

// Select Song

content = content.filter(song => replaceTitle(song.title) === replaceTitle(track.name))
content = content.filter(song => replaceTitle(replaceTitle(song.title, '('), '[') === replaceTitle(replaceTitle(track.name, '('), '['))
content = content.filter(song => song.artists.length > 0)
content = content.filter(song => song.artists[0].name === track.artists[0].name)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "spotify-to-ytmusic",
"version": "1.2.4",
"version": "1.2.5",
"description": "Convert songs from Spotify to YouTube Music!",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit f39f744

Please sign in to comment.