mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-06 07:20:29 +03:00
update: app store metadata from Triple-T gradle play publisher
Since f-droid.org has the source repos, `fdroid update` can just grab files from the source repo. This makes `fdroid update` use the metadata that is laid out in the Triple-T gradle play publisher filesystem layout: https://github.com/Triple-T/gradle-play-publisher#upload-images https://github.com/Triple-T/gradle-play-publisher#play-store-metadata closes #143
This commit is contained in:
parent
89c480181c
commit
822c2d3992
1 changed files with 103 additions and 35 deletions
|
|
@ -66,6 +66,11 @@ all_screen_densities = ['0'] + screen_densities
|
||||||
UsesPermission = collections.namedtuple('UsesPermission', ['name', 'maxSdkVersion'])
|
UsesPermission = collections.namedtuple('UsesPermission', ['name', 'maxSdkVersion'])
|
||||||
UsesPermissionSdk23 = collections.namedtuple('UsesPermissionSdk23', ['name', 'maxSdkVersion'])
|
UsesPermissionSdk23 = collections.namedtuple('UsesPermissionSdk23', ['name', 'maxSdkVersion'])
|
||||||
|
|
||||||
|
ALLOWED_EXTENSIONS = ('png', 'jpg', 'jpeg')
|
||||||
|
GRAPHIC_NAMES = ('featureGraphic', 'icon', 'promoGraphic', 'tvBanner')
|
||||||
|
SCREENSHOT_DIRS = ('phoneScreenshots', 'sevenInchScreenshots',
|
||||||
|
'tenInchScreenshots', 'tvScreenshots', 'wearScreenshots')
|
||||||
|
|
||||||
|
|
||||||
def dpi_to_px(density):
|
def dpi_to_px(density):
|
||||||
return (int(density) * 48) / 160
|
return (int(density) * 48) / 160
|
||||||
|
|
@ -551,6 +556,85 @@ def insert_obbs(repodir, apps, apks):
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
|
def _get_localized_dict(app, locale):
|
||||||
|
'''get the dict to add localized store metadata to'''
|
||||||
|
if 'localized' not in app:
|
||||||
|
app['localized'] = collections.OrderedDict()
|
||||||
|
if locale not in app['localized']:
|
||||||
|
app['localized'][locale] = collections.OrderedDict()
|
||||||
|
return app['localized'][locale]
|
||||||
|
|
||||||
|
|
||||||
|
def _set_localized_text_entry(app, locale, key, f):
|
||||||
|
limit = config['char_limits'][key]
|
||||||
|
localized = _get_localized_dict(app, locale)
|
||||||
|
with open(f) as fp:
|
||||||
|
text = fp.read()[:limit]
|
||||||
|
if len(text) > 0:
|
||||||
|
localized[key] = text
|
||||||
|
|
||||||
|
|
||||||
|
def copy_triple_t_store_metadata(apps):
|
||||||
|
"""Include store metadata from the app's source repo
|
||||||
|
|
||||||
|
The Triple-T Gradle Play Publisher is a plugin that has a standard
|
||||||
|
file layout for all of the metadata and graphics that the Google
|
||||||
|
Play Store accepts. Since F-Droid has the git repo, it can just
|
||||||
|
pluck those files directly. This method reads any text files into
|
||||||
|
the app dict, then copies any graphics into the fdroid repo
|
||||||
|
directory structure.
|
||||||
|
|
||||||
|
This needs to be run before insert_localized_app_metadata() so that
|
||||||
|
the graphics files that are copied into the fdroid repo get
|
||||||
|
properly indexed.
|
||||||
|
|
||||||
|
https://github.com/Triple-T/gradle-play-publisher#upload-images
|
||||||
|
https://github.com/Triple-T/gradle-play-publisher#play-store-metadata
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
if not os.path.isdir('build'):
|
||||||
|
return # nothing to do
|
||||||
|
|
||||||
|
for packageName, app in apps.items():
|
||||||
|
for d in glob.glob(os.path.join('build', packageName, '*', 'src', '*', 'play')):
|
||||||
|
logging.debug('Triple-T Gradle Play Publisher: ' + d)
|
||||||
|
for root, dirs, files in os.walk(d):
|
||||||
|
segments = root.split('/')
|
||||||
|
locale = segments[-2]
|
||||||
|
for f in files:
|
||||||
|
if f == 'fulldescription':
|
||||||
|
_set_localized_text_entry(app, locale, 'Description',
|
||||||
|
os.path.join(root, f))
|
||||||
|
continue
|
||||||
|
elif f == 'shortdescription':
|
||||||
|
_set_localized_text_entry(app, locale, 'Summary',
|
||||||
|
os.path.join(root, f))
|
||||||
|
continue
|
||||||
|
elif f == 'title':
|
||||||
|
_set_localized_text_entry(app, locale, 'Name',
|
||||||
|
os.path.join(root, f))
|
||||||
|
continue
|
||||||
|
elif f == 'video':
|
||||||
|
_set_localized_text_entry(app, locale, 'Video',
|
||||||
|
os.path.join(root, f))
|
||||||
|
continue
|
||||||
|
|
||||||
|
base, extension = common.get_extension(f)
|
||||||
|
dirname = os.path.basename(root)
|
||||||
|
if dirname in GRAPHIC_NAMES and extension in ALLOWED_EXTENSIONS:
|
||||||
|
if segments[-2] == 'listing':
|
||||||
|
locale = segments[-3]
|
||||||
|
else:
|
||||||
|
locale = segments[-2]
|
||||||
|
destdir = os.path.join('repo', packageName, locale)
|
||||||
|
os.makedirs(destdir, mode=0o755, exist_ok=True)
|
||||||
|
sourcefile = os.path.join(root, f)
|
||||||
|
destfile = os.path.join(destdir, dirname + '.' + extension)
|
||||||
|
logging.debug('copying ' + sourcefile + ' ' + destfile)
|
||||||
|
shutil.copy(sourcefile, destfile)
|
||||||
|
|
||||||
|
|
||||||
def insert_localized_app_metadata(apps):
|
def insert_localized_app_metadata(apps):
|
||||||
"""scans standard locations for graphics and localized text
|
"""scans standard locations for graphics and localized text
|
||||||
|
|
||||||
|
|
@ -575,24 +659,9 @@ def insert_localized_app_metadata(apps):
|
||||||
https://github.com/fastlane/fastlane/blob/1.109.0/supply/README.md#images-and-screenshots
|
https://github.com/fastlane/fastlane/blob/1.109.0/supply/README.md#images-and-screenshots
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def get_localized_dict(apps, packageName, locale):
|
|
||||||
'''get the dict to add localized store metadata to'''
|
|
||||||
if 'localized' not in apps[packageName]:
|
|
||||||
apps[packageName]['localized'] = collections.OrderedDict()
|
|
||||||
if locale not in apps[packageName]['localized']:
|
|
||||||
apps[packageName]['localized'][locale] = collections.OrderedDict()
|
|
||||||
return apps[packageName]['localized'][locale]
|
|
||||||
|
|
||||||
allowed_extensions = ('png', 'jpg', 'jpeg')
|
|
||||||
graphicnames = ('featureGraphic', 'icon', 'promoGraphic', 'tvBanner')
|
|
||||||
screenshotdirs = ('phoneScreenshots', 'sevenInchScreenshots',
|
|
||||||
'tenInchScreenshots', 'tvScreenshots', 'wearScreenshots')
|
|
||||||
|
|
||||||
sourcedirs = glob.glob(os.path.join('build', '[A-Za-z]*', 'fastlane', 'metadata', 'android', '[a-z][a-z][A-Z-.@]*'))
|
sourcedirs = glob.glob(os.path.join('build', '[A-Za-z]*', 'fastlane', 'metadata', 'android', '[a-z][a-z][A-Z-.@]*'))
|
||||||
sourcedirs += glob.glob(os.path.join('metadata', '[A-Za-z]*', '[a-z][a-z][A-Z-.@]*'))
|
sourcedirs += glob.glob(os.path.join('metadata', '[A-Za-z]*', '[a-z][a-z][A-Z-.@]*'))
|
||||||
|
|
||||||
char_limits = config['char_limits']
|
|
||||||
|
|
||||||
for d in sorted(sourcedirs):
|
for d in sorted(sourcedirs):
|
||||||
if not os.path.isdir(d):
|
if not os.path.isdir(d):
|
||||||
continue
|
continue
|
||||||
|
|
@ -605,35 +674,33 @@ def insert_localized_app_metadata(apps):
|
||||||
locale = segments[-1]
|
locale = segments[-1]
|
||||||
destdir = os.path.join('repo', packageName, locale)
|
destdir = os.path.join('repo', packageName, locale)
|
||||||
for f in files:
|
for f in files:
|
||||||
key = None
|
|
||||||
if f == 'full_description.txt':
|
if f == 'full_description.txt':
|
||||||
key = 'Description'
|
_set_localized_text_entry(apps[packageName], locale, 'Description',
|
||||||
|
os.path.join(root, f))
|
||||||
|
continue
|
||||||
elif f == 'short_description.txt':
|
elif f == 'short_description.txt':
|
||||||
key = 'Summary'
|
_set_localized_text_entry(apps[packageName], locale, 'Summary',
|
||||||
|
os.path.join(root, f))
|
||||||
|
continue
|
||||||
elif f == 'title.txt':
|
elif f == 'title.txt':
|
||||||
key = 'Name'
|
_set_localized_text_entry(apps[packageName], locale, 'Name',
|
||||||
|
os.path.join(root, f))
|
||||||
|
continue
|
||||||
elif f == 'video.txt':
|
elif f == 'video.txt':
|
||||||
key = 'Video'
|
_set_localized_text_entry(apps[packageName], locale, 'Video',
|
||||||
|
os.path.join(root, f))
|
||||||
if key:
|
|
||||||
limit = char_limits[key]
|
|
||||||
localized = get_localized_dict(apps, packageName, locale)
|
|
||||||
with open(os.path.join(root, f)) as fp:
|
|
||||||
text = fp.read()[:limit]
|
|
||||||
if len(text) > 0:
|
|
||||||
localized[key] = text
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
base, extension = common.get_extension(f)
|
base, extension = common.get_extension(f)
|
||||||
if base in graphicnames and extension in allowed_extensions:
|
if base in GRAPHIC_NAMES and extension in ALLOWED_EXTENSIONS:
|
||||||
os.makedirs(destdir, mode=0o755, exist_ok=True)
|
os.makedirs(destdir, mode=0o755, exist_ok=True)
|
||||||
logging.debug('copying ' + os.path.join(root, f) + ' ' + destdir)
|
logging.debug('copying ' + os.path.join(root, f) + ' ' + destdir)
|
||||||
shutil.copy(os.path.join(root, f), destdir)
|
shutil.copy(os.path.join(root, f), destdir)
|
||||||
for d in dirs:
|
for d in dirs:
|
||||||
if d in screenshotdirs:
|
if d in SCREENSHOT_DIRS:
|
||||||
for f in glob.glob(os.path.join(root, d, '*.*')):
|
for f in glob.glob(os.path.join(root, d, '*.*')):
|
||||||
_, extension = common.get_extension(f)
|
_, extension = common.get_extension(f)
|
||||||
if extension in allowed_extensions:
|
if extension in ALLOWED_EXTENSIONS:
|
||||||
screenshotdestdir = os.path.join(destdir, d)
|
screenshotdestdir = os.path.join(destdir, d)
|
||||||
os.makedirs(screenshotdestdir, mode=0o755, exist_ok=True)
|
os.makedirs(screenshotdestdir, mode=0o755, exist_ok=True)
|
||||||
logging.debug('copying ' + f + ' ' + screenshotdestdir)
|
logging.debug('copying ' + f + ' ' + screenshotdestdir)
|
||||||
|
|
@ -657,14 +724,14 @@ def insert_localized_app_metadata(apps):
|
||||||
logging.warning('Found "%s" graphic without metadata for app "%s"!'
|
logging.warning('Found "%s" graphic without metadata for app "%s"!'
|
||||||
% (filename, packageName))
|
% (filename, packageName))
|
||||||
continue
|
continue
|
||||||
graphics = get_localized_dict(apps, packageName, locale)
|
graphics = _get_localized_dict(apps[packageName], locale)
|
||||||
|
|
||||||
if extension not in allowed_extensions:
|
if extension not in ALLOWED_EXTENSIONS:
|
||||||
logging.warning('Only PNG and JPEG are supported for graphics, found: ' + f)
|
logging.warning('Only PNG and JPEG are supported for graphics, found: ' + f)
|
||||||
elif base in graphicnames:
|
elif base in GRAPHIC_NAMES:
|
||||||
# there can only be zero or one of these per locale
|
# there can only be zero or one of these per locale
|
||||||
graphics[base] = filename
|
graphics[base] = filename
|
||||||
elif screenshotdir in screenshotdirs:
|
elif screenshotdir in SCREENSHOT_DIRS:
|
||||||
# there can any number of these per locale
|
# there can any number of these per locale
|
||||||
logging.debug('adding ' + base + ':' + f)
|
logging.debug('adding ' + base + ':' + f)
|
||||||
if screenshotdir not in graphics:
|
if screenshotdir not in graphics:
|
||||||
|
|
@ -1394,6 +1461,7 @@ def main():
|
||||||
if newmetadata:
|
if newmetadata:
|
||||||
apps = metadata.read_metadata()
|
apps = metadata.read_metadata()
|
||||||
|
|
||||||
|
copy_triple_t_store_metadata(apps)
|
||||||
insert_obbs(repodirs[0], apps, apks)
|
insert_obbs(repodirs[0], apps, apks)
|
||||||
insert_localized_app_metadata(apps)
|
insert_localized_app_metadata(apps)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue