fix: itunesProxy use 2-arg https.get matching existing working pattern, smarter fallback
- itunesProxy: drop 3-arg form (url, options, cb) — use 2-arg (url, cb) like lookupItunesTrackMeta
- _iGet: if proxy returns {results:[]} trust it (iTunes said no results); only fall back to direct Apple if proxy gave no response at all
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
55be924805
commit
ad8ba08a03
2 files changed
+3
-2
No files matched your search
@@ -488,7 +488,7 @@ function _spTrackItem(t, defaultAlbum, defaultArt, defaultAlbumArtist) {
|
|||||||
|
|
||||||
async function itunesProxy(url) {
|
async function itunesProxy(url) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
https.get(url, { headers: { 'User-Agent': 'iTunes/12.0' } }, res => {
|
https.get(url, res => {
|
||||||
let d = '';
|
let d = '';
|
||||||
res.on('data', c => d += c);
|
res.on('data', c => d += c);
|
||||||
res.on('end', () => { try { resolve(JSON.parse(d)); } catch { resolve({}); } });
|
res.on('end', () => { try { resolve(JSON.parse(d)); } catch { resolve({}); } });
|
||||||
|
|||||||
+2
-1
@@ -58,7 +58,8 @@ async function _iGet(proxyPath, directUrl) {
|
|||||||
const base = S.cfg.backendUrl;
|
const base = S.cfg.backendUrl;
|
||||||
if (base) {
|
if (base) {
|
||||||
const d = await _fetch(base + proxyPath);
|
const d = await _fetch(base + proxyPath);
|
||||||
if (d && Object.keys(d).length) return d;
|
if (d?.results?.length) return d; // proxy returned real results
|
||||||
|
if (d?.results !== undefined) return d; // proxy responded but iTunes had no results (don't double-fetch)
|
||||||
}
|
}
|
||||||
return directUrl ? _fetch(directUrl) : {};
|
return directUrl ? _fetch(directUrl) : {};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user