Skip to content

Commit 45c756a

Browse files
authored
Merge pull request #2126 from Websoft9/feature/appstore-publish-migration
fix
2 parents 0f3d422 + 5a2dfa3 commit 45c756a

2 files changed

Lines changed: 36 additions & 21 deletions

File tree

.github/workflows/appstore-publish.yml

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -84,27 +84,7 @@ jobs:
8484
- name: Download legacy screenshots from Contentful
8585
run: |
8686
mkdir -p dist/catalog-source/screenshots
87-
for f in dist/catalog-source/product_*.json; do
88-
[ -f "$f" ] && python3 -c "
89-
import json, sys, urllib.request, os
90-
with open('$f') as fh:
91-
data = json.load(fh)
92-
urls = set()
93-
for item in data:
94-
for s in item.get('screenshots', []):
95-
u = s.get('value') or s.get('imageurl')
96-
if u: urls.add(u)
97-
for u in sorted(urls):
98-
try:
99-
name = u.rsplit('/', 1)[-1].split('?')[0]
100-
if '.' not in name: name = f'{hash(u) & 0xFFFFFFFFFFFF:012x}.png'
101-
path = os.path.join('dist/catalog-source/screenshots', name)
102-
if not os.path.exists(path):
103-
urllib.request.urlretrieve(u, path)
104-
except Exception as e:
105-
print(f'Warning: screenshot {u}: {e}', file=sys.stderr)
106-
"
107-
done
87+
python3 build/download_screenshots.py dist/catalog-source/screenshots
10888
10989
- name: Check if first v2 publish (R2 apps/ prefix empty)
11090
id: check_seed

build/download_screenshots.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env python3
2+
"""Download legacy screenshots from Contentful product JSON URLs."""
3+
import json
4+
import os
5+
import sys
6+
import urllib.request
7+
from pathlib import Path
8+
9+
OUTPUT_DIR = Path(sys.argv[1]) if len(sys.argv) > 1 else Path("dist/catalog-source/screenshots")
10+
OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
11+
12+
for product_file in sorted(Path("dist/catalog-source").glob("product_*.json")):
13+
if not product_file.exists():
14+
continue
15+
with open(product_file, encoding="utf-8") as fh:
16+
data = json.load(fh)
17+
18+
urls = set()
19+
for item in data:
20+
for s in item.get("screenshots", []):
21+
u = s.get("value") or s.get("imageurl")
22+
if u:
23+
urls.add(u)
24+
25+
for url in sorted(urls):
26+
try:
27+
name = url.rsplit("/", 1)[-1].split("?")[0]
28+
if "." not in name:
29+
name = f"{abs(hash(url)):012x}.png"
30+
path = OUTPUT_DIR / name
31+
if not path.exists():
32+
print(f"Downloading: {url}", file=sys.stderr)
33+
urllib.request.urlretrieve(url, path)
34+
except Exception as exc:
35+
print(f"Warning: screenshot {url}: {exc}", file=sys.stderr)

0 commit comments

Comments
 (0)