Created
April 22, 2016 11:11
-
-
Save larsyencken/70726ffa4f99f5b4b70e10a4afee88d9 to your computer and use it in GitHub Desktop.
Lifesum: unpack iTunes receipts
This file contains hidden or 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 base64 | |
import json | |
def unpack_itunes_receipt(receipt_b64): | |
receipt_s = base64.b64decode(receipt_b64).decode('utf8') | |
receipt_json = receipt_s.replace('" = "', '": "').replace(';', ',').replace(',\n}', '\n}') | |
receipt = json.loads(receipt_json) | |
if 'purchase-info' in receipt: | |
receipt['purchase-info'] = unpack_itunes_receipt(receipt['purchase-info']) | |
return receipt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment