diff --git a/cli/play/listing.ts b/cli/play/listing.ts index 1adec5b7..f291b7ce 100644 --- a/cli/play/listing.ts +++ b/cli/play/listing.ts @@ -1,7 +1,9 @@ // Play store listing text + app details in one edit. // storebound play listing [--dry] [--only en-US,de-DE] // App details: default language, contact email, website (must be the domain that serves app-ads.txt). -// Listings: title, short and full description of every `` section of the listing file. +// Listings: title, short and full description of every `` section of the listing file, plus the promo +// video (play.video, a YouTube URL) on every language. Play has no video upload: make the video with +// `storebound shots video --target youtube`, upload it to YouTube (public or unlisted, ads off, embeddable), paste the URL. import { readFileSync } from 'node:fs'; import { parsePlayListing } from '../lib/copy'; import type { Ctx } from '../lib/ctx'; @@ -16,19 +18,25 @@ export function readPlayCopy(ctx: Ctx) { return parsePlayListing(readFileSync(file, 'utf8'), config.app.name).filter(c => !only.length || only.includes(c.lang)); } +/** Body of one Play listing PUT. The PUT replaces the whole listing, so a promo video set in Play Console is cleared + * unless its URL is in play.video. Pure. */ +export function listingBody(c: { lang: string; title: string; short: string; full: string }, video?: string): Record { + return { language: c.lang, title: c.title, shortDescription: c.short, fullDescription: c.full, ...(video ? { video } : {}) }; +} + export async function run(ctx: Ctx): Promise { const { config, root } = ctx.loaded; const pkg = need(config.play?.packageName, 'play.packageName'); const copy = readPlayCopy(ctx); const details = { defaultLanguage: config.play?.defaultLanguage ?? 'en-US', contactEmail: config.app.contactEmail, contactWebsite: config.app.website }; if (!copy.some(c => c.lang === details.defaultLanguage) && !ctx.args.has('only')) throw new Error(`listing has no section for the default language ${details.defaultLanguage}`); - log('play', `${copy.length} listings: ${copy.map(c => c.lang).join(', ')}`); + log('play', `${copy.length} listings: ${copy.map(c => c.lang).join(', ')}${config.play?.video ? ` · promo video ${config.play.video}` : ''}`); const play = await playClient(root, pkg); await play.edit(async id => { await play.call('PUT', `${play.API}/edits/${id}/details`, details); log('play', `details: ${details.defaultLanguage} · ${details.contactEmail} · ${details.contactWebsite}`); for (const [i, c] of copy.entries()) { - await play.call('PUT', `${play.API}/edits/${id}/listings/${c.lang}`, { language: c.lang, title: c.title, shortDescription: c.short, fullDescription: c.full }); + await play.call('PUT', `${play.API}/edits/${id}/listings/${c.lang}`, listingBody(c, config.play?.video)); log('play', step(i + 1, copy.length, c.lang)); } }, { dry: ctx.args.has('dry') });