def __ipa_parse(file_path: str):
"""
??ipa?
:param file_path: ipa??
:return: PackageParse
"""
ipa_file = ZipFile(file_path)
# ??info.plist??
ns = [n for n in ipa_file.namelist() if Regex.IPAInfoPlistPath.match(n)]
if not ns:
log.warning('parse info.plist failure: {}'.format(file_path))
return
plist_path = ns[-1]
# ??plist
plist_data = ipa_file.read(plist_path)
plist_file = plistlib.loads(plist_data)
# ??icon'CFBundleIconFiles' (4400546488)
if plist_file.get('CFBundleIconFiles'):
icon_name = plist_file['CFBundleIconFiles'][-1]
else:
if plist_file.get('CFBundleIcons'):
icon_dict = plist_file['CFBundleIcons']
elif plist_file.get('CFBundleIcons'):
icon_dict = plist_file['CFBundleIcons~ipad']
else:
log.warning('parse icon failure: {}'.format(file_path))
return
icon_name = icon_dict['CFBundlePrimaryIcon']['CFBundleIconFiles'][-1]
log.debug('parse icon name: {}'.format(icon_name))
# ??icon??
re_icon_name_end = '(@\dx)\.png' if not icon_name.endswith('.png') else ''
re_icon_name = re.compile('([^/]+/){{2}}{}{}'.format(icon_name, re_icon_name_end))
ns = [n for n in ipa_file.namelist() if re_icon_name.match(n)]
if not ns:
log.warning('read icon failure: {}'.format(file_path))
return
icon_path = ns[-1]
log.debug('parse icon path: {}'.format(icon_path))
# ???
version_number = plist_file['CFBundleShortVersionString']
# build?
build_number = plist_file['CFBundleVersion']
# ??
package_name = plist_file['CFBundleIdentifier']
# app??
app_name = plist_file['CFBundleDisplayName'] if plist_file.get('CFBundleDisplayName') else plist_file[
'CFBundleName']
log.debug(
'app: {}, V{} build {}, package: {}'.format(app_name, version_number, build_number, package_name))
return PackageParse(ipa_file, AppType.iOS, package_name, app_name, icon_path, version_number, build_number)
评论列表
文章目录