Files
movie-advisor/data/parsers/tlk/aliases.ts
T

23 lines
867 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Toloka release names often carry the original (romanized) title instead of the English one,
// so "attack on titan" does not match "Shingeki no Kyojin (Season 1) ...". Keys are normalized
// TMDB titles (lowercase, straight apostrophes folded to U+2019, no trailing year/period); values
// are the queries to additionally run against Toloka.
const ALIASES: Record<string, string> = {
'attack on titan': 'shingeki no kyojin',
'fire force': 'enen no shouboutai',
'howl’s moving castle': 'ugoku shiro',
'princess mononoke': 'mononoke hime',
'spirited away': 'sen to chihiro',
'your name': 'kimi no na wa'
};
export const normalizeQuery = (query: string) =>
query
.toLowerCase()
.replace(/'/g, '’')
.replace(/\s\d{4}$/, '')
.replace(/\.$/, '')
.trim();
export const aliasFor = (query: string) => ALIASES[normalizeQuery(query)];