Created
May 8, 2018 10:58
-
-
Save ghandic/e082c46b36ce8084a40f79244b5d0dba to your computer and use it in GitHub Desktop.
Finds all available custom app url strings, for example if you paste and run this github link in your browser x-github-client://openRepo/https://github.com/ghandic/facial_analysis_api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import plistlib | |
import glob | |
import json | |
import os | |
app_urls=[] | |
for app in glob.glob('/Applications/*.app'): | |
urls=[] | |
for pl in glob.glob(os.path.join(app, 'contents/Info.plist')): | |
try: | |
plist = plistlib.readPlist(pl) | |
for urltype in plist.get('CFBundleURLTypes'): | |
for scheme in urltype.get('CFBundleURLSchemes'): | |
urls.append(scheme) | |
except: | |
pass | |
if len(urls) > 0: | |
app_urls.append({app.replace('/Applications/', '').replace('.app', ''):urls}) | |
print(json.dumps(app_urls, indent=2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment