⚡ Use promises instead of callbacks for ytsr
This commit is contained in:
parent
40d43a92e8
commit
ea3c27f3fc
1 changed files with 3 additions and 2 deletions
|
@ -203,11 +203,12 @@ class Player {
|
||||||
if (matchYoutubeURL) {
|
if (matchYoutubeURL) {
|
||||||
query = matchYoutubeURL[1]
|
query = matchYoutubeURL[1]
|
||||||
}
|
}
|
||||||
ytsr(query, (err, results) => {
|
ytsr(query).then((results) => {
|
||||||
if (results.items.length < 1) return resolve([])
|
if (results.items.length < 1) return resolve([])
|
||||||
if (err) return resolve([])
|
|
||||||
const resultsVideo = results.items.filter((i) => i.type === 'video')
|
const resultsVideo = results.items.filter((i) => i.type === 'video')
|
||||||
resolve(allResults ? resultsVideo.map((r) => new Track(r, null, null)) : [new Track(resultsVideo[0], null, null)])
|
resolve(allResults ? resultsVideo.map((r) => new Track(r, null, null)) : [new Track(resultsVideo[0], null, null)])
|
||||||
|
}).catch(() => {
|
||||||
|
return resolve([])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue