/**
 * Utility to parse video titles into artist and song parts
 * Handles various dash characters: hyphen (-), en dash (–), em dash (—)
 */

export interface ParsedTitle {
  artist: string;
  song: string;
}

export function parseArtistTitle(title: string): ParsedTitle {
  // Match various dash types with optional spaces
  const dashRegex = /\s*[-–—]\s*/;
  const parts = title.split(dashRegex);
  
  if (parts.length >= 2) {
    // Found a delimiter - split into artist and song
    const artist = parts[0].trim();
    const song = parts.slice(1).join(' - ').trim(); // Rejoin if multiple dashes
    
    return {
      artist: artist || 'video.folx.tv',
      song: song || title
    };
  }
  
  // No delimiter found - use full title as artist, empty song
  return {
    artist: title || 'video.folx.tv',
    song: ''
  };
}