fix: iTunes JP-first with US fallback; romaji filter in playlist/starred search
This commit is contained in:
1 parent
a9463917e3
commit
3837783225
3 files changed
+17
-9
No files matched your search
+6
-4
@@ -135,10 +135,12 @@ function _itunesBase() {
|
||||
|
||||
export async function itunesSearch(query, entity='musicTrack', limit=25) {
|
||||
try {
|
||||
const r = await fetch(`${_itunesBase()}/search?term=${encodeURIComponent(query)}&media=music&entity=${entity}&limit=${limit}&country=jp&explicit=Yes`);
|
||||
const text = await r.text();
|
||||
if (!text) return [];
|
||||
return JSON.parse(text).results || [];
|
||||
const base = `${_itunesBase()}/search?term=${encodeURIComponent(query)}&media=music&entity=${entity}&limit=${limit}&explicit=Yes`;
|
||||
const rJp = await fetch(`${base}&country=jp`);
|
||||
const jpResults = JSON.parse(await rJp.text()).results || [];
|
||||
if (jpResults.length) return jpResults;
|
||||
const rUs = await fetch(`${base}&country=us`);
|
||||
return JSON.parse(await rUs.text()).results || [];
|
||||
} catch { return []; }
|
||||
}
|
||||
|
||||
|
||||
+7
-3
@@ -6,7 +6,7 @@ import { playQueue, dlSongLocal, playPreview, toggleStar, parseArtists } from '.
|
||||
import { showCtxMenu, openEditPlModal, openDlModal, closeSidebar, switchNavMode } from './ui.js';
|
||||
import { closeNowPlaying, closeNpMenu } from './nowplaying.js';
|
||||
import { makeCard, makeAlbumCard, makeSongItem, makeGlobalTrackItem, mkSection } from './components.js';
|
||||
import { fetchRomajiIndex, dispArtistById } from './api.js';
|
||||
import { fetchRomajiIndex, dispArtistById, romajiLookup } from './api.js';
|
||||
import { loadSpotifyImporter } from './spotify.js';
|
||||
import { loadSoundCloudImporter } from './soundcloud.js';
|
||||
|
||||
@@ -748,7 +748,9 @@ export function filterPlaylist(val) {
|
||||
document.querySelectorAll('#playlist-songs .song-item').forEach(item => {
|
||||
const title = (item.querySelector('.song-title')?.textContent || '').toLowerCase();
|
||||
const artist = (item.querySelector('.song-artist')?.textContent || '').toLowerCase();
|
||||
item.style.display = (!q || title.includes(q) || artist.includes(q)) ? '' : 'none';
|
||||
if (!q || title.includes(q) || artist.includes(q)) { item.style.display = ''; return; }
|
||||
const rm = romajiLookup(item.dataset.songId);
|
||||
item.style.display = ((rm?.titleRomaji||'').toLowerCase().includes(q) || (rm?.artistRomaji||'').toLowerCase().includes(q)) ? '' : 'none';
|
||||
});
|
||||
}
|
||||
|
||||
@@ -916,7 +918,9 @@ export function filterStarred(val) {
|
||||
document.querySelectorAll('#starred-songs .song-item').forEach(item => {
|
||||
const title = (item.querySelector('.song-title')?.textContent || '').toLowerCase();
|
||||
const artist = (item.querySelector('.song-artist')?.textContent || '').toLowerCase();
|
||||
item.style.display = (!q || title.includes(q) || artist.includes(q)) ? '' : 'none';
|
||||
if (!q || title.includes(q) || artist.includes(q)) { item.style.display = ''; return; }
|
||||
const rm = romajiLookup(item.dataset.songId);
|
||||
item.style.display = ((rm?.titleRomaji||'').toLowerCase().includes(q) || (rm?.artistRomaji||'').toLowerCase().includes(q)) ? '' : 'none';
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user