Files
youtube-generator/src/engine/title-variants.ts
T
poli0981andClaude Opus 5.5 3c985a07d6 feat(editor): quick start, next part, store links pasted anywhere, more stores and platforms
Editor:
- Quick start at the top: pick the channel profile and the game preset
  (remembered per device); replacing fields that hold something else asks
  first, everything offers Undo; "Update profile / preset" appears when the
  editor drifts from the one in use.
- Next part (number + 1) and New video (same game) clear what belonged to
  the last video: boss, timestamps, endings, pinned comment, sponsor…
  Applying a preset for another game or a template does the same first.
- Start over replaces Clear Draft and keeps the channel (profile fields);
  a new draft starts in the Default Output Language (it was always "en").
- A store link pasted anywhere — the page, the Game name field, another
  store's field — lands in the right store field, sets the platform for a
  game's first link and names the game from it (Roman numerals and
  well-known possessives restored: "Final Fantasy VII", "Baldur's Gate 3").
  Steam links keep their name slug and drop tracking parameters.
- Game-name suggestions from presets and history.

Catalogs:
- Stores: EA app, Ubisoft, Battle.net, Google Play, App Store, Meta Quest.
- Social: YouTube, Threads, Kick, Reddit, Bilibili; "X (Twitter)" with the
  X mark; threads.net and youtu.be links accepted.
- Cross-posting: YouTube Shorts, X (counted the way X counts — CJK,
  Vietnamese letters with diacritics and emoji count twice), Threads (one
  topic tag), Bluesky; hashtag caps per platform.
- Banks: MBV, VCBNeo, Vikki Bank (renamed OceanBank, CBBank, DongA Bank —
  saved old names get a one-click switch), Cake by VPBank, Timo.

Output:
- An empty channel name no longer leaves "…of Hades on ." — the channel
  phrase is dropped per language (8 locales, every template tested).
- Title alternatives are real title shapes with the user's separator and
  badge case; "Use this shape" sets them (new Title order setting:
  game first / video first); over-long ones can't be copied.
- Copy All can include the tags (setting); Batch picks Part or Demo part
  and continues from the editor's part number; Ctrl/Cmd+S saves the
  output to History.
- Social editor headings and hints translated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 22:29:44 +07:00

48 lines
1.9 KiB
TypeScript

import type { GeneratorInput, TitleBadgePosition, TitleOrder, TranslationFn } from "./types";
import { buildTitle, type BuildTitleOptions } from "./title-builder";
type TitleVariantId = "default" | "typeFirst" | "qualityFirst";
export interface TitleVariant {
id: TitleVariantId;
/** i18n key under `output.variants.*`. */
labelKey: string;
title: string;
/** The title format that produces this variant — what "Apply" saves. */
format: { order: TitleOrder; badgePosition: TitleBadgePosition };
}
const SHAPES: ReadonlyArray<{ id: TitleVariantId; format: TitleVariant["format"] }> = [
{ id: "default", format: { order: "gameFirst", badgePosition: "middle" } },
{ id: "typeFirst", format: { order: "typeFirst", badgePosition: "middle" } },
{ id: "qualityFirst", format: { order: "gameFirst", badgePosition: "prefix" } },
];
/**
* Three alternative title shapes so a creator can A/B test the same video.
* Each is the real title builder with a different order / badge position —
* the user's separator and badge case still apply — so applying one makes
* the Output title identical to what was shown here.
*
* - default: Game — Type [2K 60FPS] — Gameplay No Commentary
* - typeFirst: Type — Game [2K 60FPS] — Gameplay No Commentary
* - qualityFirst: [2K 60FPS] Game — Type — Gameplay No Commentary
*
* Without a badge (1080p 60fps, or the badge turned off) `qualityFirst`
* reads exactly like the default.
*/
export function buildTitleVariants(
input: GeneratorInput,
t: TranslationFn,
options: BuildTitleOptions | boolean = true,
): TitleVariant[] {
const base: BuildTitleOptions =
typeof options === "boolean" ? { showQualityBadge: options } : options;
return SHAPES.map(({ id, format }) => ({
id,
labelKey: `output.variants.${id}`,
title: buildTitle(input, t, { ...base, ...format }),
format,
}));
}