# Path: resources/lib/PhoneBooks/pyicloud/exceptions.py
# class PyiCloudAPIResponseError(PyiCloudException):
#     def __init__(self, reason, code):
#         self.reason = reason
#         self.code = code
#         message = reason
#         if code:
#             message += " (%s)" % code
# 
#         super(PyiCloudAPIResponseError, self).__init__(message)
# 
# class PyiCloudBinaryFeedParseError(Exception):
#     pass
# 
# class PyiCloudPhotoLibraryNotActivatedErrror(Exception):
#     pass


import sys
import json
import urllib
from datetime import datetime
from base64 import b64decode
from bitstring import ConstBitStream
from ..exceptions import (
    PyiCloudAPIResponseError,
    PyiCloudBinaryFeedParseError,
    PyiCloudPhotoLibraryNotActivatedErrror
)
        binaryfeed = bytearray(b64decode(feed))
        bitstream = ConstBitStream(binaryfeed)

        payload_encoding = binaryfeed[0]
        if payload_encoding != bitstream.read("uint:8"):
            raise PyiCloudBinaryFeedParseError(
                "Missmatch betweeen binaryfeed and bistream payload encoding")

        ASSET_PAYLOAD = 255
        ASSET_WITH_ORIENTATION_PAYLOAD = 254
        ASPECT_RATIOS = [
            0.75,
            4.0 / 3.0 - 3.0 * (4.0 / 3.0 - 1.0) / 4.0,
            4.0 / 3.0 - 2.0 * (4.0 / 3.0 - 1.0) / 4.0,
            1.25,
            4.0 / 3.0, 1.5 - 2.0 * (1.5 - 4.0 / 3.0) / 3.0,
            1.5 - 1.0 * (1.5 - 4.0 / 3.0) / 3.0,
            1.5,
            1.5694444444444444,
            1.6388888888888888,
            1.7083333333333333,
            16.0 / 9.0,
            2.0 - 2.0 * (2.0 - 16.0 / 9.0) / 3.0,
            2.0 - 1.0 * (2.0 - 16.0 / 9.0) / 3.0,
            2,
            3
        ]

        valid_payloads = [ASSET_PAYLOAD, ASSET_WITH_ORIENTATION_PAYLOAD]
        if payload_encoding not in valid_payloads:

# Path: resources/lib/PhoneBooks/pyicloud/exceptions.py
# class PyiCloudAPIResponseError(PyiCloudException):
#     def __init__(self, reason, code):
#         self.reason = reason
#         self.code = code
#         message = reason
#         if code:
#             message += " (%s)" % code
# 
#         super(PyiCloudAPIResponseError, self).__init__(message)
# 
# class PyiCloudBinaryFeedParseError(Exception):
#     pass
# 
# class PyiCloudPhotoLibraryNotActivatedErrror(Exception):
#     pass


# Path: resources/lib/PhoneBooks/pyicloud/services/photos.py
import sys
import json
import urllib
from datetime import datetime
from base64 import b64decode
from bitstring import ConstBitStream
from ..exceptions import (
    PyiCloudAPIResponseError,
    PyiCloudBinaryFeedParseError,
    PyiCloudPhotoLibraryNotActivatedErrror
)

        binaryfeed = bytearray(b64decode(feed))
        bitstream = ConstBitStream(binaryfeed)

        payload_encoding = binaryfeed[0]
        if payload_encoding != bitstream.read("uint:8"):
            raise PyiCloudBinaryFeedParseError(
                "Missmatch betweeen binaryfeed and bistream payload encoding")

        ASSET_PAYLOAD = 255
        ASSET_WITH_ORIENTATION_PAYLOAD = 254
        ASPECT_RATIOS = [
            0.75,
            4.0 / 3.0 - 3.0 * (4.0 / 3.0 - 1.0) / 4.0,
            4.0 / 3.0 - 2.0 * (4.0 / 3.0 - 1.0) / 4.0,
            1.25,
            4.0 / 3.0, 1.5 - 2.0 * (1.5 - 4.0 / 3.0) / 3.0,
            1.5 - 1.0 * (1.5 - 4.0 / 3.0) / 3.0,
            1.5,
            1.5694444444444444,
            1.6388888888888888,
            1.7083333333333333,
            16.0 / 9.0,
            2.0 - 2.0 * (2.0 - 16.0 / 9.0) / 3.0,
            2.0 - 1.0 * (2.0 - 16.0 / 9.0) / 3.0,
            2,
            3
        ]

        valid_payloads = [ASSET_PAYLOAD, ASSET_WITH_ORIENTATION_PAYLOAD]
        if payload_encoding not in valid_payloads:

            raise PyiCloudBinaryFeedParseError(