chiark / gitweb /
include graphics and screenshots from repo in V1 index
authorHans-Christoph Steiner <hans@eds.org>
Tue, 6 Dec 2016 12:32:34 +0000 (13:32 +0100)
committerHans-Christoph Steiner <hans@eds.org>
Fri, 17 Mar 2017 12:55:40 +0000 (13:55 +0100)
If the repo has store graphics and/or screenshots, then include those in
the metadata.  This follows the possible graphics for Google Play, and the
file naming scheme of the open source 'fastlane' tool for managing those
files.

https://github.com/fastlane/fastlane/blob/1.109.0/supply/README.md#images-and-screenshots
https://support.google.com/googleplay/android-developer/answer/1078870?
https://android-developers.blogspot.com/2011/10/android-market-featured-image.html

Signed-off-by: Hans-Christoph Steiner <hans@eds.org>
30 files changed:
fdroidserver/update.py
tests/repo/obb.mainpatch.current/en-US/featureGraphic.png [new file with mode: 0644]
tests/repo/obb.mainpatch.current/en-US/icon.png [new file with mode: 0644]
tests/repo/obb.mainpatch.current/en-US/phoneScreenshots/screenshot-main.png [new file with mode: 0644]
tests/repo/obb.mainpatch.current/en-US/sevenInchScreenshots/screenshot-tablet-main.png [new file with mode: 0644]
tests/repo/org.videolan.vlc/en-US/icon.png [new file with mode: 0644]
tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot10.png [new file with mode: 0644]
tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot12.png [new file with mode: 0644]
tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot15.png [new file with mode: 0644]
tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot18.png [new file with mode: 0644]
tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot20.png [new file with mode: 0644]
tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot22.png [new file with mode: 0644]
tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot4.png [new file with mode: 0644]
tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot7.png [new file with mode: 0644]
tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot9.png [new file with mode: 0644]
tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot0.png [new file with mode: 0644]
tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot1.png [new file with mode: 0644]
tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot11.png [new file with mode: 0644]
tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot13.png [new file with mode: 0644]
tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot14.png [new file with mode: 0644]
tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot16.png [new file with mode: 0644]
tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot17.png [new file with mode: 0644]
tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot19.png [new file with mode: 0644]
tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot2.png [new file with mode: 0644]
tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot21.png [new file with mode: 0644]
tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot23.png [new file with mode: 0644]
tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot3.png [new file with mode: 0644]
tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot5.png [new file with mode: 0644]
tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot6.png [new file with mode: 0644]
tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot8.png [new file with mode: 0644]

index 05a11678934d39eece5090a6c10bbad3e257eace..e2c157b21c44d2dd95ce9316b6c838666fce0ae3 100644 (file)
@@ -494,6 +494,7 @@ def insert_obbs(repodir, apps, apks):
 
     obbs = []
     java_Integer_MIN_VALUE = -pow(2, 31)
+    currentPackageNames = apps.keys()
     for f in glob.glob(os.path.join(repodir, '*.obb')):
         obbfile = os.path.basename(f)
         # obbfile looks like: [main|patch].<expansion-version>.<package-name>.obb
@@ -508,7 +509,7 @@ def insert_obbs(repodir, apps, apks):
         packagename = ".".join(chunks[2:-1])
 
         highestVersionCode = java_Integer_MIN_VALUE
-        if packagename not in apps.keys():
+        if packagename not in currentPackageNames:
             obbWarnDelete(f, "OBB's packagename does not match a supported APK: ")
             continue
         for apk in apks:
@@ -534,6 +535,65 @@ def insert_obbs(repodir, apps, apks):
                 break
 
 
+def insert_graphics(repodir, apps):
+    """Scans for screenshot PNG files in statically defined screenshots
+    directory and adds them to the app metadata.  The screenshots and
+    graphic must be PNG or JPEG files ending with ".png", ".jpg", or ".jpeg"
+    and must be in the following layout:
+
+    repo/packageName/locale/featureGraphic.png
+    repo/packageName/locale/phoneScreenshots/1.png
+    repo/packageName/locale/phoneScreenshots/2.png
+
+    Where "packageName" is the app's packageName and "locale" is the locale
+    of the graphics, e.g. what language they are in, using the IETF RFC5646
+    format (en-US, fr-CA, es-MX, etc).  This is following this pattern:
+    https://github.com/fastlane/fastlane/blob/1.109.0/supply/README.md#images-and-screenshots
+
+    :param repodir: repo directory to scan
+
+    """
+
+
+    repofiles = sorted(glob.glob(os.path.join('repo', '[A-Za-z]*', '[a-z][a-z][A-Z-.@]*')))
+    for d in repofiles:
+        if not os.path.isdir(d):
+            continue
+        for f in sorted(glob.glob(os.path.join(d, '*.*')) + glob.glob(os.path.join(d, '*Screenshots', '*.*'))):
+            if not os.path.isfile(f):
+                continue
+            segments = f.split('/')
+            packageName = segments[1]
+            locale = segments[2]
+            screenshotdir = segments[3]
+            filename = os.path.basename(f)
+            base, extension = common.get_extension(filename)
+
+            if packageName not in apps:
+                apps[packageName] = metadata.App()
+            if 'localized' not in apps[packageName]:
+                apps[packageName]['localized'] = collections.OrderedDict()
+            if locale not in apps[packageName]['localized']:
+                apps[packageName]['localized'][locale] = collections.OrderedDict()
+            graphics = apps[packageName]['localized'][locale]
+
+            if extension not in ('png', 'jpg', 'jpeg'):
+                logging.warning('Only PNG and JPEG are supported for graphics, found: ' + f)
+            elif base in ('icon', 'tvBanner', 'promoGraphic', 'featureGraphic'):
+                # there can only be zero or one of these per locale
+                graphics[base] = filename
+            elif screenshotdir in ('phoneScreenshots', 'sevenInchScreenshots',
+                                   'tenInchScreenshots', 'tvScreenshots',
+                                   'wearScreenshots'):
+                # there can any number of these per locale
+                logging.debug('adding ' + base + ':' + f)
+                if screenshotdir not in graphics:
+                    graphics[screenshotdir] = []
+                graphics[screenshotdir].append(filename)
+            else:
+                logging.warning('Unsupported graphics file found: ' + f)
+
+
 def scan_repo_files(apkcache, repodir, knownapks, use_date_from_file=False):
     """Scan a repo for all files with an extension except APK/OBB
 
@@ -1808,6 +1868,7 @@ def main():
         apps = metadata.read_metadata()
 
     insert_obbs(repodirs[0], apps, apks)
+    insert_graphics(repodirs[0], apps)
 
     # Scan the archive repo for apks as well
     if len(repodirs) > 1:
diff --git a/tests/repo/obb.mainpatch.current/en-US/featureGraphic.png b/tests/repo/obb.mainpatch.current/en-US/featureGraphic.png
new file mode 100644 (file)
index 0000000..656e749
Binary files /dev/null and b/tests/repo/obb.mainpatch.current/en-US/featureGraphic.png differ
diff --git a/tests/repo/obb.mainpatch.current/en-US/icon.png b/tests/repo/obb.mainpatch.current/en-US/icon.png
new file mode 100644 (file)
index 0000000..4a42916
Binary files /dev/null and b/tests/repo/obb.mainpatch.current/en-US/icon.png differ
diff --git a/tests/repo/obb.mainpatch.current/en-US/phoneScreenshots/screenshot-main.png b/tests/repo/obb.mainpatch.current/en-US/phoneScreenshots/screenshot-main.png
new file mode 100644 (file)
index 0000000..39b0ac1
Binary files /dev/null and b/tests/repo/obb.mainpatch.current/en-US/phoneScreenshots/screenshot-main.png differ
diff --git a/tests/repo/obb.mainpatch.current/en-US/sevenInchScreenshots/screenshot-tablet-main.png b/tests/repo/obb.mainpatch.current/en-US/sevenInchScreenshots/screenshot-tablet-main.png
new file mode 100644 (file)
index 0000000..00ce9d0
Binary files /dev/null and b/tests/repo/obb.mainpatch.current/en-US/sevenInchScreenshots/screenshot-tablet-main.png differ
diff --git a/tests/repo/org.videolan.vlc/en-US/icon.png b/tests/repo/org.videolan.vlc/en-US/icon.png
new file mode 100644 (file)
index 0000000..0516b95
Binary files /dev/null and b/tests/repo/org.videolan.vlc/en-US/icon.png differ
diff --git a/tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot10.png b/tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot10.png
new file mode 100644 (file)
index 0000000..7aba9dd
Binary files /dev/null and b/tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot10.png differ
diff --git a/tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot12.png b/tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot12.png
new file mode 100644 (file)
index 0000000..92f8da5
Binary files /dev/null and b/tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot12.png differ
diff --git a/tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot15.png b/tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot15.png
new file mode 100644 (file)
index 0000000..79aec82
Binary files /dev/null and b/tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot15.png differ
diff --git a/tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot18.png b/tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot18.png
new file mode 100644 (file)
index 0000000..116d66c
Binary files /dev/null and b/tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot18.png differ
diff --git a/tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot20.png b/tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot20.png
new file mode 100644 (file)
index 0000000..9ca048e
Binary files /dev/null and b/tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot20.png differ
diff --git a/tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot22.png b/tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot22.png
new file mode 100644 (file)
index 0000000..c61893a
Binary files /dev/null and b/tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot22.png differ
diff --git a/tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot4.png b/tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot4.png
new file mode 100644 (file)
index 0000000..dc4c85a
Binary files /dev/null and b/tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot4.png differ
diff --git a/tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot7.png b/tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot7.png
new file mode 100644 (file)
index 0000000..fd86418
Binary files /dev/null and b/tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot7.png differ
diff --git a/tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot9.png b/tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot9.png
new file mode 100644 (file)
index 0000000..9ad6569
Binary files /dev/null and b/tests/repo/org.videolan.vlc/en-US/phoneScreenshots/screenshot9.png differ
diff --git a/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot0.png b/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot0.png
new file mode 100644 (file)
index 0000000..8d32cdd
Binary files /dev/null and b/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot0.png differ
diff --git a/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot1.png b/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot1.png
new file mode 100644 (file)
index 0000000..01d505a
Binary files /dev/null and b/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot1.png differ
diff --git a/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot11.png b/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot11.png
new file mode 100644 (file)
index 0000000..22fa465
Binary files /dev/null and b/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot11.png differ
diff --git a/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot13.png b/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot13.png
new file mode 100644 (file)
index 0000000..2346e1d
Binary files /dev/null and b/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot13.png differ
diff --git a/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot14.png b/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot14.png
new file mode 100644 (file)
index 0000000..e740757
Binary files /dev/null and b/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot14.png differ
diff --git a/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot16.png b/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot16.png
new file mode 100644 (file)
index 0000000..2c3a76c
Binary files /dev/null and b/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot16.png differ
diff --git a/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot17.png b/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot17.png
new file mode 100644 (file)
index 0000000..05a3704
Binary files /dev/null and b/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot17.png differ
diff --git a/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot19.png b/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot19.png
new file mode 100644 (file)
index 0000000..05a3704
Binary files /dev/null and b/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot19.png differ
diff --git a/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot2.png b/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot2.png
new file mode 100644 (file)
index 0000000..a896762
Binary files /dev/null and b/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot2.png differ
diff --git a/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot21.png b/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot21.png
new file mode 100644 (file)
index 0000000..c9afc66
Binary files /dev/null and b/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot21.png differ
diff --git a/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot23.png b/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot23.png
new file mode 100644 (file)
index 0000000..266aff8
Binary files /dev/null and b/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot23.png differ
diff --git a/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot3.png b/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot3.png
new file mode 100644 (file)
index 0000000..c8fad2f
Binary files /dev/null and b/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot3.png differ
diff --git a/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot5.png b/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot5.png
new file mode 100644 (file)
index 0000000..c85fbc0
Binary files /dev/null and b/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot5.png differ
diff --git a/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot6.png b/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot6.png
new file mode 100644 (file)
index 0000000..9c712af
Binary files /dev/null and b/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot6.png differ
diff --git a/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot8.png b/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot8.png
new file mode 100644 (file)
index 0000000..de12807
Binary files /dev/null and b/tests/repo/org.videolan.vlc/en-US/sevenInchScreenshots/screenshot8.png differ