more fixes
This commit is contained in:
@@ -38,6 +38,33 @@ export class SoundCloudService {
|
||||
console.log('SoundCloud service initialized');
|
||||
}
|
||||
|
||||
private getHighQualityThumbnail(originalUrl: string): string {
|
||||
if (!originalUrl) {
|
||||
return 'https://via.placeholder.com/500x500?text=No+Image';
|
||||
}
|
||||
|
||||
// SoundCloud provides different thumbnail sizes by changing the URL suffix:
|
||||
// -large (100x100) -> -t500x500 (500x500) or -t300x300 (300x300)
|
||||
// Try to get the highest quality version available
|
||||
|
||||
if (originalUrl.includes('-large.')) {
|
||||
// Replace -large with -t500x500 for better quality
|
||||
return originalUrl.replace('-large.', '-t500x500.');
|
||||
} else if (originalUrl.includes('-crop.')) {
|
||||
// If it's crop (400x400), try to get t500x500 or keep crop
|
||||
return originalUrl.replace('-crop.', '-t500x500.');
|
||||
} else if (originalUrl.includes('-t300x300.')) {
|
||||
// If it's already 300x300, try to upgrade to 500x500
|
||||
return originalUrl.replace('-t300x300.', '-t500x500.');
|
||||
} else if (originalUrl.includes('default_avatar_large.png')) {
|
||||
// For default avatars, use a higher quality placeholder
|
||||
return 'https://via.placeholder.com/500x500/007AFF/ffffff?text=🎵';
|
||||
}
|
||||
|
||||
// If no size suffix found or already high quality, return original
|
||||
return originalUrl;
|
||||
}
|
||||
|
||||
async searchTracks(query: string, maxResults: number = 10): Promise<TrackResult[]> {
|
||||
try {
|
||||
console.log(`Searching SoundCloud for: ${query}`);
|
||||
@@ -81,7 +108,7 @@ export class SoundCloudService {
|
||||
id: track.id,
|
||||
title: track.title,
|
||||
channel: track.user?.username || 'Unknown Artist',
|
||||
thumbnail: track.artwork_url || track.user?.avatar_url || 'https://via.placeholder.com/300x300?text=No+Image',
|
||||
thumbnail: this.getHighQualityThumbnail(track.artwork_url || track.user?.avatar_url || ''),
|
||||
duration: Math.floor(track.duration / 1000) || 0, // Convert from ms to seconds
|
||||
url: track.permalink_url,
|
||||
streamable: track.streamable,
|
||||
|
||||
Reference in New Issue
Block a user