build 6, watchdog
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Upload the Google Play store listing (texts + graphics) from store/metadata.json.
|
||||
|
||||
python3 store/upload_play_listing.py <work> [--locales en-US hu ...] [--texts-only]
|
||||
[--website URL] [--email ADDRESS]
|
||||
|
||||
<work> is the folder used by make_screenshots.mjs and make_play_graphics.py:
|
||||
<work>/<locale>/play/0N-*.png (1440×2560 phone screenshots),
|
||||
<work>/<locale>/play/feature.png (1024×500) and <work>/play-icon.png (512×512).
|
||||
Re-running replaces the texts and images of the uploaded languages.
|
||||
"""
|
||||
import argparse
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / 'scripts'))
|
||||
from gplay_api import PLAY_LANG, UPLOAD, Gplay # noqa: E402
|
||||
|
||||
HERE = Path(__file__).resolve().parent
|
||||
TITLE = 'SkyContour'
|
||||
|
||||
|
||||
def upload_image(g, edit, lang, kind, path):
|
||||
g.call('POST', f'/edits/{edit}/listings/{lang}/{kind}?uploadType=media', data=path.read_bytes(),
|
||||
content_type='image/png', base=UPLOAD)
|
||||
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument('work')
|
||||
ap.add_argument('--locales', nargs='*')
|
||||
ap.add_argument('--texts-only', action='store_true')
|
||||
ap.add_argument('--website', default='https://sagifer.github.io/appdocuments/skycontour/support.html')
|
||||
ap.add_argument('--email', default='sagiferdev@gmail.com', help='public contact address on the listing')
|
||||
args = ap.parse_args()
|
||||
|
||||
meta = json.loads((HERE / 'metadata.json').read_text())
|
||||
locales = args.locales or [k for k in meta if not k.startswith('_')]
|
||||
work = Path(args.work)
|
||||
if not args.texts_only: # check every file before touching the listing
|
||||
need = [work / 'play-icon.png'] + [work / l / 'play/feature.png' for l in locales]
|
||||
missing = [str(p) for p in need if not p.exists()]
|
||||
missing += [l for l in locales if len(sorted((work / l / 'play').glob('0*.png'))) < 2]
|
||||
if missing:
|
||||
sys.exit(f'missing graphics: {missing}')
|
||||
|
||||
g = Gplay()
|
||||
edit = g.edit()
|
||||
try:
|
||||
g.call('PATCH', f'/edits/{edit}/details',
|
||||
{'defaultLanguage': 'en-US', 'contactWebsite': args.website, 'contactEmail': args.email})
|
||||
for locale in locales:
|
||||
m, lang = meta[locale], PLAY_LANG[locale]
|
||||
g.call('PUT', f'/edits/{edit}/listings/{lang}',
|
||||
{'language': lang, 'title': TITLE,
|
||||
'shortDescription': m['playShortDescription'], 'fullDescription': m['description']})
|
||||
line = f'{lang}: texts'
|
||||
if not args.texts_only:
|
||||
play = work / locale / 'play'
|
||||
for kind in ('icon', 'featureGraphic', 'phoneScreenshots'):
|
||||
g.call('DELETE', f'/edits/{edit}/listings/{lang}/{kind}')
|
||||
upload_image(g, edit, lang, 'icon', work / 'play-icon.png')
|
||||
upload_image(g, edit, lang, 'featureGraphic', play / 'feature.png')
|
||||
shots = sorted(play.glob('0*.png'))
|
||||
for s in shots:
|
||||
upload_image(g, edit, lang, 'phoneScreenshots', s)
|
||||
line += f', icon, feature graphic, {len(shots)} screenshots'
|
||||
print(line)
|
||||
g.commit(edit)
|
||||
except BaseException:
|
||||
g.discard(edit)
|
||||
raise
|
||||
print('committed')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user