Revert to BitMidi only
Restore original BitMidiAdapter (was working for weeks). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,25 +8,17 @@ export class BitMidiAdapter implements SearchAdapter {
|
|||||||
async search(query: string): Promise<MIDICandidate[]> {
|
async search(query: string): Promise<MIDICandidate[]> {
|
||||||
try {
|
try {
|
||||||
const searchUrl = `${this.baseUrl}/search?q=${encodeURIComponent(query)}`;
|
const searchUrl = `${this.baseUrl}/search?q=${encodeURIComponent(query)}`;
|
||||||
console.log(`BitMidi: Fetching ${searchUrl}`);
|
|
||||||
|
|
||||||
const response = await fetch(searchUrl, {
|
const response = await fetch(searchUrl, {
|
||||||
headers: {
|
headers: {
|
||||||
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
'User-Agent': 'Mozilla/5.0 (compatible; MotifBot/1.0)'
|
||||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
|
|
||||||
'Accept-Language': 'en-US,en;q=0.5',
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(`BitMidi: Response status ${response.status}`);
|
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`BitMidi search failed: ${response.status}`);
|
throw new Error(`BitMidi search failed: ${response.status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const html = await response.text();
|
const html = await response.text();
|
||||||
console.log(`BitMidi: Got ${html.length} bytes, has initStore: ${html.includes('window.initStore')}`);
|
|
||||||
|
|
||||||
return this.parseSearchResults(html, query);
|
return this.parseSearchResults(html, query);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('BitMidi search error:', error);
|
console.error('BitMidi search error:', error);
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
import type { SearchAdapter, MIDICandidate } from '../types.js';
|
import type { SearchAdapter, MIDICandidate } from '../types.js';
|
||||||
import { BitMidiAdapter } from '../adapters/BitMidiAdapter.js';
|
import { BitMidiAdapter } from '../adapters/BitMidiAdapter.js';
|
||||||
import { FreeMidiAdapter } from '../adapters/FreeMidiAdapter.js';
|
|
||||||
|
|
||||||
export class MIDISearchService {
|
export class MIDISearchService {
|
||||||
private adapters: SearchAdapter[];
|
private adapters: SearchAdapter[];
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
// FreeMidi first (more reliable), BitMidi as backup
|
|
||||||
this.adapters = [
|
this.adapters = [
|
||||||
new FreeMidiAdapter(),
|
|
||||||
new BitMidiAdapter()
|
new BitMidiAdapter()
|
||||||
];
|
];
|
||||||
console.log('MIDISearchService initialized with adapters:', this.adapters.map(a => a.name));
|
console.log('MIDISearchService initialized with adapters:', this.adapters.map(a => a.name));
|
||||||
|
|||||||
Reference in New Issue
Block a user