Ed Brannin avatar Ed Brannin committed 1f86e32 Draft

initial

Comments (0)

Files changed (3)

+bin
+include
+lib
+syntax:glob
+*.pyc
+.*~
+*~
+.*.sw?
+.Python@
+import json
+import yaml
+
+from manifest import find_newest_backup_dir
+from manifest import BackupDir
+
+#print find_newest_backup_dir(),
+
+bd = BackupDir(find_newest_backup_dir())
+
+if __name__ == '__main__':
+  springboard_plist_filename = "ea4f4a1a45ab93a97917e22dd28d298d78686dd4"
+  plist = bd.plist(springboard_plist_filename)
+  print json.dumps(plist)
+import os
+import biplist
+import plistlib
+
+from io import BytesIO
+from zipfile import ZipFile
+
+import traceback
+
+def read_app_plist(ipa, filename="iTunesMetadata.plist"):
+  plist = None
+  try:
+    plist_data = BytesIO(ipa.read(filename))
+    plist = biplist.readPlist(plist_data)
+    plist_data.close()
+  except:
+    # TODO: Figure out when Apple stopped using XML plists
+    plist_data = BytesIO(ipa.read(filename))
+    plist = plistlib.readPlist(plist_data)
+    plist_data.close()
+  return plist
+
+def read_plist(filename="iTunesMetadata.plist"):
+  plist = None
+  try:
+    plist_data = BytesIO(filename)
+    plist = biplist.readPlist(plist_data)
+    plist_data.close()
+  except:
+    traceback.print_exc()
+    # TODO: Figure out when Apple stopped using XML plists
+    plist_data = BytesIO(filename)
+    plist = plistlib.readPlist(plist_data)
+    plist_data.close()
+  return plist
+
+def find_app_dir():
+  return os.path.expanduser("~/Music/iTunes/iTunes Music/Mobile Applications")
+
+def find_backup_dir(udid=""):
+  return os.path.expanduser("~/Library/Application Support/MobileSync/Backup/%s" % udid)
+
+def find_newest_backup_dir():
+  root = find_backup_dir()
+  dirs = [os.path.join(root, d) for d in os.listdir(root)]
+  dirs_by_date = [[os.path.getmtime(d), d] for d in dirs]
+  dirs_by_date.sort(reverse=True)
+  return dirs_by_date[0][1]
+
+class BackupDir(object):
+  def __init__(self, path):
+    self.path = path
+  def plist(self, path):
+    try:
+      file_path = os.path.join(self.path, path)
+      return read_plist(read_plist(file_path))
+    except:
+      print "Error reading from %s" % file_path
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.