revert: restore iTunes direct calls — remove broken backend proxy
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
ad8ba08a03
commit
a2f2f4f6c3
2 files changed
+48
-86
No files matched your search
@@ -483,48 +483,6 @@ function _spTrackItem(t, defaultAlbum, defaultArt, defaultAlbumArtist) {
|
||||
};
|
||||
}
|
||||
|
||||
// ─── ITUNES PROXY ────────────────────────────────────────────────────────────
|
||||
// Browser origin is blocked by Apple (403). All iTunes/Apple RSS calls go through here.
|
||||
|
||||
async function itunesProxy(url) {
|
||||
return new Promise((resolve, reject) => {
|
||||
https.get(url, res => {
|
||||
let d = '';
|
||||
res.on('data', c => d += c);
|
||||
res.on('end', () => { try { resolve(JSON.parse(d)); } catch { resolve({}); } });
|
||||
}).on('error', reject);
|
||||
});
|
||||
}
|
||||
|
||||
app.get('/api/itunes/search', async (req, res) => {
|
||||
try {
|
||||
const { term, entity = 'musicTrack', limit = 25, country = 'us' } = req.query;
|
||||
if (!term) return res.json({ results: [] });
|
||||
const url = `https://itunes.apple.com/search?term=${encodeURIComponent(term)}&media=music&entity=${entity}&limit=${limit}&country=${country}&explicit=Yes`;
|
||||
const d = await itunesProxy(url);
|
||||
res.json({ results: d.results || [] });
|
||||
} catch { res.json({ results: [] }); }
|
||||
});
|
||||
|
||||
app.get('/api/itunes/lookup', async (req, res) => {
|
||||
try {
|
||||
const { id, entity = 'song', limit = 200, country = 'us' } = req.query;
|
||||
if (!id) return res.json({ results: [] });
|
||||
const url = `https://itunes.apple.com/lookup?id=${id}&entity=${entity}&limit=${limit}&country=${country}&explicit=Yes`;
|
||||
const d = await itunesProxy(url);
|
||||
res.json({ results: d.results || [] });
|
||||
} catch { res.json({ results: [] }); }
|
||||
});
|
||||
|
||||
app.get('/api/itunes/charts', async (req, res) => {
|
||||
try {
|
||||
const { type = 'albums', country = 'de' } = req.query;
|
||||
const url = `https://rss.applemarketingtools.com/api/v2/${country}/music/most-played/50/${type}.json`;
|
||||
const d = await itunesProxy(url);
|
||||
res.json(d.feed ? { results: d.feed.results || [] } : { results: [] });
|
||||
} catch { res.json({ results: [] }); }
|
||||
});
|
||||
|
||||
// ─── ROUTES ──────────────────────────────────────────────────────────────────
|
||||
|
||||
app.post('/api/spotify/track-artwork', async (req, res) => {
|
||||
|
||||
Reference in new issue
Block a user