fix: split multi-artist string before iTunes search query in lookupItunesTrackMeta
This commit is contained in:
1 parent
3837783225
commit
9821334cc8
1 file changed
+2
-1
@@ -92,8 +92,9 @@ async function lookupItunesTrackMeta(artist, title) {
|
|||||||
// e.g. "don't rush - slowed" → search "don't rush" so iTunes finds the single
|
// e.g. "don't rush - slowed" → search "don't rush" so iTunes finds the single
|
||||||
const baseTitle = title.replace(/\s*[-–]\s*\S[^-]*$/, '').trim() || title;
|
const baseTitle = title.replace(/\s*[-–]\s*\S[^-]*$/, '').trim() || title;
|
||||||
const searchTitle = baseTitle !== title ? baseTitle : title;
|
const searchTitle = baseTitle !== title ? baseTitle : title;
|
||||||
|
const searchArtist = artist.split(/[;,&]/)[0].trim();
|
||||||
const fetchItunes = (country) => new Promise((resolve, reject) => {
|
const fetchItunes = (country) => new Promise((resolve, reject) => {
|
||||||
const url = `https://itunes.apple.com/search?term=${encodeURIComponent(artist + ' ' + searchTitle)}&media=music&entity=musicTrack&limit=10&country=${country}&explicit=Yes`;
|
const url = `https://itunes.apple.com/search?term=${encodeURIComponent(searchArtist + ' ' + searchTitle)}&media=music&entity=musicTrack&limit=10&country=${country}&explicit=Yes`;
|
||||||
https.get(url, res => {
|
https.get(url, res => {
|
||||||
let d = ''; res.on('data', c => d += c);
|
let d = ''; res.on('data', c => d += c);
|
||||||
res.on('end', () => { try { resolve(JSON.parse(d).results || []); } catch { reject(new Error('parse')); } });
|
res.on('end', () => { try { resolve(JSON.parse(d).results || []); } catch { reject(new Error('parse')); } });
|
||||||
|
|||||||
Reference in new issue
Block a user