fix: use iTunes country=jp globally — returns Japanese original names, identical for non-Japanese music
This commit is contained in:
1 parent
8f14d013b3
commit
a9463917e3
2 files changed
+3
-3
No files matched your search
@@ -92,7 +92,7 @@ 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 url = `https://itunes.apple.com/search?term=${encodeURIComponent(artist + ' ' + searchTitle)}&media=music&entity=musicTrack&limit=10&country=us&explicit=Yes`;
|
const url = `https://itunes.apple.com/search?term=${encodeURIComponent(artist + ' ' + searchTitle)}&media=music&entity=musicTrack&limit=10&country=jp&explicit=Yes`;
|
||||||
const results = await new Promise((resolve, reject) => {
|
const results = await new Promise((resolve, reject) => {
|
||||||
https.get(url, res => {
|
https.get(url, res => {
|
||||||
let d = ''; res.on('data', c => d += c);
|
let d = ''; res.on('data', c => d += c);
|
||||||
@@ -147,7 +147,7 @@ async function fetchItunesTracks(collectionId) {
|
|||||||
async function searchItunesAlbumTracks(artist, album) {
|
async function searchItunesAlbumTracks(artist, album) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
const q = encodeURIComponent(`${artist} ${album}`);
|
const q = encodeURIComponent(`${artist} ${album}`);
|
||||||
https.get(`https://itunes.apple.com/search?term=${q}&media=music&entity=album&limit=5&country=us&explicit=Yes`, res => {
|
https.get(`https://itunes.apple.com/search?term=${q}&media=music&entity=album&limit=5&country=jp&explicit=Yes`, res => {
|
||||||
let d = '';
|
let d = '';
|
||||||
res.on('data', c => d += c);
|
res.on('data', c => d += c);
|
||||||
res.on('end', () => {
|
res.on('end', () => {
|
||||||
|
|||||||
+1
-1
@@ -135,7 +135,7 @@ function _itunesBase() {
|
|||||||
|
|
||||||
export async function itunesSearch(query, entity='musicTrack', limit=25) {
|
export async function itunesSearch(query, entity='musicTrack', limit=25) {
|
||||||
try {
|
try {
|
||||||
const r = await fetch(`${_itunesBase()}/search?term=${encodeURIComponent(query)}&media=music&entity=${entity}&limit=${limit}&country=us&explicit=Yes`);
|
const r = await fetch(`${_itunesBase()}/search?term=${encodeURIComponent(query)}&media=music&entity=${entity}&limit=${limit}&country=jp&explicit=Yes`);
|
||||||
const text = await r.text();
|
const text = await r.text();
|
||||||
if (!text) return [];
|
if (!text) return [];
|
||||||
return JSON.parse(text).results || [];
|
return JSON.parse(text).results || [];
|
||||||
|
|||||||
Reference in new issue
Block a user