Anakunda / QobuzLib

// ==UserScript==
// ==UserLibrary==
// @name         QobuzLib
// @namespace    https://openuserjs.org/users/Anakunda
// @version      1.35.01
// @author       Anakunda
// @iconURL      https://static-www.qobuz.com/img/favicon/favicon-96x96.png
// @license      GPL-3.0-or-later
// @copyright    2021, Anakunda (https://openuserjs.org/users/Anakunda)
// @exclude      *
// ==/UserScript==
// ==/UserLibrary==

const qobuzTranslations = [
	['Accordion', 'Accordeon', 'Accordéon', 'Akkordeon', 'Acordeón', 'Fisarmonica'],
	['Acid Jazz', 'Acid jazz'],
	['Africa', 'Afrika', 'Afrique', 'África'],
	['Afrobeat'],
	['Alternative & Indie', 'Alternative en Indie', 'Alternatif et Indé', 'Alternativ und Indie', 'Alternativa & Indie', 'Musica alternativa e indie'],
	['Ambient', 'Ambientes'],
	['Ambient/New Age', 'Ambient / New Age / Easy Listening', 'Ambiance', 'Musica d\'ambiente/New Age'],
	['Art Songs', 'Lieder', 'Kunstlieder'],
	['Art Songs, Mélodies & Lieder', 'Liederen', 'Mélodies & Lieder', 'Französische Mélodies und Kunstlieder'],
	['Asia', 'Azië', 'Asie', 'Asien'],
	['Ballets', 'Balletten', 'Ballett', 'Balletti'],
	['Bawdy songs', 'Schuine liedjes', 'Chansons paillardes', 'Canciones gamberras', 'Canzoni licenziose'],
	['Bebop', 'Be Bop'],
	['Blues'],
	['Blues/Country/Folk', 'Blues/country/folk'],
	['Bossa Nova & Brazil', 'Bossanova en Brazilië', 'Bossa Nova & Brésil', 'Bossa Nova & brasilianische Musik', 'Bossa nova & Brasil', 'Bossa nova e musica brasiliana'],
	['Cantatas (sacred)', 'Religieuze cantates', 'Cantates sacrées', 'Geistliche Kantaten', 'Cantatas sacras', 'Cantate sacre'],
	['Cantatas (secular)', 'Cantates (wereldlijk)', 'Cantates (profanes)', 'Kantaten (weltlich)', 'Cantatas (profanas)', 'Cantate (profane)'],
	['Cello Concertos', 'Concerten voor cello', 'Concertos pour violoncelle', 'Cellokonzerte', 'Conciertos para violonchelo', 'Concerti per violoncello'],
	['Cello Solos', 'Cello solo', 'Violoncelle solo', 'Cellosolo', 'Violonchelo solo', 'Assoli per violoncello'],
	['Celtic', 'Keltisch', 'Celtique', 'Keltische Musik', 'Celta', 'Musica celtica'],
	['Chamber Music', 'Kamermuziek', 'Musique de chambre', 'Kammermusik', 'Música de cámara', 'Musica da camera'],
	['Children', 'Kinderen', 'Enfants', 'Kinder'],
	['Chill-out'],
	['Choirs (sacred)', 'Religieuze koormuziek', 'Chœurs sacrés', 'Geistliche Chormusik', 'Coros sacros', 'Cori sacri'],
	['Choral Music (Choirs)', 'Koormuziek', 'Musique chorale (pour chœur)', 'Chorwerk (für den Chor)', 'Música coral (para coro)', 'Musica corale'],
	['Christmas Music', 'Kerstmuziek', 'Musiques de Noël', 'Weihnachtsmusik', 'Músicas navideñas', 'Canzoni di Natale'],
	['Cinema Music', 'Soundtrack', 'Musiques pour le cinéma', 'Filmmusik', 'Bandas sonoras', 'Musiche per il cinema'],
	['Classical', 'Klassiek', 'Classique', 'Klassik', 'Clásica', 'Classica'],
	['Concertos for trumpet', 'Concerten voor trompet', 'Concertos pour trompette', 'Trompetenkonzerte', 'Conciertos para trompeta', 'Concerti per tromba'],
	['Concertos for wind instruments', 'Concerten voor blaasinstrumenten', 'Concertos pour instruments à vent', 'BläserKonzerte', 'Conciertos para instrumentos de viento', 'Concerti per strumenti a fiato'],
	['Concertos', 'Concertmuziek', 'Musique concertante', 'Instrumentalmusik', 'Música concertante', 'Musica concertante'],
	['Contemporary Jazz', 'Moderne jazz', 'Jazz contemporain', 'Modern Jazz', 'Jazz contemporáneo', 'Jazz contemporaneo'],
	['Cool Jazz', 'Cooljazz', 'Cool jazz'],
	['Country'],
	['Crooners', 'Crooner', 'Musica crooner'],
	['Crossover'],
	['Dance'],
	['Dancehall'],
	['Disco'],
	['Dixieland', 'Dixie'],
	['Downtempo'],
	['Drum & Bass', 'Drum \'n\' bass'],
	['Dub'],
	['Duets', 'Duo´s', 'Duos', 'Duette', 'Dúos', 'Duetti'],
	['Dutch', 'Néerlandais', 'Niederländisch', 'Olandese'],
	['Eastern Europe', 'Oost-Europa', 'Europe de l\'Est', 'Osteuropa', 'Europa del Este', 'Europa dell\'est'],
	['Educational', 'Educatief', 'Educatif', 'Bildung'],
	['Electronic', 'Électronique', 'Electrónica', 'Elettronica', 'Elektronische muziek', 'Musique électronique', 'Elektronische Musik', 'Música electrónica', 'Musica elettronica'],
	['English', 'Anglais', 'Englisch', 'Inglese'],
	['Europe', 'Europa'],
	['Experimental', 'Elektronische muziek of Musique Concrète', 'Électronique ou concrète', 'Elektronische Musik oder Musique concrète', 'Electrónica o musique concrète', 'Musica elettronica/concreta'],
	['Fado'],
	['Film Soundtracks', 'Originele soundtracks', 'Bandes originales de films', 'Original Soundtrack', 'Bandas sonoras de cine'],
	['Flamenco'],
	['Folk', 'Folk/Americana'],
	['Free Jazz & Avant-Garde', 'Free jazz & Avant-garde jazz', 'Free jazz & Avant-garde', 'Free Jazz & Avantgarde', 'Free jazz & Vanguardia', 'Free jazz et jazz d\'avanguardia'],
	['French Artists', 'Zangers van Franse chansons', 'Interprètes de chanson française', 'Französische Chanson-Sänger', 'Intérpretes de chanson francesa', 'Artisti francesi'],
	['French Music', 'Franse chansons', 'Chanson française', 'Chanson francophone', 'Französischer Chanson', 'Chanson francesa', 'Musica francese'],
	['French Rock', 'Franse rock', 'Rock français', 'Französischer Rock', 'Rock francés', 'Rock francese'],
	['French', 'Français', 'Französisch', 'Francese'],
	['Full Operas', 'Volledige opera\'s', 'Intégrales d\'opéra', 'Gesamtaufnahmen von Opern', 'Integrales de ópera', 'Opere integrali'],
	['Funk'],
	['German', 'Allemand', 'Deutsch', 'Tedesco'],
	['Germany', 'Duitsland', 'Allemagne', 'Deutsche Musik', 'Alemania', 'Germania'],
	['Gospel'],
	['Greece', 'Griekenland', 'Grèce', 'Griechenland', 'Grecia'],
	['Gypsy Jazz', 'Gipsy jazz', 'Jazz manouche', 'Gypsy-Jazz'],
	['Gypsy', 'Zigeunermuziek', 'Gipsy', 'Musik der Roma', 'Gitano'],
	['Hard Rock', 'Hardrock', 'Hard rock'],
	['Hip-Hop/Rap', 'Rap/Hip-Hop'],
	['Historical Documents', 'Documents historiques', 'Historische Dokumente', 'Documenti storici'],
	['House'],
	['Humour', 'Humor', 'Umorismo'],
	['Indian Music', 'Indiase muziek', 'Musique indienne', 'Indische Musik', 'Música india', 'Musica indiana'],
	['Indie Pop', 'Indiepop', 'Pop indé', 'Indie-Pop', 'Pop indie', 'Indie pop'],
	['International Pop', 'Internationaal variété', 'Variété internationale', 'Internationaler Pop', 'Variété internacional', 'Pop internazionale'],
	['Ireland', 'Ierland', 'Irlande', 'Irland', 'Irlanda'],
	['Irish Celtic', 'Iers Keltisch', 'Irish celtic', 'Irisch-keltische Musik', 'Música celta irlandesa', 'Musica celtica irlandese'],
	['Irish Pop Music', 'Ierse popmuziek', 'Irish popmusic', 'Irische Popmusik', 'Música pop irlandesa', 'Musica pop irlandese'],
	['Italy', 'Italië', 'Italie', 'Italien', 'Italia', 'Canzone italiana'],
	['Jazz Fusion & Jazz Rock', 'Jazz fusion en jazz rock', 'Jazz fusion & Jazz rock', 'Jazz Fusion & Jazzrock', 'Jazz fusión & Jazz rock', 'Fusion & Jazz rock'],
	['Jazz'],
	['Karaoke', 'Karaoké'],
	['Keyboard Concertos', 'Concerten voor klavier', 'Concertos pour clavier', 'Klavierkonzerte', 'Conciertos para tecla', 'Concerti per tastiera'],
	['Latin America', 'Latin', 'Latijns-Amerika', 'Amérique latine', 'Lateinamerika', 'Latina'],
	['Latin Jazz', 'Latin jazz'],
	['Lieder (German)', 'Liederen (Duitsland)', 'Lieder (Allemagne)', 'Kunstlieder (Deutschland)', 'Lieder (Alemania)', 'Lieder (Germania)'],
	['Literature', 'Littérature', 'Literatur', 'Letteratura'],
	['Lounge'],
	['Maghreb', 'Noord-Afrika', 'Magreb'],
	['Masses, Passions, Requiems', 'Missen, passies, requiems', 'Messes, Passions, Requiems', 'Messen, Passionen, Requiems', 'Misas, Pasiones, Réquiems', 'Messe, Passioni, Requiem'],
	['Metal'],
	['Military Music', 'Militaire muziek', 'Musique militaire', 'Militärmusik', 'Música militar', 'Musica militare'],
	['Minimal Music', 'Minimalistische muziek', 'Musique minimaliste', 'Música minimalista', 'Musica minimalista'],
	['Music by vocal ensembles', 'Muziek voor vocale ensembles', 'Musique pour ensembles vocaux', 'Musik für Vokalensembles', 'Música para conjuntos vocales', 'Musica per insiemi vocali'],
	['Musical Theatre', 'Musicals', 'Comédies musicales', 'Musical', 'Comedias musicales'],
	['Musique Concrète', 'Musique concrète', 'Musique concréte', 'Musica concreta'],
	['Mélodies (England)', 'Liederen (Engeland)', 'Mélodies (Angleterre)', 'Mélodies (Inglaterra)', 'Mélodies (Inghilterra)'],
	['Mélodies (French)', 'Liederen (Frankrijk)', 'Mélodies (France)', 'Französische Mélodies (Frankreich)', 'Mélodies (Francia)'],
	['Mélodies (Northern Europe)', 'Liederen (Noord-Europa)', 'Mélodies (Europe du Nord)', 'Mélodies (Nordeuropa)', 'Mélodies (Europa del Norte)', 'Mélodies (Europa del nord)'],
	['Mélodies'],
	['New Age', 'New age', 'Musica new Age'],
	['North America', 'Noord-Amerika', 'Amérique du Nord', 'Nordamerika', 'Norteamérica', 'Amercia del nord'],
	['Opera Extracts', 'Operafragmenten', 'Extraits d\'opéra', 'Opernauszüge', 'Fragmentos de ópera', 'Estratti d\'opera'],
	['Opera', 'Opéra', 'Oper', 'Ópera'],
	['Operettas', 'Operette', 'Opérette', 'Opereta', 'Operetta'],
	['Oratorios (secular)', 'Wereldlijke oratoria', 'Oratorios profanes', 'Weltliche Oratorien', 'Oratorios profanos', 'Oratori profani'],
	['Oriental Music', 'Oosters', 'Orient', 'Oriente', 'Musica orientale'],
	['Overtures', 'Ouvertures', 'Ouvertüren', 'Oberturas', 'Overture'],
	['Pop'],
	['Pop/Rock'],
	['Portugal', 'Portogallo'],
	['Progressive Rock', 'Progressieve rock', 'Rock progressif', 'Rock progresivo', 'Rock progressivo'],
	['Punk / New Wave', 'Punk en New Wave', 'Punk - New Wave', 'Punk – New Wave', 'Punk/New wave'],
	['Pédagogie', 'Pädagogik', 'Musica educativa'],
	['Quartets', 'Kwartetten', 'Quatuors', 'Quartette', 'Cuartetos', 'Quartetti'],
	['Quintets', 'Kwintetten', 'Quintettes', 'Quintette', 'Quintetos', 'Quintetti'],
	['R&B'],
	['Ragtime'],
	['Raï'],
	['Reggae'],
	['Relaxation', 'Ontspanning', 'Entspannung', 'Relajación', 'Musica rilassante'],
	['Retro French Music', 'Oude Franse chansons', 'Chanson française rétro', 'Französisches Retro-Chanson', 'Chanson francesa retro', 'Musica francese retrò'],
	['Rock'],
	['Rockabilly'],
	['Russia', 'Rusland', 'Russie', 'Russland', 'Rusia'],
	['Sacred Oratorios', 'Oratorios sacrés', 'Geistliche Oratorien', 'Oratorios sacros', 'Oratori sacri'],
	['Sacred Vocal Music', 'Religieuze vocale muziek', 'Musique vocale sacrée', 'Geistliche Vokalmusik', 'Música vocal sacra', 'Musica vocale sacra'],
	['Salsa'],
	['Schlager'],
	['Scottish', 'Schotland', 'Ecosse', 'Schottland', 'Escocia', 'Scozia'],
	['Secular Vocal Music', 'Wereldlijke vocale muziek', 'Musique vocale profane', 'Weltliche Vokalmusik', 'Música vocal profana', 'Musica vocale profana'],
	['Ska & Rocksteady', 'Ska en Rocksteady', 'Ska e rocksteady'],
	['Solo Piano', 'Piano solo', 'Klaviersolo', 'Assoli per pianoforte'],
	['Soul'],
	['Soundtracks', 'Bandes originales', 'Colonne sonore'],
	['Spain', 'Spanje', 'Espagne', 'Spanien', 'España', 'Spagna'],
	[/*'Humour/Spoken Word', */'Spoken Word', 'Comedy/Other', 'Diction', 'Hörbücher'],
	['Stimmungsmusik'],
	['Stories and Nursery Rhymes', 'Sprookjes en vertellingen', 'Contes et comptines', 'Märchen und Kinderreime'],
	['Swiss Folk Music', 'Zwitserse volksmuziek', 'Musique folklorique Suisse', 'Schweizer Volksmusik', 'Música folclórica suiza', 'Musica folclorica svizzera'],
	['Symphonic Music', 'Symfonische muziek', 'Musique symphonique', 'Symphonieorchester', 'Música sinfónica', 'Musica sinfonica'],
	['Symphonic Poems', 'Symfonische gedichten', 'Poèmes symphoniques', 'Symphonische Dichtung', 'Poemas sinfónicos', 'Poemi sinfonici'],
	['Symphonies', 'Symfonieën', 'Symphonien', 'Sinfonías', 'Sinfonie'],
	['Tango'],
	['Techno'],
	['Theatre Music', 'Toneelmuziek', 'Musique de scène', 'Intermezzi', 'Música escénica', 'Musiche di scena'],
	['Traditional Jazz & New Orleans', 'Traditionele jazz en dixieland', 'Jazz traditionnel & New Orleans', 'Klassischer Jazz & New-Orleans-Jazz', 'Jazz tradicional & Nueva Orleans', 'Jazz tradizionale & New Orleans'],
	['Trance'],
	['Trios', 'Trio´s', 'Tríos', 'Trii'],
	['Trip Hop', 'Triphop'],
	['Turkey', 'Turkije', 'Turquie', 'Türkei', 'Turquía', 'Turchia'],
	['TV Series', 'Tv-series', 'Séries TV', 'TV-Serien', 'Series de televisión', 'Serie TV'],
	['Video Games', 'Videogames', 'Jeux vidéo', 'Computerspiele', 'Vídeojuegos', 'Video Giochi'],
	['Violin Concertos', 'Concerten voor viool', 'Concertos pour violon', 'Violinkonzerte', 'Conciertos para violín', 'Concerti per violino'],
	['Violin Solos', 'Viool solo', 'Violon solo', 'Violinensolo', 'Violín solo', 'Assoli per violino'],
	['Vocal Jazz', 'Vocale jazz', 'Jazz vocal', 'Jazzgesang', 'Vocal jazz'],
	['Vocal Music (Secular and Sacred)', 'Vocale muziek (wereldlijk en religieus)', 'Musique vocale (profane et sacrée)', 'Vokalmusik (weltlich und geistlich)', 'Música vocal (profana y sacra)', 'Musica vocale (sacra e profana)'],
	['Vocal Recitals', 'Vocale recitals', 'Récitals vocaux', 'Gesangsrezitale', 'Recitales vocales', 'Recital vocali'],
	['Volksmusik'],
	['World Music', 'World', 'Wereldmuziek', 'Musiques du monde', 'Aus aller Welt', 'World music'],
	['Yiddish & Klezmer', 'Jiddisch en klezmer', 'Jiddische Musik & Klezmer', 'Musica yiddish e klezmer'],
	['Zouk & Antilles', 'Zouk en Antilliaans', 'Zouk & Musik von den Antillen', 'Zouk & Antillas', 'Musica zouk e Antille'],
];

String.prototype.toASCII = function() {
	return this.normalize("NFKD").replace(/[\x00-\x1F\u0300-\u036F]/gu, '');
};

function qbGenreToEnglish(genre) {
	if (typeof genre != 'string') throw 'Invalid parameter';
	const gl = genre.toASCII().toLowerCase();
	const g = qobuzTranslations.find(g => Array.isArray(g) && g.some(g => gl == g.toASCII().toLowerCase()));
	return g != undefined ? g[0] : genre;
}

const qobuzArtistLabels = [
	/*  0 */ ['Main Artist', 'MainArtist', 'Primary Artist', 'Main'],
	/*  1 */ ['Associated Performer', 'AssociatedPerformer'],
	/*  2 */ ['Artist', 'Soloist'],
	/*  3 */ [
		'Vocal', 'Vocals', 'Vocalist', 'Solo Vocal', 'Vocal Solo', 'Singer', 'Interpreter', 'Intérprete',
		'Interprète Vocal', 'Lead Vocalist', 'LeadVocalist', 'Lead Vocals', 'LeadVocals',
		'Alto Solo',
	],
	/*  4 */ [
		'Orchestra', 'Ensemble', 'Chorus', 'Choir', 'Ensemble', 'Band', 'MusicalEnsemble',
		'Vocal Ensemble', 'Gospel Choir', 'Chamber Ensemble', 'Chamber Orchestra', 'ChamberMusicEnsemble',
		/*'Brass Ensemble', */'Instrumental Ensemble',
	],
	/*  5 */ ['Performer', 'PrimaryMusician', 'Musician'],
	/*  6 */ ['Voice', 'Spoken Word', 'Narrator', 'Speaker'],
	/*  7 */ ['Featured Artist', 'FeaturedArtist', 'Featuring Artist', 'Featured', 'Featuring'],
	/*  8 */ [
		'Accordion', 'Acoustic Bass Guitar', 'Acoustic Guitar', 'Acoustic Piano', 'AcousticGuitar', 'Adapter',
		'Additional Background Vocals', 'Additional Drums', 'Additional Keyboards', 'Additional Vocals',
		'African Percussion', 'All Instruments', 'Alto Clarinet',
		'Alto Flute', 'Alto Saxophone', 'Alto saxophone', 'Alto Viol', 'Alto', 'AltoVocals', 'Background Vocal',
		'Background Vocalist', 'Background Vocals', 'BackgroundVocals', 'Backing Vocals', 'Backing Vocals',
		'BackingVocals', 'Bagpipes', 'Bam', 'Banjo', 'Banjo', 'Baritone Saxophone', 'Baritone', 'Baritone',
		'BaritoneVocals', 'Bass Clarinet', 'Bass Guitar', 'Bass Saxophone', 'Bass Trombone', 'Bass Viol',
		'Bass', 'BassGuitar', 'Bassoon', 'BassVocals', 'Beuron', 'Bongos', 'Bouzouki', 'Brass', 'Cabasa', 'Cadenzor',
		'Cajon', 'Cello', 'Cembalo', 'Chamber Organ', 'Chant Vocals', 'Charango Guitar', 'Charig', 'Choir Master',
		'Chorus Conductor', 'Chorus Master', 'Clapping', 'Clarinet', 'Classical Guitar', 'Clavier', 'Clavinet',
		'Clipzy Beats', 'Concertina', 'Concertmaster', 'Conga', 'Congas', 'Contra Bassoon', 'Contrabass Recorder',
		'Contralto', 'Contributing Artist', 'Cornet', 'Countertenor', 'Crumhorn', 'Digital Piano', 'Dings', 'Dobro',
		'Double Bass', 'Double Bass', 'DoubleBass', 'Drum', 'Drums', 'Electric Bass', 'Electric Guitar',
		'Electric Sitar', 'ElectricGuitar', 'Electronic Percussion', 'English Horn', 'Falsettist', 'Featured Vocals',
		'Featuring Vocals', 'Fender Rhodes Keyboards', 'Fiddle', 'First Violin', 'Flauto Traverso', 'Fluegel Horn',
		'Fluegelhorn', 'Flugelhorn', 'Flute', 'Fortepiano', 'Fretless Bass', 'FretlessElectricBassGuitar',
		'Glockenspiel', 'Gold Line', 'Guitar', 'Hammond B3 Organ', 'Hammond B3', 'Hammond Organ', 'Handclaps',
		'Hannyphizzy', 'Harmonica', 'Harmonium', 'Harmony Vocals', 'HarmonyVocals', 'Harp', 'Harpsichord', 'Ho Keys',
		'Horn', 'Instruments', 'Interprète Instrumental', 'Kalimba', 'Keyboards', 'Kaval', 'Lead Guitar', 'Leader',
		'Live Drums', 'Lofti', 'Loops', 'Lute', 'Machine Drums', 'Maj', 'Mandolin', 'Maracas', 'Marimba', 'Mellotron',
		'Metal Cans', 'MezzoSoprano', 'MezzoSopranoVocals', 'Obeisvnce', 'Oboe', 'Orchestra Leader', 'Orchestrator',
		'Organ', 'Other instrument', 'Participant', 'Pedal Steel Guitar', 'Pedal Steel', 'Percussion', 'Performance',
		'Piano', 'Prepared Piano', 'Rap Vocalist', 'Recorder', 'Rhodes Piano', 'Rhodes', 'Rhythm Guitar', 'Sarangi',
		'Saw', 'Saxophone', 'Saxophones', 'Second Violin', 'Seshin', 'Set Drums', 'Shaker', 'Sitar', 'Skev Beats',
		'Slide Guitar', 'Sohn', 'Soprano Saxophone', 'Soprano', 'SopranoSolo', 'Sounds', 'Spinet', 'Steel Guitar',
		'SteelGuitar', 'String Quartet', 'Strings Conductor', 'Strings', 'StudioMusician', 'Stylophone', 'Synth Bass',
		'Synth Pads', 'Synth', 'Synthesizer', 'Tabla', 'Tambourine', 'Tambura', 'Tenor Saxophone', 'Tenor',
		'TenorSolo', 'Theorbo', 'Tibetan Bowl', 'Timbales', 'Timpani', 'Tonmeister', 'Translator', 'Trombone',
		'Trumpet', 'Ukulele', 'Upright Bass', 'UprightBass', 'Van', 'Vibraphone', 'Vielle', 'Viol', 'Viola da Gamba',
		'Viola', 'Violin Leader', 'Violin', 'Vocoder', 'Voices', 'Vvsronny', 'Whistle', 'Whistling', 'With Accordion',
		'With Vocals', 'Woodwinds', 'Woop', 'Wurlitzer', 'Zither',
		// New additions 21/07/18
		'Additional Piano', 'Additional Rap', 'Additional Synthesiser', 'Agogo Bells', 'Bandoneon', 'Baritone Guitar',
		'Baryton', 'Bass Pedals', 'Bass Tuba', 'Basset Horn', 'Bells', 'Cello Continuo', 'Claps', 'Cuica', 'Cymbals',
		'Electric Violin', 'Fender Rhodes Piano', 'Flamenco Guitar', 'Foreign Instruments', 'French Horn', //'Group',
		'Guest Vocals', 'Guitarron', 'Kettledrums', 'Lap Steel Guitar', 'Microkorg Synthesizer', 'Moog', 'Moog Bass',
		'Mandola', 'Noises', 'Piano Concerto', 'Piccolo', 'Sampler', 'Snare Drum', 'Tenor Guitar', 'Triangle', 'Tuba',
		'Violoncello', 'WillBass', 'Wurlitzer Electric Piano', 'Wurlitzer Organ',
		// New additions 21/07/21
		'Additional Backing Vocals', 'Additional Percussion', 'Bass Synthesizer', 'Bass Vocal', 'Brass Ensemble',
		'Brush Drums', 'Celesta', 'Clavichord', 'Contrabass', 'Electric Bass Guitar', 'Featured Drums',
		'Featured Guitar', 'Fender Bass', 'Guitarra', 'Piano Duet', 'Tenor Horn', 'Viella',
		// New additions 21/07/24
		'257ers', 'Aerophones', 'Bansuri', 'Been', 'Coro e Orchestra Sinfonici', 'Coro', 'Dumbeq', 'Euphonium',
		'Guiro', 'Hambone', 'Ney', 'Reeds', 'Revale', 'Synclavier', 'Tabor', 'Talkbox', 'Xylophone',
		'Classical Artist', 'Rap', 'Featured Percussion',
		// New additions 21/05/20
		'DJ',
],
	/*  9 */ ['Composer', 'Composed By', 'Author'],
	/* 10 */ ['Conductor', 'Conducted By'],
	/* 11 */ ['Remixer', 'Remixed By', 'Remix'],
	/* 12 */ ['Producer', 'Produced By', 'Music Producer', 'Music Production'],
	/* 13 */ ['Arranger', 'Arranged By', 'MusicArranger'],
	/* 14 */ ['Compiler', 'Compiled By'/*, 'D J'*/],
	/* 15 */ [
		'Author', 'Composer Lyricist', 'ComposerLyricist', 'Created By', 'Librettist', 'Lyricist',
		'NonLyricAuthor', 'Original Text Author', 'Songwriter', 'SubLyricist', 'Writer', 'Written By',
	],
	/* 16 */ [ // all other roles
		'A&R Admin', 'A&R', 'AAndRAdministrator', 'AAndRCoordinator', 'Actor', 'Additional Arrangement by',
		'Additional Editor', 'Additional Guitar', 'Additional Producer', 'Additional Production',
		'Additional Programmer', 'Additional Recording', 'AdditionalEngineer', 'AdditionalMixingEngineer',
		'AdditionalStudioProducer', 'Assistant Conductor', 'Assistant Engineer', 'Assistant Masterer',
		'Assistant Mastering Engineer', 'Assistant Mix Engineer', 'Assistant Mixer', 'Assistant Mixing Engineer',
		'Assistant Producer', 'Assistant Production', 'Assistant Recording Engineer',
		'Assistant Vocal Recording Engineer', 'AssistantEngineer',
		'AssistantProducer', 'Associate Executive Producer', 'Associate Producer', 'Associated Producer',
		'AssociatedProducer', 'AssociateProducer', 'Audio Mastering', 'Audio Recording Engineer', 'Balance Engineer',
		'BalanceEngineer', 'Bass Programming', 'Chorus Director', 'Co-Producer', 'CoMixer', 'CoMixingEngineer',
		'Computer Programming', 'Conceptor', 'Contracting With', 'Contractor', 'Contributor', 'CoProducer',
		'Cover Artist', 'Digital Editor', 'DigitalEditingEngineer', 'Director', 'Drum Machine',
		'Drum Programmer', 'Drum Programming', 'Editor', 'Engineer', 'Executive Producer', 'ExecutiveProducer',
		'Film Company', 'FilmDirector', 'FilmProducer', 'FilmSoundEngineer', 'Graphic Artist', 'GraphicArtist',
		'Horn Arranger', 'Horns Arranger', 'MakeUpArtist', 'Manager', 'Masterer', 'Mastering Engineer', 'Mastering',
		'MasteringEngineer', 'MasteringSecondEngineer', 'Mix Engineer', 'Mixer', 'Mixing Engineer',
		'MixingEngineer', 'Music Director', 'Music Director & Conductor', 'Musical Director', 'MusicCopyist',
		'MusicDirector', 'MusicPublisher', 'Orchestra Contractor', 'OriginalPublisher', 'Other',
		'Percussion Recording Engineer', 'Performance Arranger', 'Photographer', 'Post Producer',
		'Production Company', 'Production Coordinator', 'ProductionAssistant', 'ProductionCoordinator',
		'ProductionManager', 'Programmer', 'Programming', 'Project Coordinator', 'Recorded by',
		'Recording Arranger', 'Recording Artist', 'Recording Assistant', 'Recording Engineer', 'Recording Producer',
		'Recording producer', 'Recording Supervisor', 'Recording', 'RecordingEngineer', 'Remix Engineer',
		'Rhythm Programming', 'Samples', 'Sound Design', 'Sound Editor', 'Sound Effects', 'Sound Engineer',
		'Sound Supervisor', 'SoundEngineer', 'SoundRecordist', 'Stage Assistant Engineer', 'Stage Director',
		'StageDirector', 'String Arranger', 'Studio Personnel', 'Studio', 'StudioPersonnel', 'StudioProducer',
		'Synthesizer Arranger', 'Synthesizer Programming', 'Test', 'Unknown', 'Video Director', 'Video Producer',
		'Vocal Arranger', 'Vocal Engineer', 'Vocal Mix', 'Vocal Producer', 'Vocal Production', 'Vocal Programming',
		'VocalAdaptation', 'VocalProducer', 'Wind Controller', 'Work Arranger', 'WriterOfAccompanyingMaterial',
		// New additions 21/07/18
		'Additional Mixer', 'Additional Vocal Recording Engineer', 'Artwork By', 'Artwork Title',
		'Choir Arranger', 'CompilationProducer', 'DirectStreamDigitalEngineer', 'Front Cover Photographer',
		'Instrumentation', 'MixingSecondEngineer', 'Music Supervisor', 'Overdub Engineer', 'Post Production',
		'Principal Director of Music', 'Pro Tools', 'Production', 'ProjectEngineer', 'RecordingSecondEngineer',
		'ReissueProducer', 'RemixingEngineer', 'Rhythm Arranger', 'Sound Design Designer', 'Sound Harmonics',
		'SoundDesigner', 'Strings Contractor', 'Studio Wildcard', 'Transcriber', 'Turntablist', 'Video Editor',
		'Vocal Editing', 'instrumentalist', 'Recording Engineer', 'Visual Editor',
		// New additions 21/07/21
		'Cover Designer', 'ArtistVocalEngineer', 'Assistant Additional Recording Engineer', 'Assistant Editor',
		'Audio Concept', 'Bass Programmer', 'Cinematographer', 'Coordinator', 'Director Of Photography',
		'Drop Station', 'Drum Technician', 'Drums Effects', 'Executive Director', 'Guitar Loops',
		'Guitar Technician', 'Interjections', 'MIDI Programming', 'PhotographyDirector', 'Sequencer', 'SoundMixer',
		'Spoons Percussion', 'StringProducer', 'Strings Director', 'TrackingEngineer', 'TrackingSecondEngineer',
		'Vocal Recording Engineer', 'VocalEditingEngineer', 'Graphic Designer', 'Keyboards Programming',
		// New additions 21/07/24
		'Illustrator', 'Music', 'Original Production Producer', 'PreProduction',
		'Revision', 'Studio Engineer',
	],
];

const qbRoleNormalizer = role => role.toASCII().replace(/[\W\_]+/g, '').toLowerCase();

function qbGetCategoryIndex(role, silent = false) {
	if (role) var result = qbRoleNormalizer(role); else return -1;
	result = qobuzArtistLabels.findIndex(roles => roles.map(qbRoleNormalizer).includes(result));
	if (result < 0 && !silent) console.log('qbGetCategoryIndex() uncategorized role:', role);
	return result;
}


//////////////////////////////////////////////////////////////////////////
////////////////////////////// SAFE PADDING //////////////////////////////
//////////////////////////////////////////////////////////////////////////