play listing sends the promo video URL (play.video)
This commit is contained in:
parent
2914f04129
commit
6470c486f6
1 changed files with 11 additions and 3 deletions
|
|
@ -1,7 +1,9 @@
|
||||||
// Play store listing text + app details in one edit.
|
// Play store listing text + app details in one edit.
|
||||||
// storebound play listing [--dry] [--only en-US,de-DE]
|
// 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).
|
// App details: default language, contact email, website (must be the domain that serves app-ads.txt).
|
||||||
// Listings: title, short and full description of every `<!-- play: ... -->` section of the listing file.
|
// Listings: title, short and full description of every `<!-- play: ... -->` 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 { readFileSync } from 'node:fs';
|
||||||
import { parsePlayListing } from '../lib/copy';
|
import { parsePlayListing } from '../lib/copy';
|
||||||
import type { Ctx } from '../lib/ctx';
|
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));
|
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<string, string> {
|
||||||
|
return { language: c.lang, title: c.title, shortDescription: c.short, fullDescription: c.full, ...(video ? { video } : {}) };
|
||||||
|
}
|
||||||
|
|
||||||
export async function run(ctx: Ctx): Promise<void> {
|
export async function run(ctx: Ctx): Promise<void> {
|
||||||
const { config, root } = ctx.loaded;
|
const { config, root } = ctx.loaded;
|
||||||
const pkg = need(config.play?.packageName, 'play.packageName');
|
const pkg = need(config.play?.packageName, 'play.packageName');
|
||||||
const copy = readPlayCopy(ctx);
|
const copy = readPlayCopy(ctx);
|
||||||
const details = { defaultLanguage: config.play?.defaultLanguage ?? 'en-US', contactEmail: config.app.contactEmail, contactWebsite: config.app.website };
|
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}`);
|
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);
|
const play = await playClient(root, pkg);
|
||||||
await play.edit(async id => {
|
await play.edit(async id => {
|
||||||
await play.call('PUT', `${play.API}/edits/${id}/details`, details);
|
await play.call('PUT', `${play.API}/edits/${id}/details`, details);
|
||||||
log('play', `details: ${details.defaultLanguage} · ${details.contactEmail} · ${details.contactWebsite}`);
|
log('play', `details: ${details.defaultLanguage} · ${details.contactEmail} · ${details.contactWebsite}`);
|
||||||
for (const [i, c] of copy.entries()) {
|
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));
|
log('play', step(i + 1, copy.length, c.lang));
|
||||||
}
|
}
|
||||||
}, { dry: ctx.args.has('dry') });
|
}, { dry: ctx.args.has('dry') });
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue