export type ParsedFilename = {
	title: string;
	year: number;
};

export class MovieNamings {
	parseFilename(filename: string): ParsedFilename | null {
		const match = filename.trim().match(/^(?<title>.+?)\s*\((?<year>\d{4})\)/);
		if (!match || !match.groups) {
			return null;
		}

		const title = match.groups.title.trim();
		const year = Number.parseInt(match.groups.year, 10);
		if (Number.isNaN(year)) {
			return null;
		}

		return { title, year };
	}
}
